Upcoming.org Ruby Library

This library provides an interface to upcoming.org for the Ruby programming language. It was created by Derek Greentree. Before messing around with it, you might want to look at the API docs and get yourself an API key so that you can access the database from whatever crazy thing you cook up.

Download it: upcoming_ruby-0.3.zip

Here’s a short example of how to use the library (copied from here):

require 'upcoming/upcoming'

# substitute your values here
apiObj = Upcoming::Upcoming.new('api-key', 'auth_token')
# get a list of countries
countryList = apiObj.getCountryList
# find the US
unitedStates = countryList.find { |country| country.name == 'United States' }
# get a list of states
stateList = apiObj.getStateList(unitedStates.id)
# find Colorado
colorado = stateList.find { |state| state.name == 'Colorado' }
# get list of metros
metroList = apiObj.getMetroList(colorado.id)
# iterate through the list and print names
metroList.each { |metro| puts metro.name }

Results:

Boulder
Colorado Springs
Denver
Estes Park

Here’s a changelog:

Changelog:

0.3 (6/4/06):
  * removed username/password auth, replaced with token-based auth
  * added cache mechanism to call.rb
  * added UpcomingCache model for Ruby on Rails
  * added support for geolocation arguments and attributes
  * moved object defs into a new file (datatypes.rb)
Jun 04 2006 03:04 pm | Framing | trackback |

3 Responses

  1. Casey Says:

    Where exactly is the best place to put the unzipped upcoming folder in a Rails app? Inside lib?

  2. Bitbutter Says:

    Casey, yes i think so. Derek Greentree’s site seems to be down at the time of writing.

  3. Derek Says:

    Hi guys,
    The old blog URL you have linked here isn’t valid anymore - if you’re interested it’s now http://blog.leftwise.com/. Anyhow, anything I had listed about this package at my website is now obsolete, and Dan’s version is what you should refer to.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.