This post originated from an RSS feed registered with Ruby Buzz
by Rod Waldhoff.
Original Post: Ruby Userland
Feed Title: Rodney Waldhoff: Ruby
Feed URL: http://radio-weblogs.com/0122027/categories/ruby/rss.xml
Feed Description: posts about the programming language Ruby
Over the past couple of evenings I've hacked out xmlStorageSystem.rb, a reasonably functional Ruby-based client to the XmlStorageSystem system protocol. It works like this:
Actually, my local copy of xmlStorageSystem.rb has these value specified as the defaults, so I just user XmlStorageSystem.new, and I'll use that form in the rest of these examples. The constructor also accepts an number of arguments that should allow one to connect to the Python Community Server and others, although Radio is the only server I've tried.
To get a listing of the files currently stored on the server, use:
Which will compare the list of files in the local directory with those on the server, delete the ones that don't appear locally, and load/update the rest.
Since this is Ruby, it's easy to set up little shell scripts that invoke those commands in ways useful to your personal work style.
If one wanted to be clever, there is metadata available via XmlStorageSystem.getMyDirectory that would allow one to determine whether or not a file has changed since it was last uploaded, but I haven't gotten around to that yet.
I'm still pretty much a Ruby neophyte, so there's probably substantial room for improvement there. In particular, (1) there's no error handling present just yet and (2) the current implementation supports hackablity (changing the script itself) more than extensibility. Nevertheless, it's neat that a Ruby neophyte can write a basic XmlStorageSystem client in 150 lines of readable code.