sms_my_bus 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sms_my_bus.rb +12 -1
- data/lib/sms_my_bus/locations.rb +4 -2
- data/lib/sms_my_bus/routes.rb +3 -2
- data/lib/sms_my_bus/schedules.rb +4 -2
- data/lib/sms_my_bus/version.rb +1 -1
- data/spec/sms_my_bus_spec.rb +16 -2
- metadata +24 -9
data/lib/sms_my_bus.rb
CHANGED
@@ -6,9 +6,10 @@ require 'sms_my_bus/routes'
|
|
6
6
|
|
7
7
|
require 'curb'
|
8
8
|
require 'json'
|
9
|
-
|
9
|
+
require 'uri'
|
10
10
|
|
11
11
|
module SmsMyBus
|
12
|
+
BASE_API_URI = 'http://api.smsmybus.com/v1/'
|
12
13
|
|
13
14
|
def self.key= key
|
14
15
|
@key = key
|
@@ -19,4 +20,14 @@ module SmsMyBus
|
|
19
20
|
@key
|
20
21
|
end
|
21
22
|
|
23
|
+
def self.make_api_request api_method, opts = {}
|
24
|
+
response = Curl::Easy.http_get(SmsMyBus.request_uri(api_method, opts))
|
25
|
+
JSON.parse(response.body_str)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.request_uri api_method, opts = {}
|
29
|
+
opts['key'] = SmsMyBus.key
|
30
|
+
|
31
|
+
"#{BASE_API_URI}#{api_method}?#{URI.encode_www_form(opts)}"
|
32
|
+
end
|
22
33
|
end
|
data/lib/sms_my_bus/locations.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
module SmsMyBus
|
2
2
|
class Locations
|
3
3
|
def self.get_stops route_id
|
4
|
-
|
5
|
-
|
4
|
+
api_method = 'getstops'
|
5
|
+
args = { 'routeID' => route_id }
|
6
|
+
|
7
|
+
SmsMyBus.make_api_request(api_method, args)
|
6
8
|
end
|
7
9
|
end
|
8
10
|
end
|
data/lib/sms_my_bus/routes.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
module SmsMyBus
|
2
2
|
class Routes
|
3
3
|
def self.get_routes
|
4
|
-
|
5
|
-
|
4
|
+
api_method = 'getroutes'
|
5
|
+
|
6
|
+
SmsMyBus.make_api_request api_method
|
6
7
|
end
|
7
8
|
end
|
8
9
|
end
|
data/lib/sms_my_bus/schedules.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
module SmsMyBus
|
2
2
|
class Schedules
|
3
3
|
def self.get_arrivals stop_id
|
4
|
-
|
5
|
-
|
4
|
+
api_method = 'getarrivals'
|
5
|
+
args = { 'stopID' => stop_id }
|
6
|
+
|
7
|
+
SmsMyBus.make_api_request(api_method, args)
|
6
8
|
end
|
7
9
|
end
|
8
10
|
end
|
data/lib/sms_my_bus/version.rb
CHANGED
data/spec/sms_my_bus_spec.rb
CHANGED
@@ -12,6 +12,22 @@ describe 'SmsMyBus' do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
describe 'request_uri' do
|
16
|
+
context 'with opts' do
|
17
|
+
let(:expected_uri) { 'http://api.smsmybus.com/v1/getroutes?foo=bar&key=foobazzlew' }
|
18
|
+
it 'generates the correct URI' do
|
19
|
+
SmsMyBus.request_uri('getroutes', {:foo => 'bar'}).should == expected_uri
|
20
|
+
end
|
21
|
+
end
|
22
|
+
context 'with no opts' do
|
23
|
+
let(:expected_uri) { 'http://api.smsmybus.com/v1/getroutes?key=foobazzlew' }
|
24
|
+
|
25
|
+
it 'generates the correct URI' do
|
26
|
+
SmsMyBus.request_uri('getroutes').should == expected_uri
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
15
31
|
describe SmsMyBus::Schedules do
|
16
32
|
before do
|
17
33
|
SmsMyBus.key = ENV['SMSMYBUS_KEY']
|
@@ -53,6 +69,4 @@ describe 'SmsMyBus' do
|
|
53
69
|
end
|
54
70
|
end
|
55
71
|
end
|
56
|
-
|
57
|
-
describe 'Notifications'
|
58
72
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sms_my_bus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-01-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: curb
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,15 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
26
31
|
- !ruby/object:Gem::Dependency
|
27
32
|
name: rspec
|
28
|
-
requirement:
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
29
34
|
none: false
|
30
35
|
requirements:
|
31
36
|
- - ! '>='
|
@@ -33,10 +38,15 @@ dependencies:
|
|
33
38
|
version: '0'
|
34
39
|
type: :development
|
35
40
|
prerelease: false
|
36
|
-
version_requirements:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
37
47
|
- !ruby/object:Gem::Dependency
|
38
48
|
name: pry
|
39
|
-
requirement:
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
40
50
|
none: false
|
41
51
|
requirements:
|
42
52
|
- - ! '>='
|
@@ -44,7 +54,12 @@ dependencies:
|
|
44
54
|
version: '0'
|
45
55
|
type: :development
|
46
56
|
prerelease: false
|
47
|
-
version_requirements:
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
48
63
|
description: A gem to talk to the awesome SMSMyBus API in Madison, WI.
|
49
64
|
email:
|
50
65
|
- matt.gauger@gmail.com
|
@@ -86,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
101
|
version: '0'
|
87
102
|
requirements: []
|
88
103
|
rubyforge_project:
|
89
|
-
rubygems_version: 1.8.
|
104
|
+
rubygems_version: 1.8.24
|
90
105
|
signing_key:
|
91
106
|
specification_version: 3
|
92
107
|
summary: SMSMyBus API integration
|