EmtApi

Gem Version Build Status Coverage Status

EmtApi is a Ruby wrapper around the Madrid EMT API which provides an easier and more ruby-like access to the information related to Madrid city urban buses.

Installation

Add this line to your application's Gemfile:

gem 'emt_api'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install emt_api

The EMT API requires you to have a idClient and passKey (called EMT_CLIENT and EMT_SECRET respectively from now on) to authenticate your requests. You can get these freely by filling this form.

emt_api expects them to be accessible as environment variables. To do this on Mac OS X you'll have to edit your .bash_profile and add the following lines:

# ~/.bash_profile
export EMT_CLIENT="your idClient"
export EMT_SECRET="your passKey"

Usage

Get basic info about bus lines

require 'emt_api'

line = EmtApi::Line.find(1)

line.id           # => "001"
line.label        # => "1"
line.date_first   # => #<Date: 2017-01-09 ((2457763j,0s,0n),+0s,2299161j)>
line.date_end     # => #<Date: 2999-12-31 ((2816787j,0s,0n),+0s,2299161j)>
line.origin       # => "Cristo Rey"
line.destination  # => "Prosperidad"

all_lines = EmtApi::Line.all

all_lines.size      # => 208

all_lines.first.id  # => "001"
# etc.

Get basic info about bus stops

require 'emt_api'

stop = EmtApi::Stop.find(1)

stop.id         # => 1
stop.name       # => "Av. Valdemarin - Altair"
stop.lines      # => ["", "161/1/1"]
stop.wifi?      # => false
stop.latitude   # => 40.47004454502
stop.longitude  # => -3.782887713069

all_stops = EmtApi::Stop.all

all_stops.size      # => 4677

all_stops.first.id  # => 1
# etc.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/amiedes/emt_api.

License

Powered by EMT Madrid - Terms & Conditions

The gem is available as open source under the terms of the MIT License.