ratis 3.1.3 → 3.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -10,4 +10,7 @@
10
10
  - Contains info about the stop (:side, :stopid, :heading, :lat, :area, :servicetype, :route, :operator)
11
11
 
12
12
  3.1.3
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
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
+
15
+ 3.1.4
16
+ - Bug Fix: NextBus trips returned can be an array or a single hash
@@ -22,29 +22,43 @@ module Ratis
22
22
  :servicetype => service[:servicetype],
23
23
  :route => service[:route],
24
24
  :operator => service[:operator],
25
- :trips => service[:tripinfo].map do |ti|
26
- OpenStruct.new(:triptime => ti[:triptime],
27
- :block => ti[:block],
28
- :tripid => ti[:tripid],
29
- :exception => ti[:exception],
30
- :skedtripid => ti[:skedtripid],
31
- :realtime => OpenStruct.new(:valid => ti[:realtime][:valid],
32
- :adherence => ti[:realtime][:adherence],
33
- :estimatedtime => ti[:realtime][:estimatedtime],
34
- :estimatedminutes => ti[:realtime][:estimatedminutes],
35
- :polltime => ti[:realtime][:polltime],
36
- :trend => ti[:realtime][:trend],
37
- :speed => ti[:realtime][:speed],
38
- :reliable => ti[:realtime][:reliable],
39
- :stopped => ti[:realtime][:stopped],
40
- :lat => ti[:realtime][:lat],
41
- :long => ti[:realtime][:long] ))
42
- end
25
+ :trips => parse_trip_info(service[:tripinfo])
43
26
  )
44
27
  end
45
28
 
46
29
  end
47
30
 
31
+ def parse_trip_info(trips)
32
+ # can come back as an Array or single Hash...
33
+ if trips.is_a?(Array)
34
+ trips.map do |ti|
35
+ create_trip(ti)
36
+ end
37
+ else # Hash
38
+ [create_trip(trips)]
39
+ end
40
+ end
41
+
42
+ # TODO: turn into real classes
43
+ def create_trip(trip)
44
+ OpenStruct.new(:triptime => trip[:triptime],
45
+ :block => trip[:block],
46
+ :tripid => trip[:tripid],
47
+ :exception => trip[:exception],
48
+ :skedtripid => trip[:skedtripid],
49
+ :realtime => OpenStruct.new(:valid => trip[:realtime][:valid],
50
+ :adherence => trip[:realtime][:adherence],
51
+ :estimatedtime => trip[:realtime][:estimatedtime],
52
+ :estimatedminutes => trip[:realtime][:estimatedminutes],
53
+ :polltime => trip[:realtime][:polltime],
54
+ :trend => trip[:realtime][:trend],
55
+ :speed => trip[:realtime][:speed],
56
+ :reliable => trip[:realtime][:reliable],
57
+ :stopped => trip[:realtime][:stopped],
58
+ :lat => trip[:realtime][:lat],
59
+ :long => trip[:realtime][:long] ))
60
+ end
61
+
48
62
  def self.where(conditions)
49
63
  stop_id = conditions.delete(:stop_id)
50
64
  app_id = conditions.delete(:app_id) || 'ratis-gem'
@@ -5,7 +5,7 @@ module Ratis
5
5
  def version
6
6
  @version ||= begin
7
7
 
8
- string = '3.1.3'
8
+ string = '3.1.4'
9
9
 
10
10
  def string.parts
11
11
  split('.').map { |p| p.to_i }
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: 5
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 3
10
- version: 3.1.3
9
+ - 4
10
+ version: 3.1.4
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-06 00:00:00 Z
18
+ date: 2013-06-07 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: savon