metra_schedule 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_stop.rb ADDED
@@ -0,0 +1,32 @@
1
+ require 'test/unit'
2
+ require File.join(File.dirname(__FILE__), "../lib", "metra")
3
+
4
+ class TestLine < Test::Unit::TestCase
5
+
6
+ def test_initialize_with_options
7
+ time = Time.now
8
+ assert_nothing_raised do
9
+ @@s = MetraSchedule::Stop.new :station => :ogilve, :time => time
10
+ end
11
+ assert_equal(time, @@s.time)
12
+ assert_equal(:ogilve, @@s.station)
13
+ end
14
+
15
+ def test_initialize_with_incomplete_options
16
+ assert_raises ArgumentError do
17
+ MetraSchedule::Stop.new :station => :ogilve
18
+ end
19
+ assert_raises ArgumentError do
20
+ MetraSchedule::Stop.new :time => Time.now
21
+ end
22
+ end
23
+
24
+ def test_is_after?
25
+ stop1 = MetraSchedule::Stop.new :station => :barrington, :time => Time.parse("12:30")
26
+ stop2 = MetraSchedule::Stop.new :station => :arlington_heights, :time => Time.parse("12:40")
27
+ assert(! stop1.is_after?(Time.parse("12:35")))
28
+ assert(stop2.is_after?(Time.parse("12:35")))
29
+ end
30
+
31
+
32
+ end
@@ -0,0 +1,54 @@
1
+ require 'test/unit'
2
+ require File.join(File.dirname(__FILE__), "../lib", "metra")
3
+
4
+ class TestLine < Test::Unit::TestCase
5
+
6
+ def test_initialize_empty_options
7
+ assert_nothing_raised do
8
+ t = MetraSchedule::Train.new
9
+ end
10
+ end
11
+
12
+ def test_initialize_one_option
13
+ assert_nothing_raised do
14
+ @@t = MetraSchedule::Train.new :train_num => 651
15
+ end
16
+ assert_equal(651, @@t.train_num)
17
+ end
18
+
19
+ def test_initialize_two_options
20
+ assert_nothing_raised do
21
+ @@t = MetraSchedule::Train.new :train_num => 651, :bike_limit => 12
22
+ end
23
+ assert_equal(651, @@t.train_num)
24
+ assert_equal(12, @@t.bike_limit)
25
+ end
26
+
27
+ def test_initialize_all_options
28
+ stop = MetraSchedule::Stop.new :station => :barrington, :time => Time.now
29
+ assert_nothing_raised do
30
+ @@t = MetraSchedule::Train.new :train_num => 651, :bike_limit => 12, :schedule => :weekday, :direction => :outbound, :stops => [stop]
31
+ end
32
+ assert_equal(651, @@t.train_num)
33
+ assert_equal(12, @@t.bike_limit)
34
+ assert_equal(:weekday, @@t.schedule)
35
+ assert_equal(:outbound, @@t.direction)
36
+ assert_equal([stop], @@t.stops)
37
+ end
38
+
39
+ def test_has_stop?
40
+ stop = MetraSchedule::Stop.new :station => :barrington, :time => Time.now
41
+ @@t = MetraSchedule::Train.new :train_num => 651, :bike_limit => 12, :schedule => :weekday, :direction => :outbound, :stops => [stop]
42
+ assert_equal(true, @@t.has_stop?(:barrington))
43
+ assert_equal(false, @@t.has_stop?(:arlington_park))
44
+ end
45
+
46
+ def test_in_time?
47
+ stop1 = MetraSchedule::Stop.new :station => :barrington, :time => Time.parse("12:30")
48
+ stop2 = MetraSchedule::Stop.new :station => :arlington_heights, :time => Time.parse("12:40")
49
+ @@t = MetraSchedule::Train.new :train_num => 651, :bike_limit => 12, :schedule => :weekday, :direction => :inbound, :stops => [stop1, stop2]
50
+ assert_equal(true, @@t.in_time?(:arlington_heights, Time.parse("12:35")))
51
+ assert_equal(false, @@t.in_time?(:barrington, Time.parse("12:35")))
52
+ end
53
+
54
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: metra_schedule
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.1"
5
+ platform: ruby
6
+ authors:
7
+ - Blake Smith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-24 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: nokogiri
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.4.1
24
+ version:
25
+ description: metra_schedule provides a ruby object interface to the Chicago metra train schedule.
26
+ email: blakesmith0@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - Rakefile
35
+ - LICENSE
36
+ - README.rdoc
37
+ - lib/metra.rb
38
+ - lib/metra/cacher.rb
39
+ - lib/metra/classmethods.rb
40
+ - lib/metra/line.rb
41
+ - lib/metra/parser.rb
42
+ - lib/metra/stop.rb
43
+ - lib/metra/train.rb
44
+ - lib/metra/train_data.rb
45
+ - test/fixture/UP_NW.html
46
+ - test/test_cacher.rb
47
+ - test/test_line.rb
48
+ - test/test_metra.rb
49
+ - test/test_parser.rb
50
+ - test/test_stop.rb
51
+ - test/test_train.rb
52
+ has_rdoc: true
53
+ homepage: http://github.com/blakesmith/metra_schedule
54
+ licenses: []
55
+
56
+ post_install_message:
57
+ rdoc_options: []
58
+
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ version:
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: "0"
72
+ version:
73
+ requirements: []
74
+
75
+ rubyforge_project:
76
+ rubygems_version: 1.3.5
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: metra_schedule provides a ruby object interface to the Chicago metra train schedule.
80
+ test_files: []
81
+