cukesparse 2.0.0 → 2.0.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
- N2FkNTQ5ZjkyZWZjN2U3MmZhMTJlNjk5YWU0MjAyMTAxMTNlYmM5Zg==
4
+ NWIwZTAwYWE5MDU2YTZmMDE4NThjMDIzZWJmMjNmOGI4MDg4NzQyMw==
5
5
  data.tar.gz: !binary |-
6
- ZDQ2YmQ0YTQwMzU3N2JlOWQxYTBiMGZhZjJmYjNkMTFmMmVjMjcxOA==
6
+ YmNmMGY3ODFiYTI4ODRlYTI5MTc5NTI3ZGMzNTVjMTAzZGQ5OTNjOQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YzJlMzcxNTExYjE5OWE0ZWRmNGI2ZWIwY2QyOWViMzM2OGU1NzI3Y2E2OTgw
10
- YjU0Yjg4NmJmNThhNmE3M2IxM2EzZWM3ZjZjNmJlNGEzMDU3ZDhmMzJiODcy
11
- MTg1YTkwZDI1NDVjNGIzMTVhOThiNDFmMmE2ZDEzMzYzN2I3YTA=
9
+ ZjRmNGQyZjhiZWJmN2JkZGU0MTg2MmUxMWI5YzJjYmE2YTlhOTlkZDQyZDky
10
+ MjAyYjc3ODA2NTI4Y2ZlNjJjNmVkNDM0ZGJiOGI4YTRmMjE4MDhhMTgyZDQw
11
+ MDRjNGFhOTdjM2Q2NDY4NzNmNDBiM2RjZmY3YWEyMjgwZjU3Yzc=
12
12
  data.tar.gz: !binary |-
13
- MjA2Yjk1NjM5N2ZhMjk1NjA4MTQ0YWJiMjkwODk3YmI4NjMyYzUxN2IyZjQ1
14
- OGRjMjc4ZDdmYTVhM2U0YTE2ZjQ2YzI1MzA3ZTJiM2E5NzFiNGY5NDAxZTgx
15
- ZDJlMGFkZTlkMTM1NWU4YjU3MjczZmUxZWZkOTcxODA4NTQzODM=
13
+ OTU0MDU5MDM1NWI2YzAxNGFiMmIxMjEyZWY4ZmU1YjM0MWZkMTQ5ZTc1YTYx
14
+ NjA2MmNmMWU5ZTk0YWRmZjcwMDdjMjhmMmY5Mzk3YTE0YWQ2N2YxMjFjNzhm
15
+ ODQwZWZmZGMzYTU1OTA2OTQzNTliY2U4ZGM4N2E2NjJiMDRhMDg=
data/bin/cukesparse CHANGED
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'cukesparse'
3
- Cukesparse.load_config.parse_argv.build_command
3
+ require 'colored'
4
+
5
+ Cukesparse.execute
data/cukesparse.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'cukesparse'
3
- s.version = '2.0.0'
3
+ s.version = '2.0.1'
4
4
  s.date = '2013-06-08'
5
5
  s.summary = 'Cukesparse - cucumber command line parser'
6
6
  s.description = 'A simple command line parser to pass arguments into Cucumber'
data/lib/cukesparse.rb CHANGED
@@ -18,52 +18,37 @@ module Cukesparse
18
18
  ARGV
19
19
  end
20
20
 
21
- # Parses the options passed via command line
22
- def parse_argv
23
- begin
24
- cli argv,
25
- # Cucumber options
26
- '-t' => lambda{ |t| add_multiple(:tags, t) },
27
- '-n --name' => lambda{ |n| add_multiple(:name, n) },
28
- '-f --format' => ->(f){ @parameters[:format] = "--format #{f}" },
29
- '-d --dry-run' => ->{ @parameters[:dry_run] = "--dry-run" },
30
- '-v --verbose' => ->{ @parameters[:verbose] = "--verbose" },
31
- '-s --strict' => ->{ @parameters[:strict] = "--strict" },
32
- '-g --guess' => ->{ @parameters[:guess] = "--guess" },
33
- '-x --expand' => ->{ @parameters[:expand] = "--expand" },
34
-
35
- # All options below have been added for custom project but can be used for example
36
- # Global options
37
- '-e --environment' => ->(e){ @parameters[:environment] = "ENVIRONMENT=#{e}" },
38
- '-l --loglevel' => ->(l){ @parameters[:log_level] = "LOG_LEVEL=#{l}" },
39
- '-c --controller' => ->(c){ @parameters[:controller] = "CONTROLLER=#{c}" },
40
- '-h --headless' => ->{ @parameters[:headless] = "HEADLESS=TRUE" },
41
-
42
- # Database options
43
- '--cleanup' => ->{ @parameters[:cleanup] = "CLEANUP=TRUE" },
44
- '--no-cleanup' => ->{ @parameters[:cleanup] = "CLEANUP=FALSE" },
45
- '--database' => ->{ @parameters[:database] = "DATABASE=TRUE" },
46
- '--jenkins' => ->{ @parameters[:jenkins] = "JENKINS=TRUE" },
47
-
48
- # Retry options
49
- '--retries' => ->(r){ @parameters[:retries] = "RETRIES=#{r}" },
50
- '--timeout' => ->(t){ @parameters[:timeout] = "TIMEOUT=#{t}" },
21
+ # Add multiple options to key
22
+ #
23
+ # @param [Symbol] key the key to store in options
24
+ # @param [String] val the arguments passed in for key
25
+ def add_multiple key, val
26
+ case val
27
+ when Array
28
+ val.each do |v|
29
+ (@parameters[key] ||= []).push '--' + key.to_s + ' ' + v.to_s
30
+ end
31
+ else
32
+ (@parameters[key] ||= []).push '--' + key.to_s + ' ' + val.to_s
33
+ end
34
+ end
51
35
 
52
- # Driver Options
53
- '--screen' => ->(s){ split_parameters(s, :screen) },
54
- '--position' => ->(p){ split_parameters(p, :position) },
55
- '--screenwidth' => ->(w){ @parameters[:screen_width] = "SCREENWIDTH=#{w}" },
56
- '--screenheight' => ->(h){ @parameters[:screen_height] = "SCREENHEIGHT=#{h}" },
57
- '--xposition' => ->(x){ @parameters[:xposition] = "XPOSITION=#{x}" },
58
- '--yposition' => ->(y){ @parameters[:yposition] = "YPOSITION=#{y}" },
59
- '-H --highlight' => ->{ @parameters[:highlight] = "HIGHLIGHT=TRUE" },
36
+ # Executes cukesparse by checking arguments passed
37
+ def execute
38
+ # Check if no arguments
39
+ if argv.empty?
40
+ puts 'Cukesparse - a simple command line parser to pass arguments into Cucumber!'.yellow
41
+ return
42
+ end
60
43
 
61
- # Debug
62
- '--debug' => ->{ @parameters[:debug] = "DEBUG=TRUE" }
63
- rescue
64
- abort 'Error processing passed CLI arguments!'.red.underline
44
+ # Determine argument passed
45
+ case argv.dup.shift
46
+ when 'tasks'
47
+ load_config
48
+ puts "You have the following tasks within your config file: #{@config.keys.join(', ')}".yellow
49
+ return
65
50
  else
66
- self
51
+ load_config.parse_argv.build_command
67
52
  end
68
53
  end
69
54
 
@@ -90,6 +75,25 @@ module Cukesparse
90
75
  end
91
76
  end
92
77
 
78
+ # Checks for task in arguments
79
+ def check_for_task
80
+ task = argv & @config.keys
81
+ if task.empty?
82
+ abort 'ERROR: No task was passed to cukesparse!'.red.underline
83
+ elsif task.length > 1
84
+ puts 'WARN: Multiple tasks have been passed!'.yellow
85
+ else
86
+ @task = @config[task[0]]
87
+ end
88
+ end
89
+
90
+ # Checks parameters and returns boolean
91
+ def check_for_parameters
92
+ unless @parameters.any?
93
+ puts 'WARN: No parameters passed to cukesparse'.yellow
94
+ end
95
+ end
96
+
93
97
  # Outputs the debug information
94
98
  def debug
95
99
  puts 'DEBUG: Outputting ARGV passed'.yellow
@@ -114,22 +118,52 @@ module Cukesparse
114
118
  self
115
119
  end
116
120
 
117
- # Checks for task in arguments
118
- def check_for_task
119
- task = argv & @config.keys
120
- if task.empty?
121
- abort 'ERROR: No task was passed to cukesparse!'.red.underline
122
- elsif task.length > 1
123
- puts 'WARN: Multiple tasks have been passed!'.yellow
124
- else
125
- @task = @config[task[0]]
126
- end
127
- end
121
+ # Parses the options passed via command line
122
+ def parse_argv
123
+ begin
124
+ cli argv,
125
+ # Cucumber options
126
+ '-t' => lambda{ |t| add_multiple(:tags, t) },
127
+ '-n --name' => lambda{ |n| add_multiple(:name, n) },
128
+ '-f --format' => ->(f){ @parameters[:format] = "--format #{f}" },
129
+ '-d --dry-run' => ->{ @parameters[:dry_run] = "--dry-run" },
130
+ '-v --verbose' => ->{ @parameters[:verbose] = "--verbose" },
131
+ '-s --strict' => ->{ @parameters[:strict] = "--strict" },
132
+ '-g --guess' => ->{ @parameters[:guess] = "--guess" },
133
+ '-x --expand' => ->{ @parameters[:expand] = "--expand" },
128
134
 
129
- # Checks parameters and returns boolean
130
- def check_for_parameters
131
- unless @parameters.any?
132
- puts 'WARN: No parameters passed to cukesparse'.yellow
135
+ # All options below have been added for custom project but can be used for example
136
+ # Global options
137
+ '-e --environment' => ->(e){ @parameters[:environment] = "ENVIRONMENT=#{e}" },
138
+ '-l --loglevel' => ->(l){ @parameters[:log_level] = "LOG_LEVEL=#{l}" },
139
+ '-c --controller' => ->(c){ @parameters[:controller] = "CONTROLLER=#{c}" },
140
+ '-h --headless' => ->{ @parameters[:headless] = "HEADLESS=TRUE" },
141
+
142
+ # Database options
143
+ '--cleanup' => ->{ @parameters[:cleanup] = "CLEANUP=TRUE" },
144
+ '--no-cleanup' => ->{ @parameters[:cleanup] = "CLEANUP=FALSE" },
145
+ '--database' => ->{ @parameters[:database] = "DATABASE=TRUE" },
146
+ '--jenkins' => ->{ @parameters[:jenkins] = "JENKINS=TRUE" },
147
+
148
+ # Retry options
149
+ '--retries' => ->(r){ @parameters[:retries] = "RETRIES=#{r}" },
150
+ '--timeout' => ->(t){ @parameters[:timeout] = "TIMEOUT=#{t}" },
151
+
152
+ # Driver Options
153
+ '--screen' => ->(s){ split_parameters(s, :screen) },
154
+ '--position' => ->(p){ split_parameters(p, :position) },
155
+ '--screenwidth' => ->(w){ @parameters[:screen_width] = "SCREENWIDTH=#{w}" },
156
+ '--screenheight' => ->(h){ @parameters[:screen_height] = "SCREENHEIGHT=#{h}" },
157
+ '--xposition' => ->(x){ @parameters[:xposition] = "XPOSITION=#{x}" },
158
+ '--yposition' => ->(y){ @parameters[:yposition] = "YPOSITION=#{y}" },
159
+ '-H --highlight' => ->{ @parameters[:highlight] = "HIGHLIGHT=TRUE" },
160
+
161
+ # Debug
162
+ '--debug' => ->{ @parameters[:debug] = "DEBUG=TRUE" }
163
+ rescue
164
+ abort 'Error processing passed CLI arguments!'.red.underline
165
+ else
166
+ self
133
167
  end
134
168
  end
135
169
 
@@ -179,21 +213,6 @@ module Cukesparse
179
213
  end
180
214
  end
181
215
 
182
- # Add multiple options to key
183
- #
184
- # @param [Symbol] key the key to store in options
185
- # @param [String] val the arguments passed in for key
186
- def add_multiple key, val
187
- case val
188
- when Array
189
- val.each do |v|
190
- (@parameters[key] ||= []).push '--' + key.to_s + ' ' + v.to_s
191
- end
192
- else
193
- (@parameters[key] ||= []).push '--' + key.to_s + ' ' + val.to_s
194
- end
195
- end
196
-
197
216
  # Splits parameters passed
198
217
  #
199
218
  # @param [String] params the parameters passed
@@ -33,6 +33,21 @@ describe "cukesparse" do
33
33
  end
34
34
  end
35
35
 
36
+ context "when called with no argument" do
37
+ it "should display a cukesparse information message" do
38
+ Cukesparse.should_receive("puts").with("\e[0;33;49mCukesparse - a simple command line parser to pass arguments into Cucumber!\e[0m")
39
+ Cukesparse.execute
40
+ end
41
+ end
42
+
43
+ context "when called with the task argument" do
44
+ it "should display the tasks within the config file" do
45
+ ARGV.push('tasks')
46
+ Cukesparse.should_receive("puts").with("\e[0;33;49mYou have the following tasks within your config file: test_task\e[0m")
47
+ Cukesparse.execute
48
+ end
49
+ end
50
+
36
51
  # Parameters
37
52
  context "when passed the -t parameter" do
38
53
  before :all do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cukesparse
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Chrisp