Some Twittering With Ruby And Shoes

Now that I’ve become more or less hooked on Twitter, I’ve found that using a client, rather than the actual website, generally works a bit better for me. I’ve tried several; Twitterific is cool, but after I tried Snitter I found I couldn’t go back to using Twitterific, I missed Snitter’s extra features.

However, I started having trouble with Snitter crashing or seeming to become very slow; this may just be Adobe AIR, not Snitter, but either way, it got annoying enough that I quit using it. Now I normally use the web interface.

Since I started getting into Shoes, the project that keeps crossing my mind is building a Twitter client with Shoes. Shoes programs are basically Ruby programs, so it seems very doable. Now, such a client will not receive widespread use; shoes apps still need to be started from the command line, with the command `shoes yourapp.rb`. One option would be to create a shell script or batch file which contained this line, but this would still require shoes to be in the path (not guaranteed).

I’m willing to solve that problem later, and for now people would just need to take a few baby steps with Shoes (oh, how this project lends itself to puns) in order to run the twitter-shoes client.

Assuming I finish it. I’ll keep you posted.

In the meanwhile, I did find a few other problems and solve at least one:

  • I started developing on my laptop, which is an Ubuntu machine. There, I decided to try one of the Twitter API libraries that already exists (why reinvent the wheel? No thanks), one twitter4r. However, ran into errors when trying to run `gem install twitter4r`, an error that looked something like

    extconf.rb:8:in `require’: no such file to load — mkmf (LoadError)
    from extconf.rb:8
    ERROR: While executing gem … (RuntimeError)
    ERROR: Failed to build gem native extension.

    A search led me to one Al Hoang, who discovered that upgrading to ruby1.8-dev would resolve this — apparently mkmf.rb is not present otherwise, as strange as this seems (to me). So, an `apt-get install ruby1.8-dev` later, my gem issues were resolved.

  • Before trying Twitter4r, I did try just using Ruby’s own Net::HTTP and the Twitter API. Doing this, I kept getting the error “Can’t make more than 70 requests per hour”, which is meant to restrict API usage, but which (as far as I can tell) shouldn’t have been happening. Garrick Van Buren suggested not using my main account, which I intend to test — but since I want to create a client, eventually I’ll need to find a way to make this work with my primary account. Possibly Twitter4r will be a good solution, although that does create Yet Another Dependency for the client.
  • So far, that’s it. Haven’t tried plugging this into Shoes, yet, first I’ve been playing with the Twitter API in irb just to make sure I’ve got that part down.

So, if you’re interested in Twitter clients and/or Shoes, stay tuned, I suppose.

Also, if you’re using Shoes — you can create an edit_line that will mask a password: use @password = edit_line :secret => true.

Tags: , , ,

8 Responses to “Some Twittering With Ruby And Shoes”


  1. 1 _why

    Oh, hey, this is a great idea! I just got some threading bugs killed yesterday, so you should be okay polling Twitter in the background.

    One other thing that comes to mind is that RubyGems isn’t plugged into Shoes yet. I’ll get started on that right away. In the meantime, you’ll probably want to just unpack the gem and copy the contents of its lib/ folder into the lib/ folder in your Shoes app.

    Say, are you on the Shoes list?

  2. 2 Garrick Van Buren

    In development, I wasn’t able to use my primary account, but once I pushed to production, it was fine.

  3. 3 SP

    Hi.

    Technically the RubyGem install error is really due to Twitter4R’s dependency on the json RubyGem, which is a native extension. This would make sense since mkmf is used to help build Ruby extensions. Just more of a FYI than anything.

    Also to keep you in the loop on Twitter4R there will be a 0.3.1 patch release to fix #to_xml on each of the “models” (i.e. Status, Message, User, etc.) coming up in the next week.

    Let me know if you notice any other issues with Twitter4R and I will be happy to fix them.

    Thanks,
    SP

  4. 4 Phil Crissman

    @_why Yep, I am on the Shoes list. I almost asked the question about the password edit_line to the list(I assumed it wouldn’t be online), but I decided to search anyways, and lo and behold! Found it online.

    @Garrick, good to know — thanks!

  5. 5 Phil Crissman

    @SP… you’re exactly right, it was a dependency issue, not a twitter4r issue. I had the same error with different gem, different dependency… I’m assuming that’s fixed now, too.

    Thanks! This will be very much a side project, and probably some industrious person with more time on their hands will beat me to it, b/c it may take me awhile to finish, but… oh well. It’s fun.

  6. 6 Peter Cooper

    Regarding the packaging / distribution idea, I was about to say.. Platypus will probably solve that problem! But.. that’s only on OS X :)

  7. 7 Phil Crissman

    Platypus looks cool, but I think cross-platform is going to be the holy grail.

    That said, thanks for the link to Platypus; I hadn’t seen it before, and it certainly looks like its worth checking out.

  8. 8 Phil

    You may want to try just the plain “twitter” gem (without “4r”). I believe that’s has simpler dependencies as it doesn’t require anything to be compiled.

Comments are currently closed.