duckduckgo/zeroclickinfo-spice — pull request #1056 by elebow (2014-09-01 02:54:58+00:00)
Title: MBTA module

# Spice Pull Request

**What does your instant answer do?**
Shows MBTA Commuter Rail departure times, similar to the existing SEPTA and NJ Transit answers. The biggest difference in functionality is the lack of "now boarding" status or lateness indicators, since the MBTA API doesn't provide that information (as far as I could tell).

Furthermore, the MBTA API doesn't have an endpoint to show trains from X to Y. It can only show trains departing from X, regardless of destination. We could implement an X-to-Y feature ourselves, but that's some fancy logic probably best left to a later PR. Fortunately, it's not that large of an issue, because the MBTA network (like SEPTA) is a star topology, where the important "destinations" are really just *inbound* and *outbound*.

For the moment, this only includes Commuter Rail stations, but the API endpoint I'm using also supports other transport modes operated by the MBTA, including subway and bus. That's an area for possible future expansion.

This PR also establishes the `Transit` namespace for transit-related Spices.

**What problem does your instant answer solve (Why is it better than organic links)?**
It shows upcoming departures at a glance.

**What is the data source for your instant answer? (Provide a link if possible)**
http://realtime.mbta.com/portal

**Why did you choose this data source?**
It's the official source and is very comprehensive.

**Are there any other alternative (better) data sources?**
Highly unlikely.

**What are some example queries that trigger this instant answer?**
`Next train from Braintree`, `MBTA from Providence`

In the future, I would like to support `MBTA train from Worcester to South Station`

**Which communities will this instant answer be especially useful for? (gamers, book lovers, etc)**
People in the Massachusetts Bay area.

**Is this instant answer connected to a DuckDuckHack [instant answer idea](https://duck.co/ideas)?**
No.

**Which existing instant answers will this one supersede/overlap with?**
None known.

**Are you having any problems? Do you need our help with anything?**
I would appreciate some visual design advice. I've attached screenshots of two alternatives, but I'm sure someone else can do even better.

Also, the code in this PR contains a demo API key. A real key will need to be used for production—I left the demo in there so people can run this module easily for review purposes.

![2014-08-31-21 19 39_1440x900](https://cloud.githubusercontent.com/assets/7873686/4104089/9e2bdd16-3180-11e4-9b3b-fb98a3bfe2b9.png)
![2014-08-31-21 21 42_1440x900](https://cloud.githubusercontent.com/assets/7873686/4104092/a4269f30-3180-11e4-8673-208687d0dc56.png)

## Checklist
Please place an 'X' where appropriate.

```
[X] Added metadata and attribution information
[X] Wrote test file and added to t/ directory
[X] Verified that instant answer adheres to design guidelines (https://duck.co/duckduckhack/design_styleguide)
[X] Verified that instant answer adheres to code styleguide (https://duck.co/duckduckhack/code_styleguide)
[X] Tested cross-browser compatibility

Please let us know which browsers/devices you've tested on:
- GNU/Linux
[X] Opera 12.x
[X] Firefox

```