traffic_light_controller 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  coverage/
2
2
  pkg/
3
3
  spec/reports
4
+ Gemfile.lock
data/Gemfile CHANGED
@@ -3,19 +3,15 @@ source :rubygems
3
3
  gemspec
4
4
 
5
5
  group :development do
6
- gem "guard"
7
- gem "guard-bundler"
8
- gem "guard-rspec"
9
- gem "rb-fchange", :require => false
10
- gem "rb-fsevent", :require => false
11
- gem "rb-inotify", :require => false
12
- gem "terminal-notifier-guard"
6
+ gem "rb-fchange", require: false
7
+ gem "rb-fsevent", require: false
8
+ gem "rb-inotify", require: false
13
9
  end
14
10
 
15
11
  group :test do
16
12
  gem "ci_reporter"
17
13
  gem "rake"
18
14
  gem "rspec"
19
- gem "simplecov", :require => false
15
+ gem "simplecov", require: false
20
16
  gem "simplecov-rcov"
21
17
  end
@@ -1,7 +1,12 @@
1
+ require 'command_line_helper'
2
+
1
3
  module TrafficLightController
2
4
  class CLI
5
+ include CommandLineHelper::HelpText
6
+
3
7
  class << self
4
8
  def run
9
+ change_program_name
5
10
  cli = self.new
6
11
  cli.process_command_line_options
7
12
  cli.run
@@ -13,15 +18,12 @@ module TrafficLightController
13
18
  end
14
19
 
15
20
  def process_command_line_options
16
- @options = {}
17
-
18
21
  GetoptLong.new(*options_possible).each do |opt, arg|
19
22
  case opt
20
23
  when '--help'
21
24
  show_help_and_exit
22
25
  when '--version'
23
- puts version_info
24
- exit
26
+ show_version_info_and_exit
25
27
  end
26
28
  end
27
29
  end
@@ -34,6 +36,10 @@ module TrafficLightController
34
36
 
35
37
  attr_reader :server
36
38
 
39
+ def self.change_program_name
40
+ $0 = File.basename($0) << " (#{VERSION})"
41
+ end
42
+
37
43
  def options_possible
38
44
  [
39
45
  ['--help', '-h', GetoptLong::NO_ARGUMENT],
@@ -46,57 +52,17 @@ module TrafficLightController
46
52
  exit
47
53
  end
48
54
 
49
- def help_info
50
- <<-EOH
51
- Usage: #{prog_name} [options]
52
- #{short_hand_options}
53
-
54
- Options:
55
- #{option_details}
56
- #{version_info}
57
- EOH
58
- end
59
-
60
- def prog_name
61
- File.basename($0)
62
- end
63
-
64
- def short_hand_options
65
- "[#{options_possible.map{ |o| short_hand_option(o)}.join('], [')}]"
66
- end
67
-
68
- def short_hand_option(option)
69
- if option[2] == GetoptLong::REQUIRED_ARGUMENT
70
- [option[0], option[1]].join('|') << " argument"
71
- else
72
- [option[0], option[1]].join('|')
73
- end
74
- end
75
-
76
- def option_details
77
- <<-EOO
78
- #{options_possible.map{ |o| expand_option(o) }.join("\n")}
79
- EOO
55
+ def show_version_info_and_exit
56
+ STDOUT.puts version_info
57
+ exit
80
58
  end
81
59
 
82
60
  def version_info
83
61
  <<-EOV
84
- traffic_light_controller (#{version_number})
62
+ #{program_name}
85
63
  https://github.com/jcmuller/traffic_light_controller
86
64
  (c) 2012 Juan C. Muller
87
65
  EOV
88
66
  end
89
-
90
- def version_number
91
- VERSION
92
- end
93
-
94
- def longest_width
95
- @max_width ||= options_possible.map{ |o| o[0] }.max{ |a, b| a.length <=> b.length }.length
96
- end
97
-
98
- def expand_option(option)
99
- sprintf(" %-#{longest_width + 6}s %s", option.first(2).join(', '), option[3])
100
- end
101
67
  end
102
68
  end
@@ -1,3 +1,3 @@
1
1
  module TrafficLightController
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -28,15 +28,4 @@ describe TrafficLightController::CLI do
28
28
  expect{ subject.send(:show_help_and_exit) }.to raise_error SystemExit
29
29
  end
30
30
  end
31
-
32
- describe "#help_info" do
33
- it "should return the nice string" do
34
- subject.should_receive(:prog_name)
35
- subject.should_receive(:short_hand_options)
36
- subject.should_receive(:option_details)
37
- subject.should_receive(:version_info)
38
-
39
- subject.send(:help_info)
40
- end
41
- end
42
31
  end
@@ -26,9 +26,14 @@ Gem::Specification.new do |s|
26
26
  s.add_development_dependency("pry")
27
27
  s.add_development_dependency("pry-debugger")
28
28
  s.add_development_dependency("pry-stack_explorer")
29
+ s.add_development_dependency("guard")
30
+ s.add_development_dependency("guard-bundler")
31
+ s.add_development_dependency("guard-rspec")
32
+ s.add_development_dependency("terminal-notifier-guard")
29
33
 
30
34
  s.add_dependency("sinatra")
31
35
  s.add_dependency("arduino")
32
36
  s.add_dependency("json")
33
37
  s.add_dependency("hashie")
38
+ s.add_dependency("command_line_helper")
34
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traffic_light_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-12 00:00:00.000000000 Z
12
+ date: 2012-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -75,6 +75,70 @@ dependencies:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: guard
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: guard-bundler
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: guard-rspec
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: terminal-notifier-guard
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
78
142
  - !ruby/object:Gem::Dependency
79
143
  name: sinatra
80
144
  requirement: !ruby/object:Gem::Requirement
@@ -139,6 +203,22 @@ dependencies:
139
203
  - - ! '>='
140
204
  - !ruby/object:Gem::Version
141
205
  version: '0'
206
+ - !ruby/object:Gem::Dependency
207
+ name: command_line_helper
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ type: :runtime
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
142
222
  description: ''
143
223
  email: jcmuller@gmail.com
144
224
  executables:
@@ -149,7 +229,6 @@ files:
149
229
  - .gitignore
150
230
  - .travis.yml
151
231
  - Gemfile
152
- - Gemfile.lock
153
232
  - Guardfile
154
233
  - LICENSE
155
234
  - README.md
data/Gemfile.lock DELETED
@@ -1,108 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- traffic_light_controller (0.0.5)
5
- arduino
6
- hashie
7
- json
8
- sinatra
9
-
10
- GEM
11
- remote: http://rubygems.org/
12
- specs:
13
- arduino (0.4)
14
- serialport (>= 1.0.4)
15
- binding_of_caller (0.6.8)
16
- builder (3.1.4)
17
- ci_reporter (1.7.3)
18
- builder (>= 2.1.2)
19
- coderay (1.0.8)
20
- columnize (0.3.6)
21
- debugger (1.1.4)
22
- columnize (>= 0.3.1)
23
- debugger-linecache (~> 1.1.1)
24
- debugger-ruby_core_source (~> 1.1.3)
25
- debugger-linecache (1.1.2)
26
- debugger-ruby_core_source (>= 1.1.1)
27
- debugger-ruby_core_source (1.1.4)
28
- diff-lcs (1.1.3)
29
- ffi (1.1.5)
30
- guard (1.5.4)
31
- listen (>= 0.4.2)
32
- lumberjack (>= 1.0.2)
33
- pry (>= 0.9.10)
34
- thor (>= 0.14.6)
35
- guard-bundler (1.0.0)
36
- bundler (~> 1.0)
37
- guard (~> 1.1)
38
- guard-rspec (2.1.1)
39
- guard (>= 1.1)
40
- rspec (~> 2.11)
41
- hashie (1.2.0)
42
- json (1.7.5)
43
- listen (0.5.3)
44
- lumberjack (1.0.2)
45
- method_source (0.8.1)
46
- multi_json (1.3.7)
47
- pry (0.9.10)
48
- coderay (~> 1.0.5)
49
- method_source (~> 0.8)
50
- slop (~> 3.3.1)
51
- pry-debugger (0.2.0)
52
- debugger (~> 1.1.3)
53
- pry (~> 0.9.9)
54
- pry-stack_explorer (0.4.7)
55
- binding_of_caller (~> 0.6.8)
56
- rack (1.4.1)
57
- rack-protection (1.2.0)
58
- rack
59
- rake (10.0.0)
60
- rb-fchange (0.0.6)
61
- ffi
62
- rb-fsevent (0.9.2)
63
- rb-inotify (0.8.8)
64
- ffi (>= 0.5.0)
65
- rspec (2.11.0)
66
- rspec-core (~> 2.11.0)
67
- rspec-expectations (~> 2.11.0)
68
- rspec-mocks (~> 2.11.0)
69
- rspec-core (2.11.1)
70
- rspec-expectations (2.11.3)
71
- diff-lcs (~> 1.1.3)
72
- rspec-mocks (2.11.3)
73
- serialport (1.1.0)
74
- simplecov (0.7.1)
75
- multi_json (~> 1.0)
76
- simplecov-html (~> 0.7.1)
77
- simplecov-html (0.7.1)
78
- simplecov-rcov (0.2.3)
79
- simplecov (>= 0.4.1)
80
- sinatra (1.3.3)
81
- rack (~> 1.3, >= 1.3.6)
82
- rack-protection (~> 1.2)
83
- tilt (~> 1.3, >= 1.3.3)
84
- slop (3.3.3)
85
- terminal-notifier-guard (1.5.3)
86
- thor (0.16.0)
87
- tilt (1.3.3)
88
-
89
- PLATFORMS
90
- ruby
91
-
92
- DEPENDENCIES
93
- ci_reporter
94
- guard
95
- guard-bundler
96
- guard-rspec
97
- pry
98
- pry-debugger
99
- pry-stack_explorer
100
- rake
101
- rb-fchange
102
- rb-fsevent
103
- rb-inotify
104
- rspec
105
- simplecov
106
- simplecov-rcov
107
- terminal-notifier-guard
108
- traffic_light_controller!