Re.Mark

My Life As A Blog

Archive for June 2008

Made Up Technical Terms #8

leave a comment »

Artchitecture – an architecture that is overly concerned with elegant visual representations.

Advertisements

Written by remark

June 18, 2008 at 10:23 pm

Posted in General

Ruby Tuesday #10 Part 2 : News from the Rubyverse

leave a comment »

 A few Ruby related tidbits have caught my attention over the past few days.  They are:

A social network for Rubyists.

The future of JRuby

Introducing the Ruby Benchmark Suite

IronRuby and ASP .NET MVC

Dynamic Script Control

Written by remark

June 17, 2008 at 10:51 pm

Posted in Ruby

Ruby Tuesday #10 Part 1 : Studying Form

leave a comment »

The next task I had set myself in my Ruby learning journey was to write a GUI for the Twitter client I have created.  A quick squiz around the internet reveals a number of potential frameworks.  In no particular order, here’s some I found:

FXRuby – "a library for developing powerful and sophisticated cross-platform graphical user interfaces."  I was toying with the idea of writing a weak and crude GUI, but this may still be the right choice.

Konundrum – "Very complete bindings to both the KDE API and the Qt APIs."  Very complete is clearly a good thing – none of your bog standard completeness here.  Now, what’s Qt?  It’s a "cross-platform application framework for desktop and embedded development" according to its authors, Trolltech, with "an intuitive API and a rich C++ class library."

Ruby/Tk – there seems to be Ruby bindings for the Tk toolkit. Tk is a "Tcl extension, written in C, designed to give the user a relatively high level interface to his or her windowing environment."  Tcl, in turn, is a "a powerfully simple, open source-licensed programming language."  Hmm.  Does all this sound a little obtuse and slightly recursive to you, too?

Ruby-GNOME2 –  "a set of Ruby language bindings for the GNOME 2.0 development environment."  GNOME "offers an easy to understand desktop for your GNU/Linux or UNIX computer." And lots of CAPITALS.  *nix only is a dealbreaker for me – although the documentation includes mention of Ruby/Gtk2, which uses Gtk+, which runs on Windows.  Could be clearer, but if you’re a fan of the esoteric this could be a good choice.

Shoes – "a very informal graphics and windowing toolkit."  Here’s a helpful poster thingy about it.

Of course, with IronRuby I could also use Silverlight.  I haven’t covered IronRuby yet, so I’ll leave Silverlight for another Ruby Tuesday.  For those of you who can’t wait, I’d suggest a little peek here.

Is all this choice a good thing?  Or does it distract me from building a GUI by leading me to have to find out some more about each framework / toolkit?  As good a concept as choice is, I’m not sure what the choice here really is.  I can choose between a bunch of frameworks that do more or less the same thing.  So unless anyone has a better idea, I’m going to plump for Shoes on the basis that it has the best, albeit extremely silly, name.

Written by remark

June 17, 2008 at 9:54 pm

Made Up Technical Terms #7

leave a comment »

In the first guest spot in the ever-growing series of made up technical terms Marc has contributed the following:

Lambada Function – a function which is intimately bound to the context in which it is called.

Written by remark

June 16, 2008 at 10:24 pm

Posted in General

Made Up Technical Terms #6

leave a comment »

Triple B – Broken beyond belief – refers to a system or process that is irreparable.

Written by remark

June 12, 2008 at 10:42 pm

Posted in General

Made Up Technical Terms #5

leave a comment »

Rebug – to introduce bugs as a result of an edit to code.

Written by remark

June 11, 2008 at 11:21 am

Posted in Development, General

Ruby Tuesday #9 : Interacting with the command line

leave a comment »

Last week I thought some sort of interface to the Twitter client I’ve been building would be a good idea.  The most basic interface is the command line.  So I thought I’d start there.  There’s a library called getoptlong that parses the command line and allows you to specify the options that can be supplied.  Before hooking this into the Twitter client, I thought I’d experiment with the library.  I created a new file for this purpose.  Here’s the code:

require "getoptlong"

FRIENDS = "Friends"
PUBLIC = "Public"
USER = "User"
UPDATE = "Update"
action = PUBLIC
username = password = ""
tweet = ""

parser = GetoptLong.new
parser.set_options(["-f", "--friends_timeline",GetoptLong::NO_ARGUMENT],                    ["-t", "--user_timeline", GetoptLong::NO_ARGUMENT],                    ["-s", "--update_status", GetoptLong::REQUIRED_ARGUMENT],                    ["-u", "--username", GetoptLong::REQUIRED_ARGUMENT],                    ["-p", "--password", GetoptLong::REQUIRED_ARGUMENT]) parser.each do |option, value|   case option     when "-f"       action = FRIENDS     when "-t"       action = USER     when "-s"       action = UPDATE       tweet = value     when "-u"       username = value     when "-p"       password = value   end end puts action puts username puts password puts tweet

So, we set up the GetoptLong object (interesting naming convention) by specifying the options.  Then we loop through the supplied options.  This is fairly naive at present, so if you specify -f and -s, it’ll take the last of the options and set the action to that.  We can call this from the command line to see what the output is (the format for this is ruby Filename.rb options.)  Getting both the option and the value passed into the block is going to seem unusual if your background is C# or Java – but it’s very convenient and fairly obvious.  Worth noting that methods can return more than one value, too (the get method and its alias get_option of the getoptlong library does just that.)  For those who’d like to interact with the command line at a lower level ARGV is your friend – it’s a global constant that represents all the options supplied at the command line in an array-like structure.  Of course, if you use ARGV you’ll need to figure out how to detect what’s an argument and what’s a value.

It’s fairly trivial to modify this code to call the Twitter client.  Add a line at the top to require Twitter and then replace the four puts lines at the bottom of the code with these lines:

client = Client.new 

case action
  when PUBLIC
    puts client.download_public_timeline
  when FRIENDS
    puts client.download_friends_timeline(username, password)
  when USER
    puts client.download_user_timeline(username)
  when UPDATE
    client.update(tweet, username, password)
end

Now I’ve hooked the client up to the command line, a GUI would be an interesting next step.

Written by remark

June 10, 2008 at 7:57 pm

Posted in Ruby