octranspo 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/octranspo.rb +22 -0
- data/lib/octranspo/version.rb +1 -1
- data/octranspo.gemspec +1 -1
- data/test/unit/service_date_test.rb +6 -8
- metadata +3 -3
data/lib/octranspo.rb
CHANGED
@@ -16,5 +16,27 @@ module OCTranspo
|
|
16
16
|
autoload :Stop, "octranspo/stop"
|
17
17
|
autoload :StopResource, "octranspo/stop_resource"
|
18
18
|
autoload :VERSION, "octranspo/version"
|
19
|
+
|
20
|
+
extend OCTranspo::ServiceDate
|
21
|
+
|
22
|
+
class << self
|
23
|
+
def stop (options={})
|
24
|
+
case
|
25
|
+
when options[:number]
|
26
|
+
OCTranspo::Stop.find_by_number(options[:number])
|
27
|
+
when options[:name]
|
28
|
+
OCTranspo::Stop.find_by_name(options[:name])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def stops (options={})
|
33
|
+
case
|
34
|
+
when options[:name].is_a?(Regexp)
|
35
|
+
OCTranspo::Stop.find_all_matching(options[:name])
|
36
|
+
when options[:name]
|
37
|
+
OCTranspo::Stop.find_all_by_name(options[:name])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
19
41
|
end
|
20
42
|
|
data/lib/octranspo/version.rb
CHANGED
data/octranspo.gemspec
CHANGED
@@ -3,7 +3,7 @@ require "octranspo/version"
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "octranspo"
|
6
|
-
s.version =
|
6
|
+
s.version = OCTranspo::VERSION
|
7
7
|
s.date = "2012-01-20"
|
8
8
|
s.summary = "OC Transpo tools."
|
9
9
|
s.description = "Tools for gathering data about OC Transpo service, routes and stop locations."
|
@@ -3,8 +3,6 @@ require "#{File.dirname(File.dirname(__FILE__))}/test_helper"
|
|
3
3
|
module OCTranspo
|
4
4
|
class ServiceDateTest < ActiveSupport::TestCase
|
5
5
|
|
6
|
-
include ServiceDate
|
7
|
-
|
8
6
|
test "service_date_for" do
|
9
7
|
monday = Date.parse('Monday, September 29')
|
10
8
|
tuesday = Date.parse('Tuesday, September 30')
|
@@ -16,12 +14,12 @@ module OCTranspo
|
|
16
14
|
tuesday_at_3_am = Time.zone.parse("Tuesday, September 30 at 03:00")
|
17
15
|
tuesday_at_5_am = Time.zone.parse("Tuesday, September 30 at 05:00")
|
18
16
|
|
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)
|
17
|
+
assert_equal monday, OCTranspo.service_date_for(monday_at_8_am)
|
18
|
+
assert_equal monday, OCTranspo.service_date_for(monday_at_noon)
|
19
|
+
assert_equal monday, OCTranspo.service_date_for(monday_at_11_pm)
|
20
|
+
assert_equal monday, OCTranspo.service_date_for(tuesday_at_midnight)
|
21
|
+
assert_equal monday, OCTranspo.service_date_for(tuesday_at_3_am)
|
22
|
+
assert_equal tuesday, OCTranspo.service_date_for(tuesday_at_5_am)
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octranspo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Craig Davey
|