GithubHelp home page GithubHelp logo

mbta_take_home's Introduction

Project

This is a project to satisfy a take-home assignment to interface with the MBTA API.

Preface

Reading the git history of this project should tell a good story of how it was built.

Reading the history through GitHub may be easiest, or if you have tig installed, I find that makes it very easy to read git history from a terminal emulator interface.

I will note that I normally would not include the tests in a second pass, but it was the way this project fell out as I explored the requirements. Normally I would fold the tests back in to be introduced as the functionality is introduced, but given the time constraint I decided just to add them after the implementation.

Outline

Design Documentation

'assets/MBTA Routes_Stops Design Document.pdf'

This outlines the general approach and notes decisions made and why.

Code

src/mbtacmd/main.go

This is the code itself.

Tests

src/mbtacmd/main_test.go

This has unit tests for most of the logic in the code itself. It does not have integration tests with the API server, nor does it have tests for the output to standard out.

Pre-built binaries

bin/mbtacmd-linux bin/mbtacmd-macos bin/mbtacmd-windows.exe

These are conveniently built binaries to run without bothering with the installation of the go compiler and toolchain.

Summary

 tree
.
├── assets
│   └── MBTA Routes_Stops Design Document.pdf
├── bin
│   ├── mbtacmd-linux
│   ├── mbtacmd-macos
│   └── mbtacmd-windows.exe
└── src
    └── mbtacmd
        ├── main.go
        └── main_test.go

4 directories, 6 files

This is just a summary of the file structure we just outlined.

Installation

You will need the go compiler and internet access to build and test this.

The go compiler and toolchain can be found at: https://golang.org/doc/install

Or through installation of your favorite package manager:

sudo pacman -S go

brew install go

sudo dnf install go

Running

You should be able to run the pre-built binaries in the bin/ directory after cloning this project.

./bin/mbtacmd-linux

Testing

You should be able to test this project by running the following:

GOPATH=`pwd` go test -v mbtacmd

Building

You should be able to build this yourself by running the following:

go run src/mbtacmd/main.go

And it will prompt you to input two separate stops, which you can do. Note that it is doing exact name comparisons, so match case and know the stop name exactly.

You may find it more convenient to run the following:

echo "Alewife
Arlington" | go run src/mbtacmd/main.go

Example Output

 echo "Alewife
Arlington" | go run src/mbtacmd/main.go
The Heavy Rail and Light Rail Routes are:
Red Line
Mattapan Trolley
Orange Line
Green Line B
Green Line C
Green Line D
Green Line E
Blue Line

Route with the minimum number of stops:
Mattapan Trolley (with 8 stops)
Route with the maximum number of stops:
Green Line B (with 24 stops)

The following stops connect multiple routes:
Stop North Station connects routes: Orange Line, Green Line C, Green Line E
Stop State connects routes: Orange Line, Blue Line
Stop Hynes Convention Center connects routes: Green Line B, Green Line C, Green Line D
Stop Government Center connects routes: Green Line C, Green Line D, Green Line E, Blue Line
Stop Downtown Crossing connects routes: Red Line, Orange Line
Stop Ashmont connects routes: Red Line, Mattapan Trolley
Stop Park Street connects routes: Red Line, Green Line B, Green Line C, Green Line D, Green Line E
Stop Boylston connects routes: Green Line B, Green Line C, Green Line D, Green Line E
Stop Kenmore connects routes: Green Line B, Green Line C, Green Line D
Stop Haymarket connects routes: Orange Line, Green Line C, Green Line E
Stop Copley connects routes: Green Line B, Green Line C, Green Line D, Green Line E
Stop Arlington connects routes: Green Line B, Green Line C, Green Line D, Green Line E

Enter Starting Stop
Enter Ending Stop
Take the following routes to get from Alewife to Arlington:
Red Line
Green Line B

mbta_take_home's People

Contributors

quintenpalmer avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.