A Launchpad Module for Ruby

At some point last year I started to write a Launchpad API client in Ruby, for the very simple reason that Kubuntu CI tooling is almost entirely written in Ruby and I wanted to avoid round tripping into Python to use launchpadlib for trivial things such as querying the version of a package in a PPA. Not only would that be slightly slower it also raises the ever so unfortunate problem of how to exchange data between Ruby and Python.

Perhaps someone else also can find it useful.


It is intentionally minimalistic in it’s design and validation. All JSON return data is parsed into an glorified OpenStruct with special method_missing handling which depending on how you call a non-existent method would either attempt an HTTP GET or HTTP POST on the Launchpad API. Since the underlying data is never actually wrapped into literal classes on the Ruby side it has surprisingly few lines of code.

Unfortunately this also means that there is absolutely no hand holding for anything. For the most part method calls result in exactly the same methods being called on the API endpoint. So, correctly reading and using the API documentation is pretty much a necessity. Otherwise something is most likely going to raise a supremely cryptic exception 😉

Calling a method on an object results in an HTTP GET on the self_link of that object. If the method is suffixed with a ! it will do a HTTP POST instead.

So, if I want to list all my Bazaar branches on Launchpad I’d first create a wrapper object for my user endpoint and then call:


Which as you would expect returns an Array of ‘branch‘ type objects to use. Alternatively, if I wanted to change my account status I’d again use my user endpoint object and would need to do a POST operation on it (according the API):

me.setAccountStatus!(comment: 'Best be off then', status: 'Deactivated')

Notable difference being the exclamation point indicating that we want to POST the method call.

And that is pretty much all there is to know about the entire module.

Finally a short example:

require_relative 'lp'

url = 'https://api.launchpad.net/devel/~kubuntu-ci/+archive/ubuntu/unstable'

ppa = Launchpad::Rubber.from_url(url)
sources = ppa.getPublishedSources(status: 'Published', source_name: 'solid')
sources.each { |s| puts s.display_name }
  1. creates a Rubber object from a PPA url
  2. gets all published solid sources from that PPA
  3. ouputs the display_name of all returned source

Kubuntu Web Shortcuts

In this post I would like to put the spotlight on a very nice Kubuntu feature that will help you a great deal if you regularly work with Ubuntu project services (such as the wiki) or Launchpad.

Kubuntu has this very nice package called kubuntu-konqueror-shortcuts. While I actually would like to have that renamed to something more suitable, I (or rather my minion ;)) did not yet get to rename it. Anyhow…

The shortcuts package was started in 2005 and is a collection of KDE web shortcuts related to Kubuntu and the Ubuntu project. Web shortcuts are one of the most used KDE features on my system. It allows you to enter things like “gg:kubuntu” in your browser’s URL bar to do a Google search on Kubuntu, or “kde:krecentdocuments” to lookup KDE API documentation. The nice thing about this is that it works in both Konqueror and Rekonq, as well as KickOff (the application menu) and KRunner (the thing that appears when you press ALT+F2 – actually it only works here if you have activated the shortcut explicitly in either System Settings or the settings of one of the browsers).  Suffice to say those shortcuts are quite efficient when you keep finding yourself doing searches on different sites multiple times a day.

What I probably like best about it, is that those shortcuts are not necessarily bound to a search box (as has long been the case with some popular browser out there – that said, if you use KRunner or KickOff and have a different browser set it will also work ;)). So you can swiftly do ‘CTRL+T => gg:Harald Sitter => CTRL+T => gg:John Cleese’ to find out that apparently I am not as internet famous as John Cleese. Surprise.

KDE SC already comes with a vast amount of common shortcuts for just about everything one needs, Google, Yahoo, YouTube, various news sites… Back in 2005 Stephan Hermann thought that it also made sense to use this goodness for Ubuntu developers and Launchpad users. The Kubuntu web shortcuts were born.

With an Ubuntu focus you can currently use the following shortcuts:

  • idea:kde
    To search on brainstorm.ubuntu.com for ideas with the keyword kde
  • ubw:HaraldSitter
    To directly access my Ubuntu wiki page
  • ubws:Kubuntu
    To search for Kubuntu pages on the Ubuntu wiki
  • uhelp:BinaryDriverHowto
    To directly access the binary driver howto on help.ubuntu.com
  • uhelps:MP3
    To search for MP3 pages on help.ubuntu.com
  • uman:screen
    To search for manpages named screen on manpages.ubuntu.com (this will only work on Kubuntu 11.04+)
  • upkg:kde-l10n
    To search packags.ubuntu.com
  • kpackagecode:kdelibs
    Goes to the Kubuntu source branch of a KDE core component

With a Launchpad focus we have:

  • ubug:37657
    Go to a bug on Launchpad, or search if the bug is not existing
  • lpbugproject:amarok
    Goes to the product’s bug page
  • usrc:amarok
    Goes to the source package page of Amarok in Ubuntu
  • lpuser:smarter
    Directly go to a user’s page on Launchpad
  • upeople:smarter
    Search for people on  Launchpad
  • lpcve:1245
    Searches for a CVE report on Launchpad
  • lpblueprint:rocks
    Search for a blueprint on Launchpad

So there are plenty of useful things for everyone who works with Launchpad/Ubuntu regularly. I can honestly say, without those shortcuts I would be only half as efficient. In fact, when I am developing I probably only browse using shortcuts.

They are so incredibly amazing – give them a try! 🙂

Stay friendly 🙂