cukesparse 2.0.0 → 2.0.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/bin/cukesparse +3 -1
- data/cukesparse.gemspec +1 -1
- data/lib/cukesparse.rb +92 -73
- data/spec/cukesparse_spec.rb +15 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWIwZTAwYWE5MDU2YTZmMDE4NThjMDIzZWJmMjNmOGI4MDg4NzQyMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmNmMGY3ODFiYTI4ODRlYTI5MTc5NTI3ZGMzNTVjMTAzZGQ5OTNjOQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjRmNGQyZjhiZWJmN2JkZGU0MTg2MmUxMWI5YzJjYmE2YTlhOTlkZDQyZDky
|
10
|
+
MjAyYjc3ODA2NTI4Y2ZlNjJjNmVkNDM0ZGJiOGI4YTRmMjE4MDhhMTgyZDQw
|
11
|
+
MDRjNGFhOTdjM2Q2NDY4NzNmNDBiM2RjZmY3YWEyMjgwZjU3Yzc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTU0MDU5MDM1NWI2YzAxNGFiMmIxMjEyZWY4ZmU1YjM0MWZkMTQ5ZTc1YTYx
|
14
|
+
NjA2MmNmMWU5ZTk0YWRmZjcwMDdjMjhmMmY5Mzk3YTE0YWQ2N2YxMjFjNzhm
|
15
|
+
ODQwZWZmZGMzYTU1OTA2OTQzNTliY2U4ZGM4N2E2NjJiMDRhMDg=
|
data/bin/cukesparse
CHANGED
data/cukesparse.gemspec
CHANGED
data/lib/cukesparse.rb
CHANGED
@@ -18,52 +18,37 @@ module Cukesparse
|
|
18
18
|
ARGV
|
19
19
|
end
|
20
20
|
|
21
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
'
|
57
|
-
|
58
|
-
|
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
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
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
|
-
#
|
118
|
-
def
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
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
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
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
|
data/spec/cukesparse_spec.rb
CHANGED
@@ -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
|