Project

dcmetro

0.0
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Washington, DC Metro Rails information, including lines, stations and arrival/departure predictions.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
~> 0.18
 Project Readme

DCMetro

Gem Version Build Status Coverage Status

Rails class and a command line interface to access the Washington, D.C. Metro Rail API. Returns the systemwide alerts, lines, stations and arrival times for the lines at each station.

Installation

Add this line to your application's Gemfile:

gem 'dcmetro'

And then execute:

$ bundle

Or install it yourself as:

$ gem install dcmetro

An ENV variable must be set either in your shell for the CLI or where ever you keep such variables in your Rails apps.

The variable needs to be set to DCMETRO_KEY

It is recommended that a key is requested from https://developer.wmata.com/

For the CLI, in the .bash_profile set the following: EXPORT DCMETRO_KEY = <<replace with api key from WMATA>>

Don't forget to source .bash_profile after making the changes.

Usage

Rails App

With the gem installed, instantiate a new class in your controller:

class WelcomeController < ApplicationController

  def index
    dc_metro = DCMetro::Information.new
    @alerts = JSON.parse dc_metro.alerts
    @lines = JSON.parse dc_metro.line
    @stations = JSON.parse dc_metro.line "green"
    @college_park = JSON.parse dc_metro.station "college"
    @gallery_place = JSON.parse dc_metro.station "gallery"
    #
    # New in 0.0.3 - kind of a work in prorgress
    @fare_info = JSON.parse dc_metro.station "college", "gallery"
  end

end

For more info, see this sample rails app, and the repo for the sample app.

CLI

$ dcmetro
Commands:
  dcmetro alerts          # Display DC Metro system wide alerts.
  dcmetro help [COMMAND]  # Describe available commands or one specific command
  dcmetro line COLOR      # Display metro rail lines, if COLOR, displays rail stations on the COLOR line
  dcmetro station STARTING,DEST    # Display metro station train arrival and departure times and travel info.

Contributing

  1. Fork it - https://github.com/kencrocken/dcmetro/fork
  2. Create your feature branch git checkout -b my-new-feature
  3. Commit your changes git commit -am 'Add some feature'
  4. Push to the branch git push origin my-new-feature
  5. Create a new Pull Request

Development

$ cd ~/path/to/dcmetro bundle install to get dependencies. bundle exec bin/dcmetro cucumber features to run tests.