sg_mrt 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.markdown +36 -0
- data/Rakefile +10 -0
- data/data/ccl.yml +65 -0
- data/data/ewl.yml +67 -0
- data/data/nel.yml +36 -0
- data/data/nsl.yml +55 -0
- data/lib/sg_mrt.rb +163 -0
- data/lib/sg_mrt/version.rb +3 -0
- data/sg_mrt.gemspec +22 -0
- data/spec/sg_mrt_spec.rb +97 -0
- data/spec/spec_helper.rb +7 -0
- metadata +73 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# SgMRT
|
2
|
+
|
3
|
+
**SgMRT** is a collection of Singapore's MRT Lines and Stations for use in Ruby. This tiny gem's data is taken from [List of Singapore MRT stations](http://en.wikipedia.org/wiki/List_of_Singapore_MRT_stations)
|
4
|
+
|
5
|
+
### Usage:
|
6
|
+
|
7
|
+
# Get all MRT Lines
|
8
|
+
SgMRT::Line.all # => [<SgMRT::Line @name='North East Line' @code='nsl' @stations=[...]>]
|
9
|
+
|
10
|
+
# Get all MRT Stations
|
11
|
+
SgMRT::Station.all # => [<SgMRT::Station @name='Paya Lebar' @codes=[...]>]
|
12
|
+
|
13
|
+
# Find a station by name
|
14
|
+
SgMRT::Station.find_by_name('City Hall') # => <SgMRT::Station @name='City Hall', @codes=[...]>
|
15
|
+
|
16
|
+
# Find station by code
|
17
|
+
SgMRT::Station.find_by_code('EW13') # => <SgMRT::Station @name='City Hall', @codes=[...]>
|
18
|
+
|
19
|
+
See specs for more usage examples.
|
20
|
+
|
21
|
+
### Todos:
|
22
|
+
|
23
|
+
* Provide support for rails
|
24
|
+
|
25
|
+
## License
|
26
|
+
(The MIT License)
|
27
|
+
|
28
|
+
Copyright © 2012 Tors Dalid
|
29
|
+
|
30
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
31
|
+
|
32
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
33
|
+
|
34
|
+
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
35
|
+
|
36
|
+
|
data/Rakefile
ADDED
data/data/ccl.yml
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
---
|
2
|
+
name: Circle Line
|
3
|
+
code: CCL
|
4
|
+
stations:
|
5
|
+
- - Dhoby Ghaut
|
6
|
+
- CC2
|
7
|
+
- - Esplanade
|
8
|
+
- CC3
|
9
|
+
- - Promenade
|
10
|
+
- CC4
|
11
|
+
- - Nicoll Highway
|
12
|
+
- CC5
|
13
|
+
- - Stadium
|
14
|
+
- CC6
|
15
|
+
- - Mountbatten
|
16
|
+
- CC7
|
17
|
+
- - Dakota
|
18
|
+
- CC8
|
19
|
+
- - Paya Lebar
|
20
|
+
- CC9
|
21
|
+
- - MacPherson
|
22
|
+
- CC10
|
23
|
+
- - Tai Seng
|
24
|
+
- CC11
|
25
|
+
- - Bartley
|
26
|
+
- CC12
|
27
|
+
- - Serangoon
|
28
|
+
- CC13
|
29
|
+
- - Lorong Chuan
|
30
|
+
- CC14
|
31
|
+
- - Bishan
|
32
|
+
- CC15
|
33
|
+
- - Marymount
|
34
|
+
- CC16
|
35
|
+
- - Caldecott
|
36
|
+
- CC17
|
37
|
+
- - Bukit Brown
|
38
|
+
- CC18
|
39
|
+
- - Botanic Gardens
|
40
|
+
- CC19
|
41
|
+
- - Farrer Road
|
42
|
+
- CC20
|
43
|
+
- - Holland Village
|
44
|
+
- CC21
|
45
|
+
- - Buona Vista
|
46
|
+
- CC22
|
47
|
+
- - One-north
|
48
|
+
- CC23
|
49
|
+
- - Kent Ridge
|
50
|
+
- CC24
|
51
|
+
- - Haw Par Villa
|
52
|
+
- CC25
|
53
|
+
- - Pasir Panjang
|
54
|
+
- CC26
|
55
|
+
- - Labrador Park
|
56
|
+
- CC27
|
57
|
+
- - Telok Blangah
|
58
|
+
- CC28
|
59
|
+
- - HarbourFront
|
60
|
+
- CC29
|
61
|
+
# CCLe
|
62
|
+
- - Bayfront
|
63
|
+
- CE1
|
64
|
+
- - Marina Bay
|
65
|
+
- CE2
|
data/data/ewl.yml
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
---
|
2
|
+
name: East West Line
|
3
|
+
code: EWL
|
4
|
+
stations:
|
5
|
+
- - Pasir Ris
|
6
|
+
- EW1
|
7
|
+
- - Tampines
|
8
|
+
- EW2
|
9
|
+
- - Simei
|
10
|
+
- EW3
|
11
|
+
- - Tanah Merah
|
12
|
+
- EW4[8]
|
13
|
+
- - Bedok
|
14
|
+
- EW5
|
15
|
+
- - Kembangan
|
16
|
+
- EW6
|
17
|
+
- - Eunos
|
18
|
+
- EW7
|
19
|
+
- - Paya Lebar
|
20
|
+
- EW8
|
21
|
+
- - Aljunied
|
22
|
+
- EW9
|
23
|
+
- - Kallang
|
24
|
+
- EW10
|
25
|
+
- - Lavender
|
26
|
+
- EW11
|
27
|
+
- - Bugis
|
28
|
+
- EW12
|
29
|
+
- - City Hall
|
30
|
+
- EW13
|
31
|
+
- - Raffles Place
|
32
|
+
- EW14
|
33
|
+
- - Tanjong Pagar
|
34
|
+
- EW15
|
35
|
+
- - Outram Park
|
36
|
+
- EW16
|
37
|
+
- - Tiong Bahru
|
38
|
+
- EW17
|
39
|
+
- - Redhill
|
40
|
+
- EW18
|
41
|
+
- - Queenstown
|
42
|
+
- EW19
|
43
|
+
- - Commonwealth
|
44
|
+
- EW20
|
45
|
+
- - Buona Vista
|
46
|
+
- EW21
|
47
|
+
- - Dover
|
48
|
+
- EW22
|
49
|
+
- - Clementi
|
50
|
+
- EW23
|
51
|
+
- - Jurong East
|
52
|
+
- EW24
|
53
|
+
- - Chinese Garden
|
54
|
+
- EW25
|
55
|
+
- - Lakeside
|
56
|
+
- EW26
|
57
|
+
- - Boon Lay
|
58
|
+
- EW27
|
59
|
+
- - Pioneer
|
60
|
+
- EW28
|
61
|
+
- - Joo Koon
|
62
|
+
- EW29
|
63
|
+
# CGL
|
64
|
+
- - Expo
|
65
|
+
- CG1
|
66
|
+
- - Changi Airport
|
67
|
+
- CG2
|
data/data/nel.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
name: North East Line
|
3
|
+
code: NEL
|
4
|
+
stations:
|
5
|
+
- - HarbourFront
|
6
|
+
- NE1
|
7
|
+
- - Outram Park
|
8
|
+
- NE3
|
9
|
+
- - Chinatown
|
10
|
+
- NE4
|
11
|
+
- - Clarke Quay
|
12
|
+
- NE5
|
13
|
+
- - Dhoby Ghaut
|
14
|
+
- NE6
|
15
|
+
- - Little India
|
16
|
+
- NE7
|
17
|
+
- - Farrer Park
|
18
|
+
- NE8
|
19
|
+
- - Boon Keng
|
20
|
+
- NE9
|
21
|
+
- - Potong Pasir
|
22
|
+
- NE10
|
23
|
+
- - Woodleigh
|
24
|
+
- NE11
|
25
|
+
- - Serangoon
|
26
|
+
- NE12
|
27
|
+
- - Kovan
|
28
|
+
- NE13
|
29
|
+
- - Hougang
|
30
|
+
- NE14
|
31
|
+
- - Buangkok
|
32
|
+
- NE15
|
33
|
+
- - Sengkang
|
34
|
+
- NE16
|
35
|
+
- - Punggol
|
36
|
+
- NE17
|
data/data/nsl.yml
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
---
|
2
|
+
name: North East Line
|
3
|
+
code: NSL
|
4
|
+
stations:
|
5
|
+
- - Jurong East
|
6
|
+
- NS1
|
7
|
+
- - Bukit Batok
|
8
|
+
- NS2
|
9
|
+
- - Bukit Gombak
|
10
|
+
- NS3
|
11
|
+
- - Choa Chu Kang
|
12
|
+
- NS4
|
13
|
+
- - Yew Tee
|
14
|
+
- NS5
|
15
|
+
- - Kranji
|
16
|
+
- NS7
|
17
|
+
- - Marsiling
|
18
|
+
- NS8
|
19
|
+
- - Woodlands
|
20
|
+
- NS9
|
21
|
+
- - Admiralty
|
22
|
+
- NS10
|
23
|
+
- - Sembawang
|
24
|
+
- NS11
|
25
|
+
- - Yishun
|
26
|
+
- NS13
|
27
|
+
- - Khatib
|
28
|
+
- NS14
|
29
|
+
- - Yio Chu Kang
|
30
|
+
- NS15
|
31
|
+
- - Ang Mo Kio
|
32
|
+
- NS16
|
33
|
+
- - Bishan
|
34
|
+
- NS17
|
35
|
+
- - Braddell
|
36
|
+
- NS18
|
37
|
+
- - Toa Payoh
|
38
|
+
- NS19
|
39
|
+
- - Novena
|
40
|
+
- NS20
|
41
|
+
- - Newton
|
42
|
+
- NS21
|
43
|
+
- - Orchard
|
44
|
+
- NS22
|
45
|
+
- - Somerset
|
46
|
+
- NS23
|
47
|
+
- - Dhoby Ghaut
|
48
|
+
- NS24
|
49
|
+
- - City Hall
|
50
|
+
- NS25
|
51
|
+
- - Raffles Place
|
52
|
+
- NS26
|
53
|
+
- - Marina Bay
|
54
|
+
- NS27
|
55
|
+
|
data/lib/sg_mrt.rb
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
##
|
5
|
+
# SgMRT is a collection of Singapore's MRT Lines and Stations for use in Ruby.
|
6
|
+
# The list of Singapore MRT Stations is taken from:
|
7
|
+
#
|
8
|
+
# http://en.wikipedia.org/wiki/List_of_Singapore_MRT_stations
|
9
|
+
#
|
10
|
+
# Usage:
|
11
|
+
#
|
12
|
+
# # Get all MRT Lines
|
13
|
+
# SgMRT::Line.all # => [<SgMRT::Line @name='North East Line' @code='nsl' @stations=[...]>]
|
14
|
+
#
|
15
|
+
# # Get all MRT Stations
|
16
|
+
# SgMRT::Station.all # => [<SgMRT::Station @name='Paya Lebar' @codes=[...]>]
|
17
|
+
#
|
18
|
+
# # Find a station by name
|
19
|
+
# SgMRT::Station.find_by_name('City Hall') # => <SgMRT::Station @name='City Hall', @codes=[...]>
|
20
|
+
#
|
21
|
+
# # Find station by code
|
22
|
+
# SgMRT::Station.find_by_code('EW13') # => <SgMRT::Station @name='City Hall', @codes=[...]>
|
23
|
+
#
|
24
|
+
module SgMRT
|
25
|
+
|
26
|
+
DATA_PATH = File.join(File.dirname(__FILE__), '..', 'data')
|
27
|
+
|
28
|
+
@@data = {}
|
29
|
+
|
30
|
+
class << self
|
31
|
+
|
32
|
+
##
|
33
|
+
# Load all files from the data path
|
34
|
+
#
|
35
|
+
def load_data
|
36
|
+
|
37
|
+
@@data[:stations] = []
|
38
|
+
@@data[:lines] = []
|
39
|
+
|
40
|
+
find_station = lambda do |name|
|
41
|
+
@@data[:stations].find{|x| x.name == name} || Station.new(name)
|
42
|
+
end
|
43
|
+
|
44
|
+
Dir[File.join(DATA_PATH, '*.yml')].each do |file_name|
|
45
|
+
if mrt = YAML.load_file(file_name)
|
46
|
+
mrt_name = mrt['name']
|
47
|
+
mrt_code = mrt['code']
|
48
|
+
mrt_stations = mrt['stations']
|
49
|
+
line = Line.new(mrt_code)
|
50
|
+
line.name = mrt_name
|
51
|
+
mrt_stations.each do |station|
|
52
|
+
station_name, station_code = station
|
53
|
+
new_station = find_station.call(station_name)
|
54
|
+
new_station.codes << station_code
|
55
|
+
new_station.lines << line.code
|
56
|
+
line.stations << new_station
|
57
|
+
@@data[:stations] << new_station
|
58
|
+
end
|
59
|
+
@@data[:lines] << line
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
Station.define_helpers(@@data[:lines].collect(&:code))
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
def lines
|
68
|
+
load_data if @@data.empty?
|
69
|
+
@@data[:lines]
|
70
|
+
end
|
71
|
+
|
72
|
+
def stations
|
73
|
+
load_data if @@data.empty?
|
74
|
+
@@data[:stations]
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
class Line
|
80
|
+
attr_accessor :stations, :code, :name
|
81
|
+
|
82
|
+
def initialize(code = nil)
|
83
|
+
@code = code
|
84
|
+
@stations = []
|
85
|
+
end
|
86
|
+
|
87
|
+
def to_json
|
88
|
+
hash = {}
|
89
|
+
hash[:code] = @code
|
90
|
+
hash[:name] = @name
|
91
|
+
hash[:stations] = @stations.inject([]) do |ret_station_array, station|
|
92
|
+
station_hash = {}
|
93
|
+
station_hash[:name] = station.name
|
94
|
+
station_hash[:codes] = station.codes
|
95
|
+
ret_station_array << station_hash
|
96
|
+
end
|
97
|
+
hash.to_json
|
98
|
+
end
|
99
|
+
|
100
|
+
class << self
|
101
|
+
|
102
|
+
def all
|
103
|
+
SgMRT.lines
|
104
|
+
end
|
105
|
+
|
106
|
+
def find_by_code(code)
|
107
|
+
all.find{ |x| x.code == code}
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
class Station
|
114
|
+
attr_accessor :name, :lines, :codes
|
115
|
+
@@cache = {}
|
116
|
+
|
117
|
+
def initialize(name, code = nil)
|
118
|
+
@name = name
|
119
|
+
@lines = []
|
120
|
+
@codes = []
|
121
|
+
@codes << code if code
|
122
|
+
end
|
123
|
+
|
124
|
+
class << self
|
125
|
+
|
126
|
+
def all
|
127
|
+
SgMRT.stations
|
128
|
+
end
|
129
|
+
|
130
|
+
def find_by_name(name)
|
131
|
+
@@cache[name] ||= all.find{|x| x.name == name}
|
132
|
+
end
|
133
|
+
|
134
|
+
def find_by_code(code)
|
135
|
+
@@cache[code] ||= all.find{|x| x.codes.include?(code)}
|
136
|
+
end
|
137
|
+
|
138
|
+
def cached
|
139
|
+
@@cache
|
140
|
+
end
|
141
|
+
|
142
|
+
##
|
143
|
+
# Defines line helpers
|
144
|
+
#
|
145
|
+
# Example:
|
146
|
+
#
|
147
|
+
# station = Station.find_by_code('EW13')
|
148
|
+
# station.ewl? # => true
|
149
|
+
#
|
150
|
+
def define_helpers(meths)
|
151
|
+
meths.each do |code|
|
152
|
+
define_method("#{code.downcase}?") do
|
153
|
+
@lines.include?(code.upcase)
|
154
|
+
end
|
155
|
+
|
156
|
+
define_method("#{code}?") do
|
157
|
+
@lines.include?(code.upcase)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
data/sg_mrt.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "sg_mrt/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "sg_mrt"
|
7
|
+
s.version = SgMRT::VERSION
|
8
|
+
s.authors = ["Tors Dalid"]
|
9
|
+
s.email = ["cletedalid@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Singapore MRT Stations for Ruby}
|
12
|
+
s.description = %q{Collection of Singapore MRT Stations for use in Ruby}
|
13
|
+
|
14
|
+
s.required_rubygems_version = '>= 1.3.6'
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_development_dependency('minitest', ["= 2.10.1"])
|
21
|
+
|
22
|
+
end
|
data/spec/sg_mrt_spec.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SgMRT do
|
4
|
+
|
5
|
+
describe SgMRT::Line do
|
6
|
+
|
7
|
+
describe 'class methods' do
|
8
|
+
it 'should get all MRT Lines' do
|
9
|
+
SgMRT::Line.all.size.must_equal 4
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should be able to find an MRT line by code' do
|
13
|
+
SgMRT::Line.find_by_code('NSL').instance_of?(SgMRT::Line)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should return nil for searching non existing MRT code' do
|
17
|
+
SgMRT::Line.find_by_code('ABC').must_equal nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'attributes' do
|
22
|
+
|
23
|
+
before do
|
24
|
+
@line = SgMRT::Line.find_by_code('EWL')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should have a name' do
|
28
|
+
@line.name.must_equal 'East West Line'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should have a code' do
|
32
|
+
@line.code.must_equal 'EWL'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should have stations' do
|
36
|
+
@line.stations.any?.must_equal true
|
37
|
+
end
|
38
|
+
|
39
|
+
# it 'should be json serializable' do
|
40
|
+
# begin
|
41
|
+
# @line.to_json == "{\"code\":\"EWL\",\"name\":\"East West Line\",\"stations\":[{\"name\":\"Pasir Ris\",\"codes\":[\"EW1\"]},{\"name\":\"Tampines\",\"codes\":[\"EW2\"]},{\"name\":\"Simei\",\"codes\":[\"EW3\"]},{\"name\":\"Tanah Merah\",\"codes\":[\"EW4[8]\"]},{\"name\":\"Bedok\",\"codes\":[\"EW5\"]},{\"name\":\"Kembangan\",\"codes\":[\"EW6\"]},{\"name\":\"Eunos\",\"codes\":[\"EW7\"]},{\"name\":\"Paya Lebar\",\"codes\":[\"EW8\"]},{\"name\":\"Aljunied\",\"codes\":[\"EW9\"]},{\"name\":\"Kallang\",\"codes\":[\"EW10\"]},{\"name\":\"Lavender\",\"codes\":[\"EW11\"]},{\"name\":\"Bugis\",\"codes\":[\"EW12\"]},{\"name\":\"City Hall\",\"codes\":[\"EW13\",\"NS25\"]},{\"name\":\"Raffles Place\",\"codes\":[\"EW14\",\"NS26\"]},{\"name\":\"Tanjong Pagar\",\"codes\":[\"EW15\"]},{\"name\":\"Outram Park\",\"codes\":[\"EW16\"]},{\"name\":\"Tiong Bahru\",\"codes\":[\"EW17\"]},{\"name\":\"Redhill\",\"codes\":[\"EW18\"]},{\"name\":\"Queenstown\",\"codes\":[\"EW19\"]},{\"name\":\"Commonwealth\",\"codes\":[\"EW20\"]},{\"name\":\"Buona Vista\",\"codes\":[\"EW21\"]},{\"name\":\"Dover\",\"codes\":[\"EW22\"]},{\"name\":\"Clementi\",\"codes\":[\"EW23\"]},{\"name\":\"Jurong East\",\"codes\":[\"EW24\",\"NS1\"]},{\"name\":\"Chinese Garden\",\"codes\":[\"EW25\"]},{\"name\":\"Lakeside\",\"codes\":[\"EW26\"]},{\"name\":\"Boon Lay\",\"codes\":[\"EW27\"]},{\"name\":\"Pioneer\",\"codes\":[\"EW28\"]},{\"name\":\"Joo Koon\",\"codes\":[\"EW29\"]}]}"
|
42
|
+
# end.must_equal true
|
43
|
+
# end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe SgMRT::Station do
|
49
|
+
|
50
|
+
describe 'class methods' do
|
51
|
+
it 'should be able to get all stations' do
|
52
|
+
SgMRT::Station.all.any?.must_equal true
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should be able to find a station by code' do
|
56
|
+
SgMRT::Station.find_by_code('EW12').name.must_equal 'Bugis'
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should be able to find a station by name' do
|
60
|
+
SgMRT::Station.find_by_name('Bugis').codes.include?('EW12').must_equal true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'attributes' do
|
65
|
+
before do
|
66
|
+
@station = SgMRT::Station.find_by_code('EW13')
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should have a name' do
|
70
|
+
@station.name.eql?('City Hall').must_equal true
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should have the correct code' do
|
74
|
+
@station.codes.include?('EW13').must_equal true
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should check for the correct code' do
|
78
|
+
@station.ewl?.must_equal true
|
79
|
+
@station.EWL?.must_equal true
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'could have multiple codes' do
|
83
|
+
@station.ewl?.must_equal true
|
84
|
+
@station.nsl?.must_equal true
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should be cached when performing lookups' do
|
90
|
+
station = SgMRT::Station.find_by_code('EW11')
|
91
|
+
assert_equal SgMRT::Station.cached['EW11'], station
|
92
|
+
station = SgMRT::Station.find_by_name('Paya Lebar')
|
93
|
+
assert_equal SgMRT::Station.cached['Paya Lebar'], station
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sg_mrt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tors Dalid
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-08 00:00:00.000000000 +08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: minitest
|
17
|
+
requirement: &2154804880 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - =
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.10.1
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *2154804880
|
26
|
+
description: Collection of Singapore MRT Stations for use in Ruby
|
27
|
+
email:
|
28
|
+
- cletedalid@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- .gitignore
|
34
|
+
- Gemfile
|
35
|
+
- README.markdown
|
36
|
+
- Rakefile
|
37
|
+
- data/ccl.yml
|
38
|
+
- data/ewl.yml
|
39
|
+
- data/nel.yml
|
40
|
+
- data/nsl.yml
|
41
|
+
- lib/sg_mrt.rb
|
42
|
+
- lib/sg_mrt/version.rb
|
43
|
+
- sg_mrt.gemspec
|
44
|
+
- spec/sg_mrt_spec.rb
|
45
|
+
- spec/spec_helper.rb
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: ''
|
48
|
+
licenses: []
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 1.3.6
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.6.2
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: Singapore MRT Stations for Ruby
|
71
|
+
test_files:
|
72
|
+
- spec/sg_mrt_spec.rb
|
73
|
+
- spec/spec_helper.rb
|