libclimate-ruby 0.17.0 → 0.17.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 +4 -4
- data/examples/flag_and_option_specifications.from_DATA.rb +4 -4
- data/examples/flag_and_option_specifications.rb +22 -22
- data/examples/show_usage_and_version.rb +7 -7
- data/lib/libclimate/climate.rb +1000 -1000
- data/lib/libclimate/version.rb +14 -14
- data/test/scratch/blankzeroes.rb +14 -14
- data/test/scratch/specifications.rb +23 -23
- data/test/unit/tc_abort.rb +42 -42
- data/test/unit/tc_double_slash_index.rb +73 -73
- data/test/unit/tc_infer_version.rb +47 -47
- data/test/unit/tc_minimal.rb +516 -516
- data/test/unit/tc_minimal_CLASP.rb +323 -323
- data/test/unit/tc_parse.rb +104 -104
- data/test/unit/tc_parse_and_verify.rb +93 -93
- data/test/unit/tc_test_specifications.rb +48 -48
- data/test/unit/tc_values.rb +294 -294
- data/test/unit/tc_with_blocks.rb +18 -18
- data/test/unit/tc_with_blocks_CLASP.rb +18 -18
- metadata +6 -6
data/test/unit/tc_values.rb
CHANGED
@@ -12,299 +12,299 @@ require 'stringio'
|
|
12
12
|
|
13
13
|
class Test_Climate_values_constraints < Test::Unit::TestCase
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
15
|
+
def test_constrain_with_no_constraint
|
16
|
+
|
17
|
+
stdout = StringIO.new
|
18
|
+
stderr = StringIO.new
|
19
|
+
|
20
|
+
climate = LibCLImate::Climate.new do |cl|
|
21
|
+
|
22
|
+
cl.exit_on_missing = false
|
23
|
+
|
24
|
+
cl.stdout = stdout
|
25
|
+
cl.stderr = stderr
|
26
|
+
end
|
27
|
+
|
28
|
+
stdout.string = ''
|
29
|
+
stderr.string = ''
|
30
|
+
r = climate.run [ ]
|
31
|
+
assert_equal 0, r.values.size
|
32
|
+
assert_empty stdout.string
|
33
|
+
assert_empty stderr.string
|
34
|
+
|
35
|
+
stdout.string = ''
|
36
|
+
stderr.string = ''
|
37
|
+
r = climate.run [ 'value-1' ]
|
38
|
+
assert_equal 1, r.values.size
|
39
|
+
assert_empty stdout.string
|
40
|
+
assert_empty stderr.string
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_constrain_with_integer
|
44
|
+
|
45
|
+
stdout = StringIO.new
|
46
|
+
stderr = StringIO.new
|
47
|
+
|
48
|
+
climate = LibCLImate::Climate.new do |cl|
|
49
|
+
|
50
|
+
cl.exit_on_missing = false
|
51
|
+
|
52
|
+
cl.stdout = stdout
|
53
|
+
cl.stderr = stderr
|
54
|
+
|
55
|
+
cl.constrain_values = 2
|
56
|
+
end
|
57
|
+
|
58
|
+
stdout.string = ''
|
59
|
+
stderr.string = ''
|
60
|
+
r = climate.run [ ]
|
61
|
+
assert_equal 0, r.values.size
|
62
|
+
assert_empty stdout.string
|
63
|
+
assert_not_empty stderr.string
|
64
|
+
assert_match /wrong number of values.*0 given.*2 required.*/, stderr.string
|
65
|
+
|
66
|
+
stdout.string = ''
|
67
|
+
stderr.string = ''
|
68
|
+
r = climate.run [ 'value-1' ]
|
69
|
+
assert_equal 1, r.values.size
|
70
|
+
assert_empty stdout.string
|
71
|
+
assert_not_empty stderr.string
|
72
|
+
assert_match /wrong number of values.*1 given.*2 required.*/, stderr.string
|
73
|
+
|
74
|
+
stdout.string = ''
|
75
|
+
stderr.string = ''
|
76
|
+
r = climate.run [ 'value-1', 'value-2' ]
|
77
|
+
assert_equal 2, r.values.size
|
78
|
+
assert_empty stdout.string
|
79
|
+
assert_empty stderr.string
|
80
|
+
|
81
|
+
stdout.string = ''
|
82
|
+
stderr.string = ''
|
83
|
+
r = climate.run [ 'value-1', 'value-2', 'value-3' ]
|
84
|
+
assert_equal 3, r.values.size
|
85
|
+
assert_empty stdout.string
|
86
|
+
assert_not_empty stderr.string
|
87
|
+
assert_match /wrong number of values.*3 given.*2 required.*/, stderr.string
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_constrain_with_integer_and_names
|
91
|
+
|
92
|
+
stdout = StringIO.new
|
93
|
+
stderr = StringIO.new
|
94
|
+
|
95
|
+
climate = LibCLImate::Climate.new(value_attributes: true) do |cl|
|
96
|
+
|
97
|
+
cl.exit_on_missing = false
|
98
|
+
|
99
|
+
cl.stdout = stdout
|
100
|
+
cl.stderr = stderr
|
101
|
+
|
102
|
+
cl.constrain_values = 2
|
103
|
+
cl.value_names = [
|
104
|
+
|
105
|
+
'input-path',
|
106
|
+
'output-path',
|
107
|
+
]
|
108
|
+
end
|
109
|
+
|
110
|
+
stdout.string = ''
|
111
|
+
stderr.string = ''
|
112
|
+
r = climate.run [ ]
|
113
|
+
assert_equal 0, r.values.size
|
114
|
+
assert_empty stdout.string
|
115
|
+
assert_not_empty stderr.string
|
116
|
+
assert_match /input-path not specified.*#{climate.usage_help_suffix}/, stderr.string
|
117
|
+
|
118
|
+
stdout.string = ''
|
119
|
+
stderr.string = ''
|
120
|
+
r = climate.run [ 'value-1' ]
|
121
|
+
assert_equal 1, r.values.size
|
122
|
+
assert_empty stdout.string
|
123
|
+
assert_not_empty stderr.string
|
124
|
+
assert_match /output-path not specified.*#{climate.usage_help_suffix}/, stderr.string
|
125
|
+
|
126
|
+
stdout.string = ''
|
127
|
+
stderr.string = ''
|
128
|
+
r = climate.run [ 'value-1', 'value-2' ]
|
129
|
+
assert_equal 2, r.values.size
|
130
|
+
assert_empty stdout.string
|
131
|
+
assert_empty stderr.string
|
132
|
+
assert r.respond_to? :input_path
|
133
|
+
assert r.respond_to? :output_path
|
134
|
+
|
135
|
+
stdout.string = ''
|
136
|
+
stderr.string = ''
|
137
|
+
r = climate.run [ 'value-1', 'value-2', 'value-3' ]
|
138
|
+
assert_equal 3, r.values.size
|
139
|
+
assert_empty stdout.string
|
140
|
+
assert_not_empty stderr.string
|
141
|
+
assert_match /wrong number of values.*3 given.*2 required.*/, stderr.string
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_constrain_with_integer_and_names_2
|
145
|
+
|
146
|
+
stdout = StringIO.new
|
147
|
+
stderr = StringIO.new
|
148
|
+
|
149
|
+
climate = LibCLImate::Climate.new(value_attributes: true) do |cl|
|
150
|
+
|
151
|
+
cl.exit_on_missing = false
|
152
|
+
|
153
|
+
cl.stdout = stdout
|
154
|
+
cl.stderr = stderr
|
155
|
+
|
156
|
+
cl.constrain_values = 1..2
|
157
|
+
cl.value_names = [
|
158
|
+
|
159
|
+
'input-path',
|
160
|
+
'output-path',
|
161
|
+
]
|
162
|
+
end
|
163
|
+
|
164
|
+
stdout.string = ''
|
165
|
+
stderr.string = ''
|
166
|
+
r = climate.run [ ]
|
167
|
+
assert_equal 0, r.values.size
|
168
|
+
assert_empty stdout.string
|
169
|
+
assert_not_empty stderr.string
|
170
|
+
assert_match /input-path not specified.*#{climate.usage_help_suffix}/, stderr.string
|
171
|
+
|
172
|
+
stdout.string = ''
|
173
|
+
stderr.string = ''
|
174
|
+
r = climate.run [ 'value-1' ]
|
175
|
+
assert_equal 1, r.values.size
|
176
|
+
assert_empty stdout.string
|
177
|
+
assert_empty stderr.string
|
178
|
+
assert r.respond_to? :input_path
|
179
|
+
assert r.respond_to? :output_path
|
180
|
+
assert_equal 'value-1', r.input_path
|
181
|
+
assert_nil r.output_path
|
182
|
+
|
183
|
+
stdout.string = ''
|
184
|
+
stderr.string = ''
|
185
|
+
r = climate.run [ 'value-1', 'value-2' ]
|
186
|
+
assert_equal 2, r.values.size
|
187
|
+
assert_empty stdout.string
|
188
|
+
assert_empty stderr.string
|
189
|
+
assert r.respond_to? :input_path
|
190
|
+
assert r.respond_to? :output_path
|
191
|
+
assert_equal 'value-1', r.input_path
|
192
|
+
assert_equal 'value-2', r.output_path
|
193
|
+
|
194
|
+
stdout.string = ''
|
195
|
+
stderr.string = ''
|
196
|
+
r = climate.run [ 'value-1', 'value-2', 'value-3' ]
|
197
|
+
assert_equal 3, r.values.size
|
198
|
+
assert_empty stdout.string
|
199
|
+
assert_not_empty stderr.string
|
200
|
+
assert_match /wrong number of values.*3 given.*2 required.*/, stderr.string
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_constrain_with_simple_range
|
204
|
+
|
205
|
+
stdout = StringIO.new
|
206
|
+
stderr = StringIO.new
|
207
|
+
|
208
|
+
climate = LibCLImate::Climate.new do |cl|
|
209
|
+
|
210
|
+
cl.exit_on_missing = false
|
211
|
+
|
212
|
+
cl.stdout = stdout
|
213
|
+
cl.stderr = stderr
|
214
|
+
|
215
|
+
cl.constrain_values = 0..2
|
216
|
+
end
|
217
|
+
|
218
|
+
stdout.string = ''
|
219
|
+
stderr.string = ''
|
220
|
+
r = climate.run [ ]
|
221
|
+
assert_equal 0, r.values.size
|
222
|
+
assert_empty stdout.string
|
223
|
+
assert_empty stderr.string
|
224
|
+
|
225
|
+
stdout.string = ''
|
226
|
+
stderr.string = ''
|
227
|
+
r = climate.run [ 'value-1' ]
|
228
|
+
assert_equal 1, r.values.size
|
229
|
+
assert_empty stdout.string
|
230
|
+
assert_empty stderr.string
|
231
|
+
|
232
|
+
stdout.string = ''
|
233
|
+
stderr.string = ''
|
234
|
+
r = climate.run [ 'value-1', 'value-2' ]
|
235
|
+
assert_equal 2, r.values.size
|
236
|
+
assert_empty stdout.string
|
237
|
+
assert_empty stderr.string
|
238
|
+
|
239
|
+
stdout.string = ''
|
240
|
+
stderr.string = ''
|
241
|
+
r = climate.run [ 'value-1', 'value-2', 'value-3' ]
|
242
|
+
assert_equal 3, r.values.size
|
243
|
+
assert_empty stdout.string
|
244
|
+
assert_not_empty stderr.string
|
245
|
+
|
246
|
+
stdout.string = ''
|
247
|
+
stderr.string = ''
|
248
|
+
r = climate.run [ 'value-1', 'value-2', 'value-3', 'value-4' ]
|
249
|
+
assert_equal 4, r.values.size
|
250
|
+
assert_empty stdout.string
|
251
|
+
assert_not_empty stderr.string
|
252
|
+
end
|
253
|
+
|
254
|
+
def test_constrain_with_simple_array
|
255
|
+
|
256
|
+
stdout = StringIO.new
|
257
|
+
stderr = StringIO.new
|
258
|
+
|
259
|
+
climate = LibCLImate::Climate.new do |cl|
|
260
|
+
|
261
|
+
cl.exit_on_missing = false
|
262
|
+
|
263
|
+
cl.stdout = stdout
|
264
|
+
cl.stderr = stderr
|
265
|
+
|
266
|
+
cl.constrain_values = [ 1, 3 ]
|
267
|
+
|
268
|
+
cl.program_name = "myprog"
|
269
|
+
cl.usage_help_suffix = ''
|
270
|
+
end
|
271
|
+
|
272
|
+
stdout.string = ''
|
273
|
+
stderr.string = ''
|
274
|
+
r = climate.run [ ]
|
275
|
+
assert_equal 0, r.values.size
|
276
|
+
assert_empty stdout.string
|
277
|
+
assert_not_empty stderr.string
|
278
|
+
|
279
|
+
stdout.string = ''
|
280
|
+
stderr.string = ''
|
281
|
+
r = climate.run [ 'value-1' ]
|
282
|
+
assert_equal 1, r.values.size
|
283
|
+
assert_empty stdout.string
|
284
|
+
assert_empty stderr.string
|
285
|
+
|
286
|
+
stdout.string = ''
|
287
|
+
stderr.string = ''
|
288
|
+
r = climate.run [ 'value-1', 'value-2' ]
|
289
|
+
assert_equal 2, r.values.size
|
290
|
+
assert_empty stdout.string
|
291
|
+
assert_not_empty stderr.string
|
292
|
+
|
293
|
+
stdout.string = ''
|
294
|
+
stderr.string = ''
|
295
|
+
r = climate.run [ 'value-1', 'value-2', 'value-3' ]
|
296
|
+
assert_equal 3, r.values.size
|
297
|
+
assert_empty stdout.string
|
298
|
+
assert_empty stderr.string
|
299
|
+
|
300
|
+
stdout.string = ''
|
301
|
+
stderr.string = ''
|
302
|
+
assert_equal '', stderr.string
|
303
|
+
r = climate.run [ 'value-1', 'value-2', 'value-3', 'value-4' ]
|
304
|
+
assert_equal 4, r.values.size
|
305
|
+
assert_empty stdout.string
|
306
|
+
assert_not_empty stderr.string
|
307
|
+
assert_equal "myprog: wrong number of values: 4 given, [1, 3] required\n", stderr.string
|
308
|
+
end
|
309
309
|
end
|
310
310
|
|
data/test/unit/tc_with_blocks.rb
CHANGED
@@ -15,37 +15,37 @@ require 'stringio'
|
|
15
15
|
|
16
16
|
class Test_Climate_with_blocks < Test::Unit::TestCase
|
17
17
|
|
18
|
-
|
18
|
+
def test_flag_with_block
|
19
19
|
|
20
|
-
|
20
|
+
is_verbose = false
|
21
21
|
|
22
|
-
|
22
|
+
climate = LibCLImate::Climate.new do |cl|
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
cl.add_flag('--verbose') { is_verbose = true }
|
25
|
+
end
|
26
26
|
|
27
|
-
|
27
|
+
argv = %w{ --verbose }
|
28
28
|
|
29
|
-
|
29
|
+
climate.run argv
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
assert is_verbose, "block associated with flag '--verbose' was not executed"
|
32
|
+
end
|
33
33
|
|
34
|
-
|
34
|
+
def test_option_with_block
|
35
35
|
|
36
|
-
|
36
|
+
flavour = nil
|
37
37
|
|
38
|
-
|
38
|
+
climate = LibCLImate::Climate.new do |cl|
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
cl.add_option('--flavour') { |o| flavour = o.value }
|
41
|
+
end
|
42
42
|
|
43
|
-
|
43
|
+
argv = %w{ --flavour=blueberry }
|
44
44
|
|
45
|
-
|
45
|
+
climate.run argv
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
assert_equal 'blueberry', flavour
|
48
|
+
end
|
49
49
|
end
|
50
50
|
|
51
51
|
# ############################## end of file ############################# #
|