[ANN] xml-configfile 0.8.0

Yo!

I have just released version 0.8.0 of xml-configfile, a library for an
easy handling of XML configuration files. It allows you to access
configuration parameters stored in an XML file by using XPath.

Changes since last release:

  • Handling of attributes is configurable now. They will be
    expanded by get_parameters, if the user wants them to.
  • [] is an alias for method get_parameter now.
  • Method get_parameter_array was added by Nigel Ball.
  • Changed method names to Ruby style (using underscores instead
    of CamelCase). The old method names still work, but will be
    removed in the future.
  • ‘ruby install.rb config’ prints a warning now, if REXML
    is not installed (pre-config.rb was added).
  • Added and improved documentation.

You can find xml-configfile on RAA at
http://raa.ruby-lang.org/list.rhtml?name=xml-configfile

and a nice tutorial on its own website
http://www.maik-schmidt.de/projects/xmlconfigfile/index.html

Have fun!

You know, this could be used for a lot more than just config files.
It could probably be extended to store any object as long as it’s data
contains strings only.

For instance, in my tutorial I am working on an addressbook application.
We create an AddressBook class which, internally, is an an array whose
entries are Person classes. The Person class is a hash with entries such
as “name” and “phone”.

It would be great if I could save and load this entire class with
something as simple as:

xml_save(addressbook, “file.xml”)
addressbook = xml_open(“file.xml”)

Just a thought.

Cheers,
Daniel.

···

On Sat, Feb 22, 2003 at 01:42:34AM +0900, Maik Schmidt wrote:

Yo!

I have just released version 0.8.0 of xml-configfile, a library for an
easy handling of XML configuration files. It allows you to access
configuration parameters stored in an XML file by using XPath.

Changes since last release:

  • Handling of attributes is configurable now. They will be
    expanded by get_parameters, if the user wants them to.
  • is an alias for method get_parameter now.
  • Method get_parameter_array was added by Nigel Ball.
  • Changed method names to Ruby style (using underscores instead
    of CamelCase). The old method names still work, but will be
    removed in the future.
  • ‘ruby install.rb config’ prints a warning now, if REXML
    is not installed (pre-config.rb was added).
  • Added and improved documentation.

You can find xml-configfile on RAA at
http://raa.ruby-lang.org/list.rhtml?name=xml-configfile

and a nice tutorial on its own website
http://www.maik-schmidt.de/projects/xmlconfigfile/index.html

Have fun!


Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

Daniel Carrera wrote:

It would be great if I could save and load this entire class with
something as simple as:

xml_save(addressbook, “file.xml”)
addressbook = xml_open(“file.xml”)

One of the most important points in my TODO file is “allow write
access”. But this will really turn class XmlConfigFile into something
bigger. There is a Perl module called XML::Simple that provides exactly
the functionality you are looking for and I am currently trying to port
it to Ruby. XmlConfigFile will simply use this new class then.

Cheers,

If you want to serialize objects, YAML4R makes it quick and easy…

···

On Sat, Feb 22, 2003 at 02:04:36AM +0900, Daniel Carrera wrote:

You know, this could be used for a lot more than just config files.
It could probably be extended to store any object as long as it’s data
contains strings only.

For instance, in my tutorial I am working on an addressbook application.
We create an AddressBook class which, internally, is an an array whose
entries are Person classes. The Person class is a hash with entries such
as “name” and “phone”.

It would be great if I could save and load this entire class with
something as simple as:

xml_save(addressbook, “file.xml”)
addressbook = xml_open(“file.xml”)


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

MS-DOS, you can’t live with it, you can live without it.
– from Lars Wirzenius’ .sig

It would be great if I could save and load this entire class with
something as simple as:

xml_save(addressbook, “file.xml”)
addressbook = xml_open(“file.xml”)

If you want to serialize objects, YAML4R makes it quick and easy…
http://yaml4r.sourceforge.net/

And if you want XML, you can try http://clabs.org/clxmlserial.htm. Biggest
thing it lacks now is it can’t handle circular references.

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:

60

or:

60

YAML looks pretty neat. It’s simple enough for an introductory tutorial.
I can just teach the student:

Save addressbook

File.open(“file.yaml”, “w”).puts address_book.yaml

Open addressbook

address_book = YAML::load( File.open(“file.yaml”) )

Thanks.

···

On Sat, Feb 22, 2003 at 04:04:46AM +0900, Mauricio Fernández wrote:

xml_save(addressbook, “file.xml”)
addressbook = xml_open(“file.xml”)

If you want to serialize objects, YAML4R makes it quick and easy…
http://yaml4r.sourceforge.net/


Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

If you want to serialize objects, YAML4R makes it quick and easy…
http://yaml4r.sourceforge.net/

YAML looks pretty neat. It’s simple enough for an introductory tutorial.
I can just teach the student:

Save addressbook

File.open(“file.yaml”, “w”).puts address_book.yaml
.to_yaml

Open addressbook

address_book = YAML::load( File.open(“file.yaml”) )

Marshal does the job if you want to stay in the standard lib.

···

On Sat, Feb 22, 2003 at 05:42:00AM +0900, Daniel Carrera wrote:


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

any new sendmail hole I have to fix before going on vacations?
– Seen on #Linux

I’d love to stay in the standard lib. Could you give me a link to
Marshal? I haven’t been able to find it.

···

On Sat, Feb 22, 2003 at 06:52:21AM +0900, Mauricio Fernández wrote:

Save addressbook

File.open(“file.yaml”, “w”).puts address_book.yaml
.to_yaml

Open addressbook

address_book = YAML::load( File.open(“file.yaml”) )

Marshal does the job if you want to stay in the standard lib.


Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

Daniel Carrera wrote:

I’d love to stay in the standard lib. Could you give me a link to
Marshal? I haven’t been able to find it.

It’s built in. The following should run as is:

irb(main):001:0> Marshal.load(Marshal.dump([1, “2”, :three]))
[1, “2”, :three]

Yaml should be in the standard lib, IMHO. It gives you the same
functionality, but the dumped data is quite human readable and editable.

If the Yaml module can gain some maturity, I’d like to make a run for
submitting a Yaml module for the 1.8 list. I don’t know what Matz’
thoughts on this are, but I believe the extension list is rather open
to additions for 1.8. I’ve finished designing a streamlined version in C,
based on ideas from Marshal.

I see Ruby’s API for C as being ideal for serialization. When loading
an element from YAML, I merely need to recast the structure into a Ruby
object. This should be incredibly efficient.

And I am fortunate that Racc and Yacc are so similiar. Porting the
tokenizer is the bigger struggle. And putting behind recent health
problems.

Anyways, thanks for suggesting Yaml to new users. Yaml hasn’t enjoyed
nearly the embrace in other communities.

_why

···

Joel VanderWerf (vjoel@PATH.Berkeley.EDU) wrote:

Yaml should be in the standard lib, IMHO. It gives you the same
functionality, but the dumped data is quite human readable and editable.

why,

Bummer about your health, hope you are doing better.

As a key user of YAML (in FreeRIDE) I just want to thank you for this
module…its quite awesome.

To have something that works from a single file (yaml.rb) instead of
lots-o-files (xml parsing, etc) is really quite great when it comes to
deploying applications. I highly recommend YAML to all that need to
store configuration data (or data exchange…which should get more
press!!!).

-rich

···

On Saturday, February 22, 2003, at 02:54 PM, why the lucky stiff wrote:

Joel VanderWerf (vjoel@PATH.Berkeley.EDU) wrote:

Yaml should be in the standard lib, IMHO. It gives you the same
functionality, but the dumped data is quite human readable and
editable.

If the Yaml module can gain some maturity, I’d like to make a run for
submitting a Yaml module for the 1.8 list. I don’t know what Matz’
thoughts on this are, but I believe the extension list is rather open
to additions for 1.8. I’ve finished designing a streamlined version
in C,
based on ideas from Marshal.

I see Ruby’s API for C as being ideal for serialization. When loading
an element from YAML, I merely need to recast the structure into a Ruby
object. This should be incredibly efficient.

And I am fortunate that Racc and Yacc are so similiar. Porting the
tokenizer is the bigger struggle. And putting behind recent health
problems.

Anyways, thanks for suggesting Yaml to new users. Yaml hasn’t enjoyed
nearly the embrace in other communities.

_why

“why the lucky stiff” ruby-talk@whytheluckystiff.net wrote in message
news:20030222200639.GA92649@rysa.inetz.com

Anyways, thanks for suggesting Yaml to new users. Yaml hasn’t enjoyed
nearly the embrace in other communities.

Obviously, peoply seeking simplicity and power would be found here :slight_smile:

BTW: what tool(s) did you use to produce the Yaml documentation?

Mikkel

Hi,

···

In message “YAML in std lib (was Re: [ANN] xml-configfile 0.8.0)” on 03/02/23, why the lucky stiff ruby-talk@whytheluckystiff.net writes:

If the Yaml module can gain some maturity, I’d like to make a run for
submitting a Yaml module for the 1.8 list. I don’t know what Matz’
thoughts on this are, but I believe the extension list is rather open
to additions for 1.8. I’ve finished designing a streamlined version in C,
based on ideas from Marshal.

We are open. When you feel you’re prepared, feel free to tell us. We
will grant you CVS account.

Anyway, don’t work too hard. Get well soon.

						matz.

Yaml :slight_smile: Take a look at doc/yamlrb.yod: it is a “Yaml document”, to be
processed by Yod (Yaml Ok Documentation). See src/yod.rb:

$Id: yod.rb,v 1.22 2003/01/03 07:40:00 whythluckystiff Exp $

···

On Sun, Feb 23, 2003 at 08:06:16AM +0900, MikkelFJ wrote:

“why the lucky stiff” ruby-talk@whytheluckystiff.net wrote in message
news:20030222200639.GA92649@rysa.inetz.com

Anyways, thanks for suggesting Yaml to new users. Yaml hasn’t enjoyed
nearly the embrace in other communities.

Obviously, peoply seeking simplicity and power would be found here :slight_smile:

BTW: what tool(s) did you use to produce the Yaml documentation?

YOD: Yaml Ok Documentation

require ‘yaml’

Hi. Yod is… well… something. Okay, look.

It’s a personal project for building documentation.

It’s also meant to be an example project. To give

a more complete example of YAML’s use.


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

The documentation is in Japanese. Good luck.
– Rich $alz