[#35036] Intentional Programming — "John" <nojgoalbyspam@...>

Hi all

17 messages 2002/03/01

[#35112] RDoc question — Michael Davis <mdavis@...>

I have a question about RDoc. I would like to reference an external

17 messages 2002/03/02

[#35162] string to array and back — Ron Jeffries <ronjeffries@...>

I am needing to convert strings to arrays of bytes and back. I see pack and

19 messages 2002/03/03

[#35364] file reading impossibly slow? — Ron Jeffries <ronjeffries@...>

So I'm doing this benchmark to work with my set program. Part of the problem is

18 messages 2002/03/07

[#35429] Interesting link on static/dynamic typing... — Robert Feldt <feldt@...>

...relevant to Ruby compared to other languages discussion:

25 messages 2002/03/08
[#35441] Re: Interesting link on static/dynamic typing... — Paul Brannan <paul@...> 2002/03/08

On Fri, Mar 08, 2002 at 05:34:43PM +0900, Robert Feldt wrote:

[#35460] Spam, ruby-talk, and me — Dave Thomas <Dave@...>

14 messages 2002/03/08

[#35537] Confusion — David Corbin <dcorbin@...>

The following is from my debugging through xmlc.rb

16 messages 2002/03/10

[#35579] RE: WIN32OLE and LDAP — "Morris, Chris" <chris.morris@...>

> The new version 0.4.2 of Win32OLE has WIN32OLE.bind method.

16 messages 2002/03/11

[#35652] Method type 'abstract' — Peter Hickman <peter@...>

The one thing I miss in Ruby is the abstract class method to go along

15 messages 2002/03/12

[#35653] Some potential RCRs — "Bob Alexander" <bobalex@...>

Here are a few thing I am considering submitting as RCRs. I'm looking =

50 messages 2002/03/12
[#35672] Re: Some potential RCRs — matz@... (Yukihiro Matsumoto) 2002/03/12

Hi,

[#35683] Re: Some potential RCRs — Massimiliano Mirra <list@...> 2002/03/12

On Wed, Mar 13, 2002 at 03:58:01AM +0900, Yukihiro Matsumoto wrote:

[#35697] Re: Some potential RCRs — David Alan Black <dblack@...> 2002/03/13

Hello --

[#35694] rpkg 0.3 — Massimiliano Mirra <list@...>

14 messages 2002/03/13
[#35699] RE: [ANN] rpkg 0.3 — <james@...> 2002/03/13

>

[#35787] testunit - setup -> set_up ? — "Morris, Chris" <chris.morris@...>

I'm just starting to use testunit instead of rubyunit ... I noticed with an

21 messages 2002/03/13
[#35793] RE: testunit - setup -> set_up ? — "Nathaniel Talbott" <nathaniel@...> 2002/03/13

Morris, Chris [mailto:chris.morris@snelling.com] wrote:

[#35796] Re: testunit - setup -> set_up ? — Dave Thomas <Dave@...> 2002/03/13

"Nathaniel Talbott" <nathaniel@talbott.ws> writes:

[#35797] RE: testunit - setup -> set_up ? — "Nathaniel Talbott" <nathaniel@...> 2002/03/13

dave@thomases.com [mailto:dave@thomases.com] wrote:

[#35898] camelCase and underscore_style — "Morris, Chris" <chris.morris@...>

First, a question. If underscore_style is the Ruby norm for methods and the

20 messages 2002/03/15
[#35924] Re: camelCase and underscore_style — "Guy N. Hurst" <gnhurst@...> 2002/03/15

Phil Tomson wrote:

[#35930] RE: camelCase and underscore_style — "Nathaniel Talbott" <nathaniel@...> 2002/03/16

Guy N. Hurst [mailto:gnhurst@hurstlinks.com] wrote:

[#35989] ANN: Locana GUI and GUI Builder version 0.81 — Michael Davis <mdavis@...>

I am pleased to announce release 0.81 of Locana. Locana is a GUI

16 messages 2002/03/16

[#35992] XPath — Michael Schuerig <schuerig@...>

27 messages 2002/03/16

[#36034] Mini Rant: Indenting — Thomas Hurst <tom.hurst@...>

Why is it that I see *so* much code like:

14 messages 2002/03/17

[#36049] web templating for static sites? — Massimiliano Mirra <list@...>

I'm using the Template Toolkit for generating static web sites and I

42 messages 2002/03/17
[#36426] web standars (was: web templating for static sites?) — Tobias Reif <tobiasreif@...> 2002/03/20

Albert Wagner wrote:

[#36052] Xml Serialization for Ruby — "Chris Morris" <chrismo@...>

=Xml Serialization for Ruby

20 messages 2002/03/17
[#36059] Re: [ANN] Xml Serialization for Ruby — Massimiliano Mirra <list@...> 2002/03/17

On Mon, Mar 18, 2002 at 05:20:56AM +0900, Chris Morris wrote:

[#36067] eval/Module question — David Corbin <dcorbin@...>

If I have a String src that is similar to the following:

13 messages 2002/03/18

[#36157] Development of Windows version of Ruby — ptkwt@...1.aracnet.com (Phil Tomson)

Now that we've dumped the cygwin requirement for the Windows version of

63 messages 2002/03/18
[#36330] Re: Development of Windows version of Ruby — Ron Jeffries <ronjeffries@...> 2002/03/19

On Tue, 19 Mar 2002 14:05:27 GMT, "Albert L. Wagner" <alwagner@uark.edu> wrote:

[#36431] Re: Development of Windows version of Ruby — Dennis Newbold <dennisn@...> 2002/03/20

[#36458] Windows version of Ruby (proposals) — ptkwt@... (Phil Tomson) 2002/03/21

Dennis Newbold <dennisn@pe.net> wrote in message news:<Pine.GSO.3.96.1020320113603.22242B-100000@shell2>...

[#36482] RE: Windows version of Ruby (proposals) — "Christian Boos" <cboos@...> 2002/03/21

Some thoughts on the 2 first Windows issues, plus a 4th one...

[#36496] Re: Windows version of Ruby (proposals) — Dave Thomas <Dave@...> 2002/03/21

"Christian Boos" <cboos@bct-technology.com> writes:

[#36510] Re: Windows version of Ruby (proposals) — nobu.nokada@... 2002/03/21

Hi,

[#36514] Re: Windows version of Ruby (proposals) — Dave Thomas <Dave@...> 2002/03/21

nobu.nokada@softhome.net writes:

[#36518] Re: Windows version of Ruby (proposals) — nobu.nokada@... 2002/03/21

Hi,

[#36211] dots in Dir.entries — matz@... (Yukihiro Matsumoto)

Hi,

22 messages 2002/03/19

[#36231] style choice — Ron Jeffries <ronjeffries@...>

A style question for the community ... which of the following do you prefer, and

18 messages 2002/03/19

[#36345] ANN: REXML 2.0 — Sean Russell <ser@...>

I have a feeling there will only be three major revisions of REXML. Version

19 messages 2002/03/20

[#36610] Re: Windows version of Ruby (proposals) — Ron Jeffries <ronjeffries@...>

On Thu, 21 Mar 2002 14:11:55 GMT, Dave Thomas <Dave@PragmaticProgrammer.com> wrote:

16 messages 2002/03/22

[#36645] Ruby for Mac OS 10.1 — Jim Freeze <jim@...>

Hi:

28 messages 2002/03/23

[#36768] Re: Difference between 'do' and 'begin' — Clemens Hintze <c.hintze@...>

In <slrna9ulvi.f2h.mwg@fluffy.isd.dp.ua> Wladimir Mutel <mwg@fluffy.isd.dp.ua> writes:

23 messages 2002/03/26
[#36783] RE: Difference between 'do' and 'begin' — <james@...> 2002/03/26

[#36792] Re: Difference between 'do' and 'begin' — Kent Dahl <kentda@...> 2002/03/26

james@rubyxml.com wrote:

[#36808] Error calling Tk in a loop — <james@...>

I'm trying to write some code that pops up a Tk window when for certain

15 messages 2002/03/26

[#36841] RE: Windows version of Ruby (proposals) — "Andres Hidalgo" <sol123@...>

I believe that Ruby has a place in windows (Office), I happened to have

14 messages 2002/03/27

[#36863] Hash.new(Hash.new) doesn't use Hash.new as default value — "Jonas Delfs" <jonas@...>

Hi -

18 messages 2002/03/27

[#37080] Why isn't Math object-oriented? — Bil Kleb <W.L.Kleb@...>

So I'm reading along in the Pixaxe book (yet again), and I am told

15 messages 2002/03/30

[#37121] String#begins?(s) — timsuth@... (Tim Sutherland)

class String

24 messages 2002/03/31

[ANN] Xml Serialization 1.0.pre2

From: "Chris Morris" <home@...>
Date: 2002-03-29 04:59:36 UTC
List: ruby-talk #36996
Thanks to all for the feedback so far. The latest readme has all the new
stuff intertwined. Hit the Usage section for more.

=Xml Serialization for Ruby

Download 1.0.pre2::
http://prdownloads.sourceforge.net/scrapware/clxmlserial.1.0.pre2.zip
REXML (>=1.2.5):: http://www.germane-software.com/~ser/Software/rexml
Home Page:: http://clabs.org/clxmlserial.htm
ViewCVS::
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/scrapware/clxmlserial/
Anon CVS:: http://sourceforge.net/cvs/?group_id=17451

===Overview

Xml Serialization allows classes to be marshalled to and from XML, with an
emphasis on concise, human readable and editable XML.

It consists of a module (+XmlSerialization+) and modified standard classes
which
add +to_xml+ and +from_xml+ methods. +to_xml+ is an instance method which
returns an XML element containing the data from each instance variable in
the
including class. +from_xml+ is a singleton/class method which accepts an XML
element and creates an instance of the class with the data in the element.

Currently, REXML is used for XML parsing. In later versions, I plan to
refactor
out the dependency on REXML so other XML processors could be plugged-in.

This is still very much in a pre-release state, though functional. If your
interested in this project, please feel free to give me feedback (code
contributions are of course always welcome).

===License

Copyright (c) 2002, Chris Morris (mailto:chrismo@clabs.org). BSD license.

===Install

  % ruby install.rb

===Usage

See the examples directory for a sample. Unit tests are also included in
clxmlserialtest.rb. Here's a quick sample:

  require 'cl/xmlserial'

  class MyClass
    include XmlSerialization

    attr_accessor :attr

    def initialize
      attr = 0
    end
  end

  doc = REXML::Document.new(File.open("class.xml"))
  c = MyClass.from_xml(doc.root)
  c.attr = 60
  f = File.new("class.xml", File::CREAT|File::TRUNC|File::RDWR)
  c.to_xml.write(f, -1)
  f.close

yields either:

  <MyClass>
    <attr>
      <Fixnum>60</Fixnum>
    </attr>
  </MyClass>

or:

  <MyClass>
    <attr>60</attr>
  </MyClass>

The +XmlSerialization+ module includes a singleton configuration class with
an
+outputTypeElements+ setting. Setting this to false gives more concise XML
(the
latter example above). In order to ensure the data is read in correctly, the
instance variables should be initialized in the class's initialize method.

Attempts to correctly grok Strings and Numerics will be made for
uninitialized
instance vars, so the latter example above will read in 60 as a Fixnum, even
if
@attr is not initialized. If the value is neither a valid Integer or Float,
then
it's read in as a String.

All forms of Ruby Numeric notation are supported as well. So this:

  <Array>-5.4,5.a,4e5,0xaabb,123_456</Array>

is read in as:

  [-5.4, "5.a", 400000.0, 43707, 123456]

Arrays and Hashes also work with +outputTypeElements+ set to false, assuming
the
items/keys/values are all of type String or Numeric. In that case, a CSV
string
is output. For example:

  c = MyClass.new
  c.attr = ['a', 5]

becomes

  <MyClass>
    <attr>a,5</attr>
  </MyClass>

and

  c = MyClass.new
  c.attr = { 'a' => 5, 'b' => 6 }

becomes

  <MyClass>
    <attr>a=5,b=6</attr>
  </MyClass>

If any of the items/keys/values are neither a String or Numeric, then type
elements are automagically used:

  c = MyClass.new
  c.attr = ['a', ['b', 'c']]

becomes

  <MyClass>
    <attr>
      <Array>
        <String>a</String>
        <Array>
          <String>b</String>
          <String>c</String>
        </Array>
      </Array>
    </attr>
  </MyClass>

Currently, the following standard classes are supported:

* +String+
* +Fixnum+
* +Array+
* +Hash+
* +Time+
* +Integer+ (+Fixnum+, +Bignum+)
* +Float+

In This Thread

Prev Next