Earlier today, Vincent Foley was kind enough to hand over maitenance of the the ShortURL project on RubyForge to me. He first released it back in 2005, which I blogged about as RubyURL was the first shortening service that it supported (and is the default). Unfortunately, the release of RubyURL 2.0 broke backwards compatibility and Vincent wasn’t maintaining it anymore. So, earlier, I decided to patch this and got a new version released that now works with the current RubyURL site.
While working on the code, I decided to extend the compatible services to include moourl and urlTea.
These updates are available in ShortURL version 0.8.4.
Install the ShortURL gem
Installation is a snap… (like 99.7% of rubygems…)
~ > sudo gem install shorturl Password:
Successfully installed shorturl-0.8.4
1 gem installed
Installing ri documentation for shorturl-0.8.4...
Installing RDoc documentation for shorturl-0.8.4.
Using ShortURL
The ShortURL gem provides the ShortURL library, which you can use from any Ruby application.
Using the ShortURL library
~ > irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'shorturl'
=> true
irb(main):003:0> ShortURL.shorten( 'http://www.istwitterdown.com' )
=> "http://rubyurl.com/P9w"
As you can see…it’s really straight forward.
Let’s try it with a few other services.
irb(main):004:0> ShortURL.shorten( 'http://www.istwitterdown.com', :moourl )
=> "http://moourl.com/fvoky"
irb(main):005:0> ShortURL.shorten( 'http://www.istwitterdown.com', :tinyurl )
=> "http://tinyurl.com/2t3qmh"
Using the shorturl command-line tool
Many people don’t know that ShortURL provides a command-line tool, which you can use after installing the gem.
~ > shorturl http://istwitterdown.com
http://rubyurl.com/Lwk
If you’d like to see more services provided than the ones listed here, please submit feature requests and/or patches on the rubyforge project.
ShortURL Documentation
To see the latest documentation for the project, please visit:
My favorite part about this? My rbot plugin for RubyURL works again!
Happy URL-shortening!