route_c 0.2.0 → 0.2.1
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.
- checksums.yaml +8 -8
- data/config/config.yaml +20 -0
- data/lib/route_c/cli.rb +8 -2
- data/lib/route_c/query.rb +29 -1
- data/lib/route_c/version.rb +1 -1
- data/route_c.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MThmMDFmN2QyYjc2YWNkZDc4Nzg0ZjIyNTExMTM3ODMzMGY5NTg4Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDc2OTNjMTRiOGNkZjBmYzFjODA3NmExMGNjYTkyYzdjNzdkNTA3NQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjJhNGRhNGFkMGJkMjBkYTczMTllZjhlMGVhM2IwNDZhOTViOGUxMjNiOTE1
|
10
|
+
NjA2MDgyZTVhMTVmYTEwZjhiNWU0NGQzNTQ5NzU3ZmM1YTQzZmIxNzEwYzBm
|
11
|
+
MGIyYzIzNWY5MWQ0MmNiY2Y4NzU0MDkxMzc1YWI1NWU0NjQ0MmU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjIwOGZlNGQwOWQwMmM2ZjY4ZmUwNTM4NjIyNTBlN2NhYzE4MDAzMmE3Yzkw
|
14
|
+
NjlmYzMyYjFkMmY5OTM5NmE0Nzg1MTRhZTJiZThjOTdiNjRmNTMwNTJiZDAz
|
15
|
+
NTljZGFmYzk0Nzg1OTk1YWYxOWQyZDk2NzJiODcyODdiMGFhNjQ=
|
data/config/config.yaml
CHANGED
@@ -14,3 +14,23 @@ lights:
|
|
14
14
|
button: 21
|
15
15
|
station: euston
|
16
16
|
direction: southbound
|
17
|
+
|
18
|
+
valid_stations:
|
19
|
+
|
20
|
+
stations:
|
21
|
+
- walthamstow_central
|
22
|
+
- blackhorse_road
|
23
|
+
- tottenham_hale
|
24
|
+
- seven_sisters
|
25
|
+
- finsbury_park
|
26
|
+
- highbury_and_islington
|
27
|
+
- kings_cross_st_pancras
|
28
|
+
- euston
|
29
|
+
- warren_street
|
30
|
+
- oxford_circus
|
31
|
+
- green_park
|
32
|
+
- victoria
|
33
|
+
- pimlico
|
34
|
+
- vauxhall
|
35
|
+
- stockwell
|
36
|
+
- brixton
|
data/lib/route_c/cli.rb
CHANGED
@@ -9,7 +9,7 @@ module RouteC
|
|
9
9
|
end
|
10
10
|
map %w(-v --version) => :version
|
11
11
|
|
12
|
-
desc 'lights', 'Show lights for station and direction'
|
12
|
+
desc 'lights <STATION> <DIRECTION> [--datetime]', 'Show lights for station and direction'
|
13
13
|
method_option :time,
|
14
14
|
type: :string,
|
15
15
|
default: '2015-09-23T18:00',
|
@@ -21,7 +21,13 @@ module RouteC
|
|
21
21
|
desc: 'Dump output to console (instead of LEDs)'
|
22
22
|
|
23
23
|
def lights station, direction
|
24
|
-
|
24
|
+
begin
|
25
|
+
routec = RouteC::Query.new station, direction, options[:time]
|
26
|
+
rescue RouteCException => rce
|
27
|
+
puts rce.status
|
28
|
+
exit 1
|
29
|
+
end
|
30
|
+
|
25
31
|
if options['console']
|
26
32
|
puts routec.to_a.inspect
|
27
33
|
else
|
data/lib/route_c/query.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
module RouteC
|
2
2
|
class Query
|
3
3
|
def initialize(station, direction, datetime = nil)
|
4
|
-
@station
|
4
|
+
@station = Query.validate_station(station)
|
5
|
+
@direction = Query.boundify(direction)
|
6
|
+
@datetime = set_datetime(datetime)
|
7
|
+
@config = Config.new
|
5
8
|
end
|
6
9
|
|
7
10
|
def set_datetime(datetime)
|
@@ -48,5 +51,30 @@ module RouteC
|
|
48
51
|
def lights
|
49
52
|
@lights ||= Lights.new(to_a)
|
50
53
|
end
|
54
|
+
|
55
|
+
def self.boundify direction
|
56
|
+
case direction
|
57
|
+
when /^n/
|
58
|
+
'northbound'
|
59
|
+
when /^s/
|
60
|
+
'southbound'
|
61
|
+
else
|
62
|
+
raise RouteCException.new "Invalid direction '#{direction}'"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.validate_station station
|
67
|
+
s = station.downcase.gsub(' ', '_')
|
68
|
+
return s if Config.new.stations.include? s
|
69
|
+
raise RouteCException.new "Unknown station '#{station}'"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class RouteCException < Exception
|
74
|
+
attr_reader :status
|
75
|
+
|
76
|
+
def initialize status
|
77
|
+
@status = status
|
78
|
+
end
|
51
79
|
end
|
52
80
|
end
|
data/lib/route_c/version.rb
CHANGED
data/route_c.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: route_c
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pikesley
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dotenv
|
@@ -165,6 +165,20 @@ dependencies:
|
|
165
165
|
- - ~>
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0.10'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: curacao
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ! '>='
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
type: :development
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
168
182
|
description: words
|
169
183
|
email:
|
170
184
|
- ops@theodi.org
|