ratis 3.1.4 → 3.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -1
- data/Gemfile.lock +1 -1
- data/lib/ratis/next_bus.rb +28 -18
- data/lib/ratis/version.rb +1 -1
- data/spec/ratis/next_bus_spec.rb +25 -5
- data/spec/support/vcr_cassettes/Point2Point.yml +23 -23
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -13,4 +13,7 @@
|
|
13
13
|
- Turns out that in the NextBus calls the <service> tag can come back as either a single node or list of nodes. In one case savon turns this into an array, in the other case it's just a single entity. Rewrote NextBus.where to handle these two cases, this also means NextBus would never really represent a single service. Created a NextBus.services method that returns all these entities in a similar manner. Update test specs
|
14
14
|
|
15
15
|
3.1.4
|
16
|
-
- Bug Fix: NextBus trips returned can be an array or a single hash
|
16
|
+
- Bug Fix: NextBus trips returned can be an array or a single hash
|
17
|
+
|
18
|
+
3.1.5
|
19
|
+
- Bug Fix: NextBus where was incorrectly sending Time in 12 hour format when ATIS needs it in 24 hour format.
|
data/Gemfile.lock
CHANGED
data/lib/ratis/next_bus.rb
CHANGED
@@ -5,27 +5,37 @@ module Ratis
|
|
5
5
|
attr_accessor :stop, :services, :success
|
6
6
|
|
7
7
|
def initialize(response)
|
8
|
-
@success
|
9
|
-
@stop = response.body[:nextbus_response][:atstop]
|
10
|
-
_services = @stop.delete(:service)
|
8
|
+
@success = response.success?
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
if @success
|
11
|
+
@stop = response.body[:nextbus_response][:atstop]
|
12
|
+
|
13
|
+
_services = @stop.delete(:service)
|
14
|
+
|
15
|
+
unless _services.is_a?(Array)
|
16
|
+
_services = [_services]
|
17
|
+
end
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
@services = _services.map do |service|
|
20
|
+
OpenStruct.new(:status => service[:status],
|
21
|
+
:sign => service[:sign],
|
22
|
+
:routetype => service[:routetype],
|
23
|
+
:times => service[:times],
|
24
|
+
:direction => service[:direction],
|
25
|
+
:servicetype => service[:servicetype],
|
26
|
+
:route => service[:route],
|
27
|
+
:operator => service[:operator],
|
28
|
+
:trips => parse_trip_info(service[:tripinfo])
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
else
|
33
|
+
@stop = {}
|
34
|
+
@services = []
|
27
35
|
end
|
28
36
|
|
37
|
+
debugger
|
38
|
+
x = 1
|
29
39
|
end
|
30
40
|
|
31
41
|
def parse_trip_info(trips)
|
@@ -77,7 +87,7 @@ module Ratis
|
|
77
87
|
response = Request.get 'Nextbus', {'Stopid' => stop_id,
|
78
88
|
'Appid' => app_id,
|
79
89
|
'Date' => datetime.strftime("%m/%d/%Y"),
|
80
|
-
'Time' => datetime.strftime("%
|
90
|
+
'Time' => datetime.strftime("%H%M"),
|
81
91
|
'Type' => type }
|
82
92
|
|
83
93
|
NextBus.new(response)
|
data/lib/ratis/version.rb
CHANGED
data/spec/ratis/next_bus_spec.rb
CHANGED
@@ -20,6 +20,25 @@ describe Ratis::NextBus do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
describe '#where' do
|
23
|
+
describe 'time formatting' do
|
24
|
+
it 'should make requests with 24 hour time format' do
|
25
|
+
@stop_id = 10050
|
26
|
+
@time = Chronic.parse('tomorrow at 3pm')
|
27
|
+
@conditions = {:stop_id => @stop_id,
|
28
|
+
:app_id => 'ratis-specs', # a short string that can be used to separate requests from different applications or different modules with
|
29
|
+
:type => 'N',
|
30
|
+
:datetime => @time }
|
31
|
+
|
32
|
+
Ratis::Request.should_receive(:get) do |action, options|
|
33
|
+
action.should eq('Nextbus')
|
34
|
+
options["Time"].should eq(@time.strftime("%H%M"))
|
35
|
+
|
36
|
+
end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running
|
37
|
+
|
38
|
+
Ratis::NextBus.where(@conditions.dup)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
23
42
|
describe 'single service return' do
|
24
43
|
before do
|
25
44
|
@stop_id = 10050
|
@@ -27,9 +46,10 @@ describe Ratis::NextBus do
|
|
27
46
|
:app_id => 'ratis-specs', # a short string that can be used to separate requests from different applications or different modules with
|
28
47
|
:type => 'N',
|
29
48
|
:datetime => @time }
|
49
|
+
|
30
50
|
end
|
31
51
|
|
32
|
-
it 'returns the next
|
52
|
+
it 'returns the next bus times' do
|
33
53
|
# raises exception when no runs available:
|
34
54
|
# Ratis::Errors::SoapError:
|
35
55
|
# SOAP - no runs available
|
@@ -49,7 +69,7 @@ describe Ratis::NextBus do
|
|
49
69
|
options["Stopid"].should eq(@stop_id)
|
50
70
|
options["Appid"].should eq('ratis-specs')
|
51
71
|
options["Date"].should eq(@time.strftime("%m/%d/%Y"))
|
52
|
-
options["Time"].should eq(@time.strftime("%
|
72
|
+
options["Time"].should eq(@time.strftime("%H%M"))
|
53
73
|
options["Type"].should eq('N')
|
54
74
|
|
55
75
|
end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running
|
@@ -99,7 +119,7 @@ describe Ratis::NextBus do
|
|
99
119
|
options["Stopid"].should eq(@stop_id)
|
100
120
|
options["Appid"].should eq('ratis-specs')
|
101
121
|
options["Date"].should eq(@time.strftime("%m/%d/%Y"))
|
102
|
-
options["Time"].should eq(@time.strftime("%
|
122
|
+
options["Time"].should eq(@time.strftime("%H%M"))
|
103
123
|
options["Type"].should eq('N')
|
104
124
|
|
105
125
|
end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running
|
@@ -137,7 +157,7 @@ describe Ratis::NextBus do
|
|
137
157
|
options["Stopid"].should eq(@stop_id)
|
138
158
|
options["Appid"].should eq('ratis-specs')
|
139
159
|
options["Date"].should eq(@time.strftime("%m/%d/%Y"))
|
140
|
-
options["Time"].should eq(@time.strftime("%
|
160
|
+
options["Time"].should eq(@time.strftime("%H%M"))
|
141
161
|
options["Type"].should eq('N')
|
142
162
|
|
143
163
|
end.and_return(double('response', :success? => false, :body => empty_body)) # false only to stop further running
|
@@ -198,7 +218,7 @@ describe Ratis::NextBus do
|
|
198
218
|
it "should return an empty array if the api request isn't successful" do
|
199
219
|
Ratis::Request.should_receive('get') do |action, options|
|
200
220
|
action.should eq('Nextbus')
|
201
|
-
options["Time"].should eq(@time.strftime("%
|
221
|
+
options["Time"].should eq(@time.strftime("%H%M") )
|
202
222
|
options["Type"].should eq("N")
|
203
223
|
options["Stopid"].should eq(@stop_id)
|
204
224
|
options["Date"].should eq(@time.strftime("%m/%d/%Y") )
|
@@ -1,4 +1,5 @@
|
|
1
1
|
---
|
2
|
+
recorded_with: VCR 2.4.0
|
2
3
|
http_interactions:
|
3
4
|
- request:
|
4
5
|
method: post
|
@@ -20,25 +21,25 @@ http_interactions:
|
|
20
21
|
aW50MnBvaW50PjwvZW52OkJvZHk+PC9lbnY6RW52ZWxvcGU+
|
21
22
|
|
22
23
|
headers:
|
23
|
-
Soapaction:
|
24
|
-
- "\"PX_WEB#Point2point\""
|
25
24
|
Content-Type:
|
26
25
|
- text/xml;charset=UTF-8
|
27
26
|
Accept:
|
28
27
|
- "*/*"
|
29
28
|
Content-Length:
|
30
29
|
- "576"
|
30
|
+
Soapaction:
|
31
|
+
- "\"PX_WEB#Point2point\""
|
31
32
|
response:
|
32
33
|
status:
|
33
34
|
code: 302
|
34
35
|
message: Found
|
35
36
|
headers:
|
36
|
-
Server:
|
37
|
-
- BigIP
|
38
|
-
Content-Length:
|
39
|
-
- "0"
|
40
37
|
Connection:
|
41
38
|
- Keep-Alive
|
39
|
+
Content-Length:
|
40
|
+
- "0"
|
41
|
+
Server:
|
42
|
+
- BigIP
|
42
43
|
Location:
|
43
44
|
- http://www.iana.org/domains/example/
|
44
45
|
body:
|
@@ -55,41 +56,41 @@ http_interactions:
|
|
55
56
|
c29hcC9lbnZlbG9wZS8iIHhtbG5zOndzZGw9IlBYX1dFQiIgeG1sbnM6eHNk
|
56
57
|
PSJodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYSIgeG1sbnM6eHNp
|
57
58
|
PSJodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYS1pbnN0YW5jZSI+
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
PGVudjpCb2R5PjxQb2ludDJwb2ludCB4bWxucz0iUFhfV0VCIj48RGVzdGlu
|
60
|
+
YXRpb25sYXQ+MzMuNDQ3MDk4PC9EZXN0aW5hdGlvbmxhdD48U3RhcnR0aW1l
|
61
|
+
PjE3MDA8L1N0YXJ0dGltZT48RW5kdGltZT4xODAwPC9FbmR0aW1lPjxSb3V0
|
62
|
+
ZXM+MTwvUm91dGVzPjxSb3V0ZXNvbmx5Plk8L1JvdXRlc29ubHk+PE9yaWdp
|
63
|
+
bmxhdD4zMy40NDY5MzE8L09yaWdpbmxhdD48T3JpZ2lubG9uZz4tMTEyLjA5
|
64
|
+
NzkwMzwvT3JpZ2lubG9uZz48RGVzdGluYXRpb25sb25nPi0xMTIuMDc3MjEz
|
65
|
+
PC9EZXN0aW5hdGlvbmxvbmc+PERhdGU+MDYvMTAvMjAxMzwvRGF0ZT48L1Bv
|
65
66
|
aW50MnBvaW50PjwvZW52OkJvZHk+PC9lbnY6RW52ZWxvcGU+
|
66
67
|
|
67
68
|
headers:
|
68
|
-
Soapaction:
|
69
|
-
- "\"PX_WEB#Point2point\""
|
70
69
|
Content-Type:
|
71
70
|
- text/xml;charset=UTF-8
|
72
71
|
Accept:
|
73
72
|
- "*/*"
|
74
73
|
Content-Length:
|
75
74
|
- "576"
|
75
|
+
Soapaction:
|
76
|
+
- "\"PX_WEB#Point2point\""
|
76
77
|
response:
|
77
78
|
status:
|
78
79
|
code: 200
|
79
80
|
message: OK
|
80
81
|
headers:
|
81
|
-
Server:
|
82
|
-
- Apache/2.2.3 (CentOS)
|
83
|
-
Date:
|
84
|
-
- Thu, 06 Jun 2013 23:02:44 GMT
|
85
82
|
Content-Type:
|
86
83
|
- text/xml; charset=utf-8
|
84
|
+
Connection:
|
85
|
+
- close
|
87
86
|
Soapserver:
|
88
87
|
- SOAP::Lite/Perl/0.55
|
88
|
+
Server:
|
89
|
+
- Apache/2.2.3 (CentOS)
|
89
90
|
Content-Length:
|
90
91
|
- "4558"
|
91
|
-
|
92
|
-
-
|
92
|
+
Date:
|
93
|
+
- Tue, 11 Jun 2013 00:18:05 GMT
|
93
94
|
body:
|
94
95
|
base64_string: |
|
95
96
|
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48U09BUC1F
|
@@ -196,5 +197,4 @@ http_interactions:
|
|
196
197
|
RU5WOkVudmVsb3BlPg==
|
197
198
|
|
198
199
|
http_version:
|
199
|
-
recorded_at:
|
200
|
-
recorded_with: VCR 2.4.0
|
200
|
+
recorded_at: Tue, 11 Jun 2013 00:18:06 GMT
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ratis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 3.1.
|
9
|
+
- 5
|
10
|
+
version: 3.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Burst Software
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-06-
|
18
|
+
date: 2013-06-11 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: savon
|