route_c 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDkwYTg0Y2YwMjNkNTM3NjI0NTQ1NDU1YWM1MDQyZTU4ODIzMjc4Yw==
4
+ MThmMDFmN2QyYjc2YWNkZDc4Nzg0ZjIyNTExMTM3ODMzMGY5NTg4Yg==
5
5
  data.tar.gz: !binary |-
6
- MWRlMzZjNGE4YjFiZWM0ZDg5ZjZjNjNkZjU5ZTM4NGZlZTQ2MTI4Yg==
6
+ NDc2OTNjMTRiOGNkZjBmYzFjODA3NmExMGNjYTkyYzdjNzdkNTA3NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OThhZDFhYmM4Njg3MmIwNjE4YTIwN2FmMDdmYzk4ZTc5YWNjNzJiZWI2ZTM4
10
- MjRjYzMwNTc3MGRmNzc4YjM5YzFkYmNlYTM3YWM1ODhkMmIzZWNiNDYwNjM5
11
- NGQ4NjA5NTQwZTZkNGUyNWYzNTFmZGI4ODdjMmQwODRhZDNhNzg=
9
+ NjJhNGRhNGFkMGJkMjBkYTczMTllZjhlMGVhM2IwNDZhOTViOGUxMjNiOTE1
10
+ NjA2MDgyZTVhMTVmYTEwZjhiNWU0NGQzNTQ5NzU3ZmM1YTQzZmIxNzEwYzBm
11
+ MGIyYzIzNWY5MWQ0MmNiY2Y4NzU0MDkxMzc1YWI1NWU0NjQ0MmU=
12
12
  data.tar.gz: !binary |-
13
- MTQ1MTFmYzIzOWQ0ZTU3YzM4ZjIyYTkzMjY5ZmY5NzYwZTlkOTI3YzVmMmRi
14
- ZDE2MzNiM2U5ZTJiODRiODNkZmVhYWE5ZjY4ZmU4ZTIxMzUxODRmZjY1OTkx
15
- NjAyNTVmYmI1NDU3OTYxM2JhMjRmYTAzNGNlZThlY2RjNWM1M2Y=
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
- routec = RouteC::Query.new station, direction, options[:time]
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, @direction, @datetime, @config = station, direction, set_datetime(datetime), Config.new
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
@@ -1,3 +1,3 @@
1
1
  module RouteC
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/route_c.gemspec CHANGED
@@ -31,4 +31,5 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency 'webmock', '~> 1.22'
32
32
  spec.add_development_dependency 'vcr', '~> 3.0'
33
33
  spec.add_development_dependency 'pry', '~> 0.10'
34
+ spec.add_development_dependency 'curacao' #, '~> 0.10'
34
35
  end
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.0
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-02-29 00:00:00.000000000 Z
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