Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit and also minimum viable product lol

  • Loading branch information...
commit 5bbaa383d0245fa603b43416e94c4fb0526e9ffc 0 parents
@chendo authored
Showing with 118 additions and 0 deletions.
  1. +4 −0 Gemfile
  2. +84 −0 Gemfile.lock
  3. +30 −0 web.rb
4 Gemfile
@@ -0,0 +1,4 @@
+gem 'sinatra'
+gem 'sinatra-contrib'
+gem 'metlinkr', :git => 'https://github.com/chendo/metlinkr.git'
+gem 'json'
84 Gemfile.lock
@@ -0,0 +1,84 @@
+GIT
+ remote: https://github.com/chendo/metlinkr.git
+ revision: 10cebea36df2e9195f3a2ec31584e544a412c1cc
+ specs:
+ metlinkr (0.0.5)
+ capybara-mechanize
+ nokogiri
+
+GEM
+ specs:
+ addressable (2.2.7)
+ backports (2.5.1)
+ capybara (1.1.2)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (~> 2.0)
+ xpath (~> 0.1.4)
+ capybara-mechanize (0.3.0)
+ capybara (~> 1.1)
+ mechanize (~> 2.3)
+ childprocess (0.3.1)
+ ffi (~> 1.0.6)
+ domain_name (0.5.3)
+ unf (~> 0.0.3)
+ eventmachine (0.12.10)
+ ffi (1.0.11)
+ json (1.4.6)
+ libwebsocket (0.1.3)
+ addressable
+ mechanize (2.3)
+ domain_name (~> 0.5, >= 0.5.1)
+ mime-types (~> 1.17, >= 1.17.2)
+ net-http-digest_auth (~> 1.1, >= 1.1.1)
+ net-http-persistent (~> 2.5, >= 2.5.2)
+ nokogiri (~> 1.4)
+ ntlm-http (~> 0.1, >= 0.1.1)
+ webrobots (~> 0.0, >= 0.0.9)
+ mime-types (1.18)
+ multi_json (1.2.0)
+ net-http-digest_auth (1.2)
+ net-http-persistent (2.6)
+ nokogiri (1.5.2)
+ ntlm-http (0.1.1)
+ rack (1.4.1)
+ rack-protection (1.2.0)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rubyzip (0.9.7)
+ selenium-webdriver (2.21.0)
+ childprocess (>= 0.2.5)
+ ffi (~> 1.0)
+ libwebsocket (~> 0.1.3)
+ multi_json (~> 1.0)
+ rubyzip
+ sinatra (1.3.0)
+ rack (~> 1.3)
+ rack-protection (~> 1.1)
+ tilt (~> 1.3)
+ sinatra-contrib (1.3.1)
+ backports (>= 2.0)
+ eventmachine
+ rack-protection
+ rack-test
+ sinatra (~> 1.3.0)
+ tilt (~> 1.3)
+ tilt (1.3.3)
+ unf (0.0.5)
+ unf_ext
+ unf_ext (0.0.4)
+ webrobots (0.0.13)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ json
+ metlinkr!
+ sinatra
+ sinatra-contrib
30 web.rb
@@ -0,0 +1,30 @@
+require 'json'
+require 'sinatra'
+require 'sinatra/json'
+require 'metlinkr'
+
+set :json_encoder, JSON
+
+get '/route' do
+ options = {:limit => 3, :methods => :all}
+ options[:methods] = params['methods'].to_sym if params['methods']
+ journey = Metlinkr.plan(params[:from], params[:to], options)
+ ret = {}
+ ret['trips'] = journey.trips.map do |trip|
+ {
+ 'steps' => trip.steps.map do |step|
+ {
+ 'origin' => step.origin,
+ 'departure_time' => step.departure_time,
+ 'duration' => step.duration,
+ 'route' => step.route,
+ 'arrival_time' => step.arrival_time,
+ 'destination' => step.destination,
+ 'method' => step.method,
+ }
+ end
+ }
+ end
+
+ json ret
+end
Please sign in to comment.
Something went wrong with that request. Please try again.