octranspo 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. data/.gitignore +3 -0
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +26 -0
  4. data/Rakefile +8 -0
  5. data/lib/octranspo.rb +20 -0
  6. data/lib/octranspo/headsign.rb +2539 -0
  7. data/lib/octranspo/headsigns.yml +40565 -0
  8. data/lib/octranspo/landmarks.rb +37 -0
  9. data/lib/octranspo/lingo.rb +125 -0
  10. data/lib/octranspo/lingo/headsign_messages.yml +104 -0
  11. data/lib/octranspo/lingo/headsign_signatures.yml +3 -0
  12. data/lib/octranspo/lingo/landmarks.yml +205 -0
  13. data/lib/octranspo/lingo/roadways.yml +1957 -0
  14. data/lib/octranspo/mobile_resource_methods.rb +98 -0
  15. data/lib/octranspo/mobile_route_data.rb +85 -0
  16. data/lib/octranspo/mobile_route_schedule.rb +118 -0
  17. data/lib/octranspo/mobile_stop_schedule.rb +137 -0
  18. data/lib/octranspo/remote_resource_methods.rb +89 -0
  19. data/lib/octranspo/route.rb +31 -0
  20. data/lib/octranspo/routes.yml +507 -0
  21. data/lib/octranspo/service_date.rb +17 -0
  22. data/lib/octranspo/stations.yml +77 -0
  23. data/lib/octranspo/stop.rb +69 -0
  24. data/lib/octranspo/stop_resource.rb +46 -0
  25. data/lib/octranspo/stops.yml +30696 -0
  26. data/lib/octranspo/version.rb +3 -0
  27. data/octranspo.gemspec +22 -0
  28. data/test/fixtures/mobile_route_data/20090323/route_123_index_0.html +457 -0
  29. data/test/fixtures/mobile_route_data/20090323/route_123_index_1.html +99 -0
  30. data/test/fixtures/mobile_route_data/20090323/route_1_index_0.html +700 -0
  31. data/test/fixtures/mobile_route_data/20090323/route_1_index_1.html +691 -0
  32. data/test/fixtures/mobile_route_data/20090323/route_2_index_0.html +682 -0
  33. data/test/fixtures/mobile_route_data/20090323/route_2_index_1.html +646 -0
  34. data/test/fixtures/mobile_route_data/20100323/route_123_index_0.html +469 -0
  35. data/test/fixtures/mobile_route_data/20100323/route_123_index_1.html +105 -0
  36. data/test/fixtures/mobile_route_data/20100323/route_1_index_0.html +703 -0
  37. data/test/fixtures/mobile_route_data/20100323/route_1_index_1.html +694 -0
  38. data/test/fixtures/mobile_route_data/20100323/route_2_index_0.html +685 -0
  39. data/test/fixtures/mobile_route_data/20100323/route_2_index_1.html +649 -0
  40. data/test/fixtures/mobile_route_data/20100323/route_3_index_0.html +649 -0
  41. data/test/fixtures/mobile_route_data/20100323/route_3_index_1.html +721 -0
  42. data/test/fixtures/mobile_route_schedule/20090323/route_18_direction_2_location_25.html +1038 -0
  43. data/test/fixtures/mobile_route_schedule/20090323/route_1_direction_1_location_0.html +1127 -0
  44. data/test/fixtures/mobile_route_schedule/20090323/route_2_direction_2_location_11.html +1430 -0
  45. data/test/fixtures/mobile_route_schedule/20090323/route_2_direction__location_11.html +104 -0
  46. data/test/fixtures/mobile_route_schedule/20100323/route_1_direction_1_location_0.html +1180 -0
  47. data/test/fixtures/mobile_route_schedule/20100323/route_2_direction_2_location_11.html +1554 -0
  48. data/test/fixtures/mobile_route_schedule/20100323/route_3_direction_1_location_0.html +1082 -0
  49. data/test/fixtures/mobile_route_schedule/20100323/route_3_direction_1_location_1.html +1082 -0
  50. data/test/fixtures/mobile_stop_schedule/20090323/location_1987.yml +198 -0
  51. data/test/fixtures/mobile_stop_schedule/20090323/location_1987_route_index_0.html +1283 -0
  52. data/test/fixtures/mobile_stop_schedule/20090323/location_1987_route_index_1.html +194 -0
  53. data/test/fixtures/mobile_stop_schedule/20090323/location_1987_route_index_2.html +116 -0
  54. data/test/fixtures/mobile_stop_schedule/20090323/location_3058_route_index_12.html +149 -0
  55. data/test/fixtures/mobile_stop_schedule/20090323/location_8789_route_index_0.html +1002 -0
  56. data/test/fixtures/mobile_stop_schedule/20100323/location_1987.yml +209 -0
  57. data/test/fixtures/mobile_stop_schedule/20100323/location_1987_route_index_0.html +1393 -0
  58. data/test/fixtures/mobile_stop_schedule/20100323/location_1987_route_index_1.html +206 -0
  59. data/test/fixtures/mobile_stop_schedule/20100323/location_1987_route_index_2.html +123 -0
  60. data/test/fixtures/mobile_stop_schedule/20100323/location_3058_route_index_12.html +278 -0
  61. data/test/fixtures/mobile_stop_schedule/20100323/location_7558_route_index_0.html +979 -0
  62. data/test/fixtures/mobile_stop_schedule/20100323/location_8789_route_index_0.html +1059 -0
  63. data/test/fixtures/stop_resource/1987.html +126 -0
  64. data/test/test_helper.rb +15 -0
  65. data/test/unit/headsign_test.rb +34 -0
  66. data/test/unit/lingo_test.rb +139 -0
  67. data/test/unit/mobile_resource_methods_test.rb +25 -0
  68. data/test/unit/mobile_route_data_test.rb +124 -0
  69. data/test/unit/mobile_route_schedule_test.rb +210 -0
  70. data/test/unit/mobile_stop_schedule_test.rb +153 -0
  71. data/test/unit/service_date_test.rb +27 -0
  72. data/test/unit/stop_resource_test.rb +26 -0
  73. metadata +251 -0
@@ -0,0 +1,210 @@
1
+ require "#{File.dirname(File.dirname(__FILE__))}/test_helper"
2
+
3
+ module OCTranspo
4
+ class MobileRouteScheduleTest < ActiveSupport::TestCase
5
+
6
+ def setup
7
+ OCTranspo::MobileRouteData.use_fixtures!
8
+ OCTranspo::MobileRouteSchedule.use_fixtures!
9
+ end
10
+
11
+ def teardown
12
+ OCTranspo::MobileRouteData.reset!
13
+ OCTranspo::MobileRouteSchedule.reset!
14
+ end
15
+
16
+ def date
17
+ @date ||= Date.parse("20100323")
18
+ end
19
+
20
+ def assert_departures_are_in_correct_timezone (departures)
21
+ assert departures.any?
22
+ assert departures.all? {|d| d[:time].time_zone.name == "Eastern Time (US & Canada)" }, "Some departure times are not in the Eastern Time time zone"
23
+ end
24
+
25
+ test "url_for with direction" do
26
+ expected = "http://www.octranspo.com/mobileweb/jnot/post.stoplist.schedules.oci?rangeIndex=5&day=20100323&route=1&direction=Direction1&check0=on"
27
+ criteria = {:route => 1, :direction => "SOUTH KEYS", :date => date}
28
+ assert_equal expected, OCTranspo::MobileRouteSchedule.url_for(criteria)
29
+
30
+ expected = "http://www.octranspo.com/mobileweb/jnot/post.stoplist.schedules.oci?rangeIndex=5&day=20100323&route=1&direction=Direction2&check0=on"
31
+ criteria = {:route => 1, :direction => "OTTAWA-ROCKCLIFFE", :date => date}
32
+ assert_equal expected, OCTranspo::MobileRouteSchedule.url_for(criteria)
33
+ end
34
+
35
+ test "url_for with direction index" do
36
+ expected = "http://www.octranspo.com/mobileweb/jnot/post.stoplist.schedules.oci?rangeIndex=5&day=20100323&route=1&direction=Direction1&check0=on"
37
+ criteria = {:route => 1, :direction_index => 1, :date => date}
38
+ assert_equal expected, OCTranspo::MobileRouteSchedule.url_for(criteria)
39
+
40
+ expected = "http://www.octranspo.com/mobileweb/jnot/post.stoplist.schedules.oci?rangeIndex=5&day=20100323&route=1&direction=Direction2&check0=on"
41
+ criteria = {:route => 1, :direction_index => 2, :date => date}
42
+ assert_equal expected, OCTranspo::MobileRouteSchedule.url_for(criteria)
43
+ end
44
+
45
+ test "url_for with location index option" do
46
+ expected = "http://www.octranspo.com/mobileweb/jnot/post.stoplist.schedules.oci?rangeIndex=5&day=20100323&route=1&direction=Direction1&check2=on"
47
+ criteria = {:route => 1, :location_index => 2, :date => date}
48
+ assert_equal expected, OCTranspo::MobileRouteSchedule.url_for(criteria)
49
+ end
50
+
51
+ test "find schedule for route 1 going to South Keys from bus stop 8789 (the first stop on the route)" do
52
+ criteria = {:route => 1, :direction => "SOUTH KEYS", :location_index => 0, :date => date}
53
+ schedule = OCTranspo::MobileRouteSchedule.find_one(criteria)
54
+
55
+ assert schedule
56
+ assert_equal date, schedule[:date]
57
+ assert_equal "8789", schedule[:location][:number]
58
+ assert_equal "MAPLE LANE / SPRINGFIELD", schedule[:location][:name]
59
+ assert_equal "1", schedule[:route]
60
+ assert_equal "SOUTH KEYS", schedule[:direction]
61
+
62
+ assert_departures_are_in_correct_timezone schedule[:departures]
63
+
64
+ first_departure = schedule[:departures].first
65
+ assert_equal date.at("05:52"), first_departure[:time]
66
+ assert_equal "SOUTH KEYS", first_departure[:destination]
67
+
68
+ last_departure = schedule[:departures].last
69
+ assert_equal date.at("23:11"), last_departure[:time]
70
+ assert_equal "SOUTH KEYS", last_departure[:destination]
71
+ end
72
+
73
+ test "find schedule for route 1 going to South Keys from bus stop 8789 (the first stop on the route) using direction index" do
74
+ criteria = {:route => 1, :direction_index => 1, :location_index => 0, :date => date}
75
+ schedule = OCTranspo::MobileRouteSchedule.find_one(criteria)
76
+
77
+ assert schedule
78
+ assert_equal date, schedule[:date]
79
+ assert_equal "8789", schedule[:location][:number]
80
+ assert_equal "MAPLE LANE / SPRINGFIELD", schedule[:location][:name]
81
+ assert_equal "1", schedule[:route]
82
+ assert_equal "SOUTH KEYS", schedule[:direction]
83
+
84
+ assert_departures_are_in_correct_timezone schedule[:departures]
85
+
86
+ first_departure = schedule[:departures].first
87
+ assert_equal date.at("05:52"), first_departure[:time]
88
+ assert_equal "SOUTH KEYS", first_departure[:destination]
89
+
90
+ last_departure = schedule[:departures].last
91
+ assert_equal date.at("23:11"), last_departure[:time]
92
+ assert_equal "SOUTH KEYS", last_departure[:destination]
93
+ end
94
+
95
+ test "find schedule for route 2 going to Bayshore from bus stop 1987 (the twelth stop on the route)" do
96
+ criteria = {:route => 2, :direction => "BAYSHORE", :location_index => 11, :date => date}
97
+ schedule = OCTranspo::MobileRouteSchedule.find_one(criteria)
98
+
99
+ assert schedule
100
+ assert_equal date, schedule[:date]
101
+ assert_equal "1987", schedule[:location][:number]
102
+ assert_equal "SOMERSET O-W / BRONSON", schedule[:location][:name]
103
+ assert_equal "2", schedule[:route]
104
+ assert_equal "BAYSHORE", schedule[:direction]
105
+
106
+ assert_departures_are_in_correct_timezone schedule[:departures]
107
+
108
+ first_departure = schedule[:departures].first
109
+ assert_equal date.at('05:03'), first_departure[:time]
110
+ assert_equal "BAYSHORE", first_departure[:destination]
111
+
112
+ last_departure = schedule[:departures].last
113
+ assert_equal date.next.at('01:18'), last_departure[:time]
114
+ assert_equal "BAYSHORE", last_departure[:destination]
115
+ end
116
+
117
+ test "find schedule for route 2 going to Bayshore from bus stop 1987 (the twelth stop on the route) using direction index" do
118
+ criteria = {:route => 2, :direction_index => 2, :location_index => 11, :date => date}
119
+ schedule = OCTranspo::MobileRouteSchedule.find_one(criteria)
120
+
121
+ assert schedule
122
+ assert_equal date, schedule[:date]
123
+ assert_equal "1987", schedule[:location][:number]
124
+ assert_equal "SOMERSET O-W / BRONSON", schedule[:location][:name]
125
+ assert_equal "2", schedule[:route]
126
+ assert_equal "BAYSHORE", schedule[:direction]
127
+
128
+ assert_departures_are_in_correct_timezone schedule[:departures]
129
+
130
+ first_departure = schedule[:departures].first
131
+ assert_equal date.at('05:03'), first_departure[:time]
132
+ assert_equal "BAYSHORE", first_departure[:destination]
133
+
134
+ last_departure = schedule[:departures].last
135
+ assert_equal date.next.at('01:18'), last_departure[:time]
136
+ assert_equal "BAYSHORE", last_departure[:destination]
137
+ end
138
+
139
+ test "find schedule for route 3 heading toward Colonnade from RIDEAU 4A (the first stop on the route)" do
140
+ criteria = {:route => 3, :direction => "COLONNADE", :location_index => 0, :date => date}
141
+ schedule = OCTranspo::MobileRouteSchedule.find_one(criteria)
142
+
143
+ assert schedule
144
+ assert_equal date, schedule[:date]
145
+ assert_equal "3009", schedule[:location][:number]
146
+ assert_equal "RIDEAU 4A", schedule[:location][:name]
147
+ assert_equal "3", schedule[:route]
148
+ assert_equal "COLONNADE", schedule[:direction]
149
+
150
+ assert_departures_are_in_correct_timezone schedule[:departures]
151
+
152
+ first_departure = schedule[:departures].first
153
+ assert_equal date.at('06:04'), first_departure[:time]
154
+ assert_equal "COLONNADE", first_departure[:destination]
155
+
156
+ last_departure = schedule[:departures].last
157
+ assert_equal date.at('23:47'), last_departure[:time]
158
+ assert_equal "COLONNADE", last_departure[:destination]
159
+
160
+ last_nepean_centre_departure = schedule[:departures][-14]
161
+ assert_equal date.at('17:36'), last_nepean_centre_departure[:time]
162
+ assert_equal "3X NEPEAN CENTRE MERIVALE VIEWMOUNT", last_nepean_centre_departure[:destination]
163
+ end
164
+
165
+ test "find schedule for route 3 heading toward Colonnade from bus stop 7558 (the second stop on the route)" do
166
+ criteria = {:route => 3, :direction => "COLONNADE", :location_index => 1, :date => date}
167
+ schedule = OCTranspo::MobileRouteSchedule.find_one(criteria)
168
+
169
+ assert schedule
170
+ assert_equal date, schedule[:date]
171
+ assert_equal "7558", schedule[:location][:number]
172
+ assert_equal "ELGIN / QUEEN", schedule[:location][:name]
173
+ assert_equal "3", schedule[:route]
174
+ assert_equal "COLONNADE", schedule[:direction]
175
+
176
+ assert_departures_are_in_correct_timezone schedule[:departures]
177
+
178
+ first_departure = schedule[:departures].first
179
+ assert_equal date.at('06:06'), first_departure[:time]
180
+ assert_equal "COLONNADE", first_departure[:destination]
181
+
182
+ last_departure = schedule[:departures].last
183
+ assert_equal date.at('23:49'), last_departure[:time]
184
+ assert_equal "COLONNADE", last_departure[:destination]
185
+
186
+ last_nepean_centre_departure = schedule[:departures][-14]
187
+ assert_equal date.at('17:38'), last_nepean_centre_departure[:time]
188
+ assert_equal "3X NEPEAN CENTRE MERIVALE VIEWMOUNT", last_nepean_centre_departure[:destination]
189
+ end
190
+
191
+ test "find schedule for a route at a stop without a number" do
192
+ @date ||= Date.parse("20090323")
193
+
194
+ criteria = {:route => 18, :direction_index => 2, :location_index => 25, :date => date}
195
+ schedule = OCTranspo::MobileRouteSchedule.find_one(criteria)
196
+
197
+ assert schedule
198
+ assert_equal date, schedule[:date]
199
+ assert_equal "QUILL / GLYNN", schedule[:location][:name]
200
+ assert schedule[:location][:number].nil?
201
+ assert_equal "18", schedule[:route]
202
+ assert_equal "BRITANNIA", schedule[:direction]
203
+ assert schedule[:departures].any?
204
+
205
+ assert_equal "VIA CROYDON REGINA", schedule[:destinations]['x']
206
+ assert_equal "DOWNTOWN CENTRE-VILLE", schedule[:destinations]['y']
207
+ assert_equal "VIA CASSELS BRADFORD", schedule[:destinations]['D']
208
+ end
209
+ end
210
+ end
@@ -0,0 +1,153 @@
1
+ require "#{File.dirname(File.dirname(__FILE__))}/test_helper"
2
+
3
+ module OCTranspo
4
+ class MobileStopScheduleTest < ActiveSupport::TestCase
5
+
6
+ def setup
7
+ OCTranspo::MobileStopSchedule.use_fixtures!
8
+ end
9
+
10
+ def teardown
11
+ OCTranspo::MobileStopSchedule.reset!
12
+ end
13
+
14
+ def date
15
+ @date ||= Date.parse("20100323")
16
+ end
17
+
18
+ test "url_for" do
19
+ expected = "http://www.octranspo.com/mobileweb/jnot/post.routelist.stoptimes.oci?rangeIndex=5&day=20100323&stop=1987&check0=on"
20
+ criteria = {:location => 1987, :route_index => 0, :date => date}
21
+ assert_equal expected, OCTranspo::MobileStopSchedule.url_for(criteria)
22
+ criteria = {:location => 1987, :date => date}
23
+ assert_equal expected, OCTranspo::MobileStopSchedule.url_for(criteria)
24
+ end
25
+
26
+ test "url_for with route index option" do
27
+ expected = "http://www.octranspo.com/mobileweb/jnot/post.routelist.stoptimes.oci?rangeIndex=5&day=20100323&stop=1987&check1=on"
28
+ criteria = {:location => 1987, :route_index => 1, :date => date}
29
+ assert_equal expected, OCTranspo::MobileStopSchedule.url_for(criteria)
30
+ end
31
+
32
+ test "find schedule for route 1 going to South Keys from bus stop 8789 (the first stop on the route)" do
33
+ criteria = {:route => 1, :direction => "SOUTH KEYS", :location => "8789", :date => date}
34
+ schedule = OCTranspo::MobileStopSchedule.find_one(criteria)
35
+
36
+ assert schedule
37
+ assert_equal date, schedule[:date]
38
+ assert_equal "8789", schedule[:location][:number]
39
+ assert_equal "MAPLE LANE / SPRINGFIELD", schedule[:location][:name]
40
+ assert_equal "1", schedule[:route]
41
+ assert_equal "SOUTH KEYS", schedule[:direction]
42
+
43
+ assert schedule[:departures].any?
44
+ assert schedule[:departures].all? {|d| d[:time].time_zone.name == "Eastern Time (US & Canada)" }, "Some departure times are not in the Eastern Time time zone"
45
+
46
+ first_departure = schedule[:departures].first
47
+ assert_equal date.at("05:52"), first_departure[:time]
48
+ assert_equal "SOUTH KEYS", first_departure[:destination]
49
+
50
+ last_departure = schedule[:departures].last
51
+ assert_equal date.at("23:11"), last_departure[:time]
52
+ assert_equal "SOUTH KEYS", last_departure[:destination]
53
+ end
54
+
55
+ test "find schedule for route 2 heading toward Bayshore from bus stop #1987" do
56
+ criteria = {:route => 2, :direction => "BAYSHORE", :location => "1987", :date => date}
57
+ schedule = OCTranspo::MobileStopSchedule.find_one(criteria)
58
+
59
+ assert schedule
60
+ assert_equal date, schedule[:date]
61
+ assert_equal "1987", schedule[:location][:number]
62
+ assert_equal "SOMERSET O-W / BRONSON", schedule[:location][:name]
63
+ assert_equal "2", schedule[:route]
64
+ assert_equal "BAYSHORE", schedule[:direction]
65
+
66
+ assert schedule[:departures].any?
67
+ assert schedule[:departures].all? {|d| d[:time].time_zone.name == "Eastern Time (US & Canada)" }, "Some departure times are not in the Eastern Time time zone"
68
+
69
+ first_departure = schedule[:departures].first
70
+ assert_equal date.at('05:03'), first_departure[:time]
71
+ assert_equal "BAYSHORE", first_departure[:destination]
72
+
73
+ last_departure = schedule[:departures].last
74
+ assert_equal date.next.at('01:18'), last_departure[:time]
75
+ assert_equal "BAYSHORE", last_departure[:destination]
76
+ end
77
+
78
+ test "find schedule for route 3 heading toward Colonnade from bus stop #7558" do
79
+ criteria = {:route => 3, :direction => "COLONNADE", :location => "7558", :date => date}
80
+ schedule = OCTranspo::MobileStopSchedule.find_one(criteria)
81
+
82
+ assert schedule
83
+ assert_equal date, schedule[:date]
84
+ assert_equal "7558", schedule[:location][:number]
85
+ assert_equal "ELGIN / QUEEN", schedule[:location][:name]
86
+ assert_equal "3", schedule[:route]
87
+ assert_equal "COLONNADE", schedule[:direction]
88
+
89
+ assert schedule[:departures].any?
90
+ assert schedule[:departures].all? {|d| d[:time].time_zone.name == "Eastern Time (US & Canada)" }, "Some departure times are not in the Eastern Time time zone"
91
+
92
+ first_departure = schedule[:departures].first
93
+ assert_equal date.at('06:06'), first_departure[:time]
94
+ assert_equal "COLONNADE", first_departure[:destination]
95
+
96
+ last_departure = schedule[:departures].last
97
+ assert_equal date.at('23:49'), last_departure[:time]
98
+ assert_equal "COLONNADE", last_departure[:destination]
99
+
100
+ last_nepean_centre_departure = schedule[:departures][-14]
101
+ assert_equal date.at('17:38'), last_nepean_centre_departure[:time]
102
+ assert_equal "3X NEPEAN CENTRE MERIVALE VIEWMOUNT", last_nepean_centre_departure[:destination]
103
+ end
104
+
105
+ test "find the first schedule for stop number 1987" do
106
+ criteria = {:location => 1987, :date => date}
107
+ schedule = OCTranspo::MobileStopSchedule.find_one(criteria)
108
+
109
+ assert_equal date, schedule[:date]
110
+ assert_equal "2", schedule[:route]
111
+ assert_equal "BAYSHORE", schedule[:direction]
112
+ assert schedule[:legend]
113
+ assert schedule[:destinations]
114
+ assert schedule[:departures].any?
115
+
116
+ first_departure = schedule[:departures].first
117
+ assert_equal date.at("05:03"), first_departure[:time]
118
+ assert_equal "BAYSHORE", first_departure[:destination]
119
+
120
+ last_departure = schedule[:departures].last
121
+ assert_equal date.next.at("01:18"), last_departure[:time]
122
+ assert_equal "BAYSHORE", last_departure[:destination]
123
+ end
124
+
125
+ test "find all schedules for stop number 1987" do
126
+ criteria = {:location => 1987, :date => date}
127
+ schedules = OCTranspo::MobileStopSchedule.find_all(criteria)
128
+ assert 2, schedules.size
129
+
130
+ assert_equal "2", schedules.first[:route]
131
+ assert_equal "BAYSHORE", schedules.first[:direction]
132
+ assert schedules.first[:departures].any?
133
+
134
+ assert_equal "153", schedules.last[:route]
135
+ assert_equal "LEBRETON", schedules.last[:direction]
136
+ assert schedules.last[:departures].any?
137
+ end
138
+
139
+ test "find schedule for route 404 going to scotia bank place from bus stop number 3058" do
140
+ criteria = {:location => 3058, :route_index => 12, :date => date}
141
+ schedule = OCTranspo::MobileStopSchedule.find_one(criteria)
142
+
143
+ assert schedule
144
+ assert_equal date, schedule[:date]
145
+ assert_equal "404", schedule[:route]
146
+ assert_equal "SCOTIABANK PLACE BANQUE SCOTIA", schedule[:direction]
147
+ assert_equal "3058", schedule[:location][:number]
148
+ assert_equal "TERRY FOX 3C", schedule[:location][:name]
149
+
150
+ assert schedule[:departures].any?
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,27 @@
1
+ require "#{File.dirname(File.dirname(__FILE__))}/test_helper"
2
+
3
+ module OCTranspo
4
+ class ServiceDateTest < ActiveSupport::TestCase
5
+
6
+ include ServiceDate
7
+
8
+ test "service_date_for" do
9
+ monday = Date.parse('Monday, September 29')
10
+ tuesday = Date.parse('Tuesday, September 30')
11
+
12
+ monday_at_8_am = Time.zone.parse("Monday, September 29 at 08:00")
13
+ monday_at_noon = Time.zone.parse("Monday, September 29 at 12:00")
14
+ monday_at_11_pm = Time.zone.parse("Monday, September 29 at 23:00")
15
+ tuesday_at_midnight = Time.zone.parse("Tuesday, September 30 at 00:00")
16
+ tuesday_at_3_am = Time.zone.parse("Tuesday, September 30 at 03:00")
17
+ tuesday_at_5_am = Time.zone.parse("Tuesday, September 30 at 05:00")
18
+
19
+ assert_equal monday, service_date_for(monday_at_8_am)
20
+ assert_equal monday, service_date_for(monday_at_noon)
21
+ assert_equal monday, service_date_for(monday_at_11_pm)
22
+ assert_equal monday, service_date_for(tuesday_at_midnight)
23
+ assert_equal monday, service_date_for(tuesday_at_3_am)
24
+ assert_equal tuesday, service_date_for(tuesday_at_5_am)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ require "#{File.dirname(File.dirname(__FILE__))}/test_helper"
2
+
3
+ module OCTranspo
4
+ class StopResourceTest < ActiveSupport::TestCase
5
+
6
+ def setup
7
+ OCTranspo::StopResource.use_fixtures!
8
+ end
9
+
10
+ def teardown
11
+ OCTranspo::StopResource.reset!
12
+ end
13
+
14
+ test "url_for" do
15
+ expected = "http://www.octranspo.com/tps/jnot/From560.oci?from560Code=1987"
16
+ assert_equal expected, OCTranspo::StopResource.url_for(:number => "1987")
17
+ end
18
+
19
+ test "find a stop by number" do
20
+ stop = OCTranspo::StopResource.find(:number => "1987")
21
+ assert stop.is_a?(Hash)
22
+ assert_equal "1987", stop[:number]
23
+ assert_equal "SOMERSET O-W / BRONSON", stop[:name]
24
+ end
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,251 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: octranspo
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 0
10
+ version: 0.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Craig Davey
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-01-20 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: activesupport
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 9
29
+ segments:
30
+ - 2
31
+ - 3
32
+ - 5
33
+ version: 2.3.5
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: hpricot
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: htmlentities
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ type: :runtime
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: i18n
66
+ prerelease: false
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ type: :runtime
77
+ version_requirements: *id004
78
+ - !ruby/object:Gem::Dependency
79
+ name: tzinfo
80
+ prerelease: false
81
+ requirement: &id005 !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ type: :runtime
91
+ version_requirements: *id005
92
+ description: Tools for gathering data about OC Transpo service, routes and stop locations.
93
+ email: me@craigdavey.ca
94
+ executables: []
95
+
96
+ extensions: []
97
+
98
+ extra_rdoc_files: []
99
+
100
+ files:
101
+ - .gitignore
102
+ - Gemfile
103
+ - Gemfile.lock
104
+ - Rakefile
105
+ - lib/octranspo.rb
106
+ - lib/octranspo/headsign.rb
107
+ - lib/octranspo/headsigns.yml
108
+ - lib/octranspo/landmarks.rb
109
+ - lib/octranspo/lingo.rb
110
+ - lib/octranspo/lingo/headsign_messages.yml
111
+ - lib/octranspo/lingo/headsign_signatures.yml
112
+ - lib/octranspo/lingo/landmarks.yml
113
+ - lib/octranspo/lingo/roadways.yml
114
+ - lib/octranspo/mobile_resource_methods.rb
115
+ - lib/octranspo/mobile_route_data.rb
116
+ - lib/octranspo/mobile_route_schedule.rb
117
+ - lib/octranspo/mobile_stop_schedule.rb
118
+ - lib/octranspo/remote_resource_methods.rb
119
+ - lib/octranspo/route.rb
120
+ - lib/octranspo/routes.yml
121
+ - lib/octranspo/service_date.rb
122
+ - lib/octranspo/stations.yml
123
+ - lib/octranspo/stop.rb
124
+ - lib/octranspo/stop_resource.rb
125
+ - lib/octranspo/stops.yml
126
+ - lib/octranspo/version.rb
127
+ - octranspo.gemspec
128
+ - test/fixtures/mobile_route_data/20090323/route_123_index_0.html
129
+ - test/fixtures/mobile_route_data/20090323/route_123_index_1.html
130
+ - test/fixtures/mobile_route_data/20090323/route_1_index_0.html
131
+ - test/fixtures/mobile_route_data/20090323/route_1_index_1.html
132
+ - test/fixtures/mobile_route_data/20090323/route_2_index_0.html
133
+ - test/fixtures/mobile_route_data/20090323/route_2_index_1.html
134
+ - test/fixtures/mobile_route_data/20100323/route_123_index_0.html
135
+ - test/fixtures/mobile_route_data/20100323/route_123_index_1.html
136
+ - test/fixtures/mobile_route_data/20100323/route_1_index_0.html
137
+ - test/fixtures/mobile_route_data/20100323/route_1_index_1.html
138
+ - test/fixtures/mobile_route_data/20100323/route_2_index_0.html
139
+ - test/fixtures/mobile_route_data/20100323/route_2_index_1.html
140
+ - test/fixtures/mobile_route_data/20100323/route_3_index_0.html
141
+ - test/fixtures/mobile_route_data/20100323/route_3_index_1.html
142
+ - test/fixtures/mobile_route_schedule/20090323/route_18_direction_2_location_25.html
143
+ - test/fixtures/mobile_route_schedule/20090323/route_1_direction_1_location_0.html
144
+ - test/fixtures/mobile_route_schedule/20090323/route_2_direction_2_location_11.html
145
+ - test/fixtures/mobile_route_schedule/20090323/route_2_direction__location_11.html
146
+ - test/fixtures/mobile_route_schedule/20100323/route_1_direction_1_location_0.html
147
+ - test/fixtures/mobile_route_schedule/20100323/route_2_direction_2_location_11.html
148
+ - test/fixtures/mobile_route_schedule/20100323/route_3_direction_1_location_0.html
149
+ - test/fixtures/mobile_route_schedule/20100323/route_3_direction_1_location_1.html
150
+ - test/fixtures/mobile_stop_schedule/20090323/location_1987.yml
151
+ - test/fixtures/mobile_stop_schedule/20090323/location_1987_route_index_0.html
152
+ - test/fixtures/mobile_stop_schedule/20090323/location_1987_route_index_1.html
153
+ - test/fixtures/mobile_stop_schedule/20090323/location_1987_route_index_2.html
154
+ - test/fixtures/mobile_stop_schedule/20090323/location_3058_route_index_12.html
155
+ - test/fixtures/mobile_stop_schedule/20090323/location_8789_route_index_0.html
156
+ - test/fixtures/mobile_stop_schedule/20100323/location_1987.yml
157
+ - test/fixtures/mobile_stop_schedule/20100323/location_1987_route_index_0.html
158
+ - test/fixtures/mobile_stop_schedule/20100323/location_1987_route_index_1.html
159
+ - test/fixtures/mobile_stop_schedule/20100323/location_1987_route_index_2.html
160
+ - test/fixtures/mobile_stop_schedule/20100323/location_3058_route_index_12.html
161
+ - test/fixtures/mobile_stop_schedule/20100323/location_7558_route_index_0.html
162
+ - test/fixtures/mobile_stop_schedule/20100323/location_8789_route_index_0.html
163
+ - test/fixtures/stop_resource/1987.html
164
+ - test/test_helper.rb
165
+ - test/unit/headsign_test.rb
166
+ - test/unit/lingo_test.rb
167
+ - test/unit/mobile_resource_methods_test.rb
168
+ - test/unit/mobile_route_data_test.rb
169
+ - test/unit/mobile_route_schedule_test.rb
170
+ - test/unit/mobile_stop_schedule_test.rb
171
+ - test/unit/service_date_test.rb
172
+ - test/unit/stop_resource_test.rb
173
+ homepage: http://github.com/craigdavey/octranspo
174
+ licenses: []
175
+
176
+ post_install_message:
177
+ rdoc_options: []
178
+
179
+ require_paths:
180
+ - lib
181
+ required_ruby_version: !ruby/object:Gem::Requirement
182
+ none: false
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ hash: 3
187
+ segments:
188
+ - 0
189
+ version: "0"
190
+ required_rubygems_version: !ruby/object:Gem::Requirement
191
+ none: false
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ hash: 3
196
+ segments:
197
+ - 0
198
+ version: "0"
199
+ requirements: []
200
+
201
+ rubyforge_project:
202
+ rubygems_version: 1.8.15
203
+ signing_key:
204
+ specification_version: 3
205
+ summary: OC Transpo tools.
206
+ test_files:
207
+ - test/fixtures/mobile_route_data/20090323/route_123_index_0.html
208
+ - test/fixtures/mobile_route_data/20090323/route_123_index_1.html
209
+ - test/fixtures/mobile_route_data/20090323/route_1_index_0.html
210
+ - test/fixtures/mobile_route_data/20090323/route_1_index_1.html
211
+ - test/fixtures/mobile_route_data/20090323/route_2_index_0.html
212
+ - test/fixtures/mobile_route_data/20090323/route_2_index_1.html
213
+ - test/fixtures/mobile_route_data/20100323/route_123_index_0.html
214
+ - test/fixtures/mobile_route_data/20100323/route_123_index_1.html
215
+ - test/fixtures/mobile_route_data/20100323/route_1_index_0.html
216
+ - test/fixtures/mobile_route_data/20100323/route_1_index_1.html
217
+ - test/fixtures/mobile_route_data/20100323/route_2_index_0.html
218
+ - test/fixtures/mobile_route_data/20100323/route_2_index_1.html
219
+ - test/fixtures/mobile_route_data/20100323/route_3_index_0.html
220
+ - test/fixtures/mobile_route_data/20100323/route_3_index_1.html
221
+ - test/fixtures/mobile_route_schedule/20090323/route_18_direction_2_location_25.html
222
+ - test/fixtures/mobile_route_schedule/20090323/route_1_direction_1_location_0.html
223
+ - test/fixtures/mobile_route_schedule/20090323/route_2_direction_2_location_11.html
224
+ - test/fixtures/mobile_route_schedule/20090323/route_2_direction__location_11.html
225
+ - test/fixtures/mobile_route_schedule/20100323/route_1_direction_1_location_0.html
226
+ - test/fixtures/mobile_route_schedule/20100323/route_2_direction_2_location_11.html
227
+ - test/fixtures/mobile_route_schedule/20100323/route_3_direction_1_location_0.html
228
+ - test/fixtures/mobile_route_schedule/20100323/route_3_direction_1_location_1.html
229
+ - test/fixtures/mobile_stop_schedule/20090323/location_1987.yml
230
+ - test/fixtures/mobile_stop_schedule/20090323/location_1987_route_index_0.html
231
+ - test/fixtures/mobile_stop_schedule/20090323/location_1987_route_index_1.html
232
+ - test/fixtures/mobile_stop_schedule/20090323/location_1987_route_index_2.html
233
+ - test/fixtures/mobile_stop_schedule/20090323/location_3058_route_index_12.html
234
+ - test/fixtures/mobile_stop_schedule/20090323/location_8789_route_index_0.html
235
+ - test/fixtures/mobile_stop_schedule/20100323/location_1987.yml
236
+ - test/fixtures/mobile_stop_schedule/20100323/location_1987_route_index_0.html
237
+ - test/fixtures/mobile_stop_schedule/20100323/location_1987_route_index_1.html
238
+ - test/fixtures/mobile_stop_schedule/20100323/location_1987_route_index_2.html
239
+ - test/fixtures/mobile_stop_schedule/20100323/location_3058_route_index_12.html
240
+ - test/fixtures/mobile_stop_schedule/20100323/location_7558_route_index_0.html
241
+ - test/fixtures/mobile_stop_schedule/20100323/location_8789_route_index_0.html
242
+ - test/fixtures/stop_resource/1987.html
243
+ - test/test_helper.rb
244
+ - test/unit/headsign_test.rb
245
+ - test/unit/lingo_test.rb
246
+ - test/unit/mobile_resource_methods_test.rb
247
+ - test/unit/mobile_route_data_test.rb
248
+ - test/unit/mobile_route_schedule_test.rb
249
+ - test/unit/mobile_stop_schedule_test.rb
250
+ - test/unit/service_date_test.rb
251
+ - test/unit/stop_resource_test.rb