The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Ruby Userland

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Rod Waldhoff

Posts: 99
Nickname: rwald
Registered: Jun, 2003

Rod Waldhoff is.
Ruby Userland Posted: Nov 21, 2003 11:41 AM
Reply to this message Reply

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
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Rod Waldhoff
Latest Posts From Rodney Waldhoff: Ruby

Advertisement

As I previously mentioned, I've been toying with custom clients to the XmlStorageSystem XML-RPC protocol used by Radio Userland and several open source blog servers, with the ultimate goal of hosting a custom blog on the radio.weblogs.com host.

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:

To create a new instance of the client, use:

XmlStorageSystem.new(<usernumber>,<md5-hash-of-password>,<root-directory>)

For instance, I use:

XmlStorageSystem.new('122027','8c8034f5c9d68564e155c67a6d4e4612','/0122027/')

although that's not my actual password.

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:

XmlStorageSystem.new.getMyDirectory

To download all those files to a local directory

XmlStorageSystem.new.backupMyDirectory 'backupdir'

To upload a file (or files) to the server, use:

XmlStorageSystem.new.saveMultipleFiles( 'local-base-dir', [ 'file1', 'file2', 'etc' ])

To delete a file (or files) from the server, use:

XmlStorageSystem.new.deleteMultipleFiles( [ 'file1', 'file2', 'etc' ])

Finally, the really handy one:

XmlStorageSystem.new.updateFromLocalDirectory 'localdir'

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.

Read: Ruby Userland

Topic: Unlimited Undo Previous Topic   Next Topic Topic: Using Ruby: An Introduction to Ruby for Java Programmers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use