mbta-realtime 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29aaee51c15a02a333d3f24999aef9fd3e0f5c11
4
- data.tar.gz: 19bdcf40faaf2657f69e3d7d156a74900d32bcdd
3
+ metadata.gz: 78f301f46119304ba56b1e352c5b61fadf757cc5
4
+ data.tar.gz: ce6f58d60ec90ca97c9d564d68a5e4b579dcd7ea
5
5
  SHA512:
6
- metadata.gz: 45787814440363d1184b390a798c4041dc3abcf7048414f0a7df7eeecb20f63980767f1953fd8d908267387dfcfa866c9d70848b914b59a1d5f5e68579f3a19e
7
- data.tar.gz: 50384639814e3e14caa9dba41f870dfbe36abab49e94eab9ad22422be3f16725bc66e976a3a994f8935e2fa8c8c03f150cdcaeb27d52bc215c6d302f45d09fb8
6
+ metadata.gz: a79ab34899f40b3e6c1afff5590f512dc34073d18067e211af0726fde995b5ebe7e5600932c8005a6bf05972130d48e6ed2552e3b20424692aaac95f97b1dd11
7
+ data.tar.gz: f1156251041dc57adcc61283cc2524f92045612aa4ccce2a62d31ae39bd6d0ba508b8eb06d8019e7f1a63c749ebb5e9d67302ccae35e3c220d37c8d17fea30df
@@ -0,0 +1 @@
1
+ mbta-realtime
data/Gemfile CHANGED
@@ -9,6 +9,9 @@ source "http://rubygems.org"
9
9
  gem "rest-client", ">= 0"
10
10
  gem "httparty", ">= 0"
11
11
 
12
+ gem "geocoder", ">= 0"
13
+
14
+
12
15
  group :development do
13
16
  gem "shoulda", ">= 0"
14
17
  gem "rdoc", "~> 3.12"
@@ -15,6 +15,7 @@ GEM
15
15
  docile (1.1.5)
16
16
  faraday (0.9.0)
17
17
  multipart-post (>= 1.2, < 3)
18
+ geocoder (1.2.3)
18
19
  git (1.2.8)
19
20
  github_api (0.12.0)
20
21
  addressable (~> 2.3)
@@ -95,6 +96,7 @@ PLATFORMS
95
96
 
96
97
  DEPENDENCIES
97
98
  bundler (~> 1.0)
99
+ geocoder
98
100
  httparty
99
101
  jeweler (~> 2.0.1)
100
102
  rdoc (~> 3.12)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -1,3 +1,5 @@
1
+ require 'geocoder'
2
+
1
3
  module MBTARealtime
2
4
  class Client
3
5
  include HTTParty
@@ -15,6 +17,9 @@ module MBTARealtime
15
17
  end
16
18
 
17
19
 
20
+ # Routes
21
+
22
+
18
23
  def routes
19
24
  self.class.get("/routes", @options).to_h
20
25
  end
@@ -25,18 +30,43 @@ module MBTARealtime
25
30
  end
26
31
 
27
32
 
33
+ # Stops
34
+
35
+
28
36
  def stops_by_route(route_id)
29
- raise NotImplementedError
37
+ self.class.get("/stopsbyroute", url_opts({route: route_id})).to_h
30
38
  end
31
39
 
32
40
 
33
- def stops_by_location(location)
34
- raise NotImplementedError
41
+ def stops_by_location(location={})
42
+ # Requires a hash {lat: 42.35291,lon: -71.064648}
43
+ self.class.get("/stopsbylocation", url_opts( location )).to_h
44
+ end
45
+
46
+
47
+ def nearest_stop(location={})
48
+ stops_by_location(location)["stop"].first
49
+ end
50
+
51
+
52
+ def nearest_stop_id(location={})
53
+ nearest_stop(location)["stop_id"]
35
54
  end
36
55
 
37
56
 
38
57
  def stops_by_location_name(intersection)
39
- raise NotImplementedError
58
+ lat, lng = Geocoder.coordinates(intersection)
59
+ stops_by_location(lat: lat, lon: lng)
60
+ end
61
+
62
+
63
+ def nearest_stop_by_location_name(intersection)
64
+ stops_by_location_name(intersection)["stop"].first
65
+ end
66
+
67
+
68
+ def nearest_stop_id_by_location_name(intersection)
69
+ nearest_stop_by_location_name(intersection)["stop_id"]
40
70
  end
41
71
 
42
72
 
@@ -70,9 +100,6 @@ module MBTARealtime
70
100
  end
71
101
  end
72
102
 
73
-
74
- # private
75
-
76
103
  # def assert_api_key
77
104
  # unless @api_key
78
105
  # raise ArgumentError, %Q{ You must pass an API key, i.e.:
@@ -0,0 +1,6 @@
1
+ module MBTA
2
+ class Client
3
+
4
+
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module MBTARealtime
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: mbta-realtime 0.1.0 ruby lib
5
+ # stub: mbta-realtime 0.1.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "mbta-realtime"
9
- s.version = "0.1.0"
9
+ s.version = "0.1.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  ]
21
21
  s.files = [
22
22
  ".document",
23
+ ".ruby-gemset",
23
24
  "Gemfile",
24
25
  "Gemfile.lock",
25
26
  "LICENSE.txt",
@@ -28,6 +29,7 @@ Gem::Specification.new do |s|
28
29
  "VERSION",
29
30
  "lib/mbta-realtime.rb",
30
31
  "lib/mbta-realtime/client.rb",
32
+ "lib/mbta-realtime/client/routes.rb",
31
33
  "lib/mbta-realtime/version.rb",
32
34
  "mbta-realtime.gemspec",
33
35
  "spec/mbta-realtime_spec.rb",
@@ -44,6 +46,7 @@ Gem::Specification.new do |s|
44
46
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
47
  s.add_runtime_dependency(%q<rest-client>, [">= 0"])
46
48
  s.add_runtime_dependency(%q<httparty>, [">= 0"])
49
+ s.add_runtime_dependency(%q<geocoder>, [">= 0"])
47
50
  s.add_development_dependency(%q<shoulda>, [">= 0"])
48
51
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
49
52
  s.add_development_dependency(%q<bundler>, ["~> 1.0"])
@@ -53,6 +56,7 @@ Gem::Specification.new do |s|
53
56
  else
54
57
  s.add_dependency(%q<rest-client>, [">= 0"])
55
58
  s.add_dependency(%q<httparty>, [">= 0"])
59
+ s.add_dependency(%q<geocoder>, [">= 0"])
56
60
  s.add_dependency(%q<shoulda>, [">= 0"])
57
61
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
58
62
  s.add_dependency(%q<bundler>, ["~> 1.0"])
@@ -63,6 +67,7 @@ Gem::Specification.new do |s|
63
67
  else
64
68
  s.add_dependency(%q<rest-client>, [">= 0"])
65
69
  s.add_dependency(%q<httparty>, [">= 0"])
70
+ s.add_dependency(%q<geocoder>, [">= 0"])
66
71
  s.add_dependency(%q<shoulda>, [">= 0"])
67
72
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
68
73
  s.add_dependency(%q<bundler>, ["~> 1.0"])
@@ -1,5 +1,11 @@
1
1
  require 'mbta-realtime'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.expect_with :rspec do |c|
5
+ c.syntax = :should
6
+ end
7
+ end
8
+
3
9
  # require 'simplecov'
4
10
 
5
11
  # module SimpleCov::Configuration
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mbta-realtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Cloyd
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: geocoder
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: shoulda
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -134,6 +148,7 @@ extra_rdoc_files:
134
148
  - README.md
135
149
  files:
136
150
  - ".document"
151
+ - ".ruby-gemset"
137
152
  - Gemfile
138
153
  - Gemfile.lock
139
154
  - LICENSE.txt
@@ -142,6 +157,7 @@ files:
142
157
  - VERSION
143
158
  - lib/mbta-realtime.rb
144
159
  - lib/mbta-realtime/client.rb
160
+ - lib/mbta-realtime/client/routes.rb
145
161
  - lib/mbta-realtime/version.rb
146
162
  - mbta-realtime.gemspec
147
163
  - spec/mbta-realtime_spec.rb