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.
@@ -15,163 +15,163 @@ require 'stringio'
15
15
 
16
16
  class Test_Climate_parse < Test::Unit::TestCase
17
17
 
18
- class VerifyException < RuntimeError; end
18
+ class VerifyException < RuntimeError; end
19
19
 
20
- class MissingRequiredException < VerifyException; end
21
- class UnrecognisedArgumentException < VerifyException; end
22
- class UnusedArgumentException < VerifyException; end
20
+ class MissingRequiredException < VerifyException; end
21
+ class UnrecognisedArgumentException < VerifyException; end
22
+ class UnusedArgumentException < VerifyException; end
23
23
 
24
- def test_empty_specs_empty_args
24
+ def test_empty_specs_empty_args
25
25
 
26
- stdout = StringIO.new
27
- stderr = StringIO.new
26
+ stdout = StringIO.new
27
+ stderr = StringIO.new
28
28
 
29
- climate = LibCLImate::Climate.new do |cl|
29
+ climate = LibCLImate::Climate.new do |cl|
30
30
 
31
- cl.stdout = $stdout
32
- cl.stderr = $stderr
33
- end
31
+ cl.stdout = $stdout
32
+ cl.stderr = $stderr
33
+ end
34
34
 
35
- assert $stdout.equal? climate.stdout
36
- assert $stderr.equal? climate.stderr
35
+ assert $stdout.equal? climate.stdout
36
+ assert $stderr.equal? climate.stderr
37
37
 
38
- argv = [
39
- ]
38
+ argv = [
39
+ ]
40
40
 
41
- r = climate.parse argv
41
+ r = climate.parse argv
42
42
 
43
- assert_eql climate, r.climate
44
- assert_equal 0, r.flags.size
45
- assert_equal 0, r.options.size
46
- assert_equal 0, r.values.size
47
- assert_nil r.double_slash_index
43
+ assert_eql climate, r.climate
44
+ assert_equal 0, r.flags.size
45
+ assert_equal 0, r.options.size
46
+ assert_equal 0, r.values.size
47
+ assert_nil r.double_slash_index
48
48
 
49
- r.verify()
50
- end
49
+ r.verify()
50
+ end
51
51
 
52
- def test_one_flag_with_block
52
+ def test_one_flag_with_block
53
53
 
54
- stdout = StringIO.new
55
- stderr = StringIO.new
54
+ stdout = StringIO.new
55
+ stderr = StringIO.new
56
56
 
57
- debug = false
57
+ debug = false
58
58
 
59
- climate = LibCLImate::Climate.new do |cl|
59
+ climate = LibCLImate::Climate.new do |cl|
60
60
 
61
- cl.add_flag('--debug', alias: '-d') { debug = true }
61
+ cl.add_flag('--debug', alias: '-d') { debug = true }
62
62
 
63
- cl.stdout = $stdout
64
- cl.stderr = $stderr
65
- end
63
+ cl.stdout = $stdout
64
+ cl.stderr = $stderr
65
+ end
66
66
 
67
- assert $stdout.equal? climate.stdout
68
- assert $stderr.equal? climate.stderr
67
+ assert $stdout.equal? climate.stdout
68
+ assert $stderr.equal? climate.stderr
69
69
 
70
- argv = [
70
+ argv = [
71
71
 
72
- '-d',
73
- '--',
74
- ]
72
+ '-d',
73
+ '--',
74
+ ]
75
75
 
76
- r = climate.parse argv
76
+ r = climate.parse argv
77
77
 
78
- assert_false debug
78
+ assert_false debug
79
79
 
80
- assert_eql climate, r.climate
81
- assert_equal 1, r.flags.size
82
- assert_equal 0, r.options.size
83
- assert_equal 0, r.values.size
84
- assert_equal 1, r.double_slash_index
80
+ assert_eql climate, r.climate
81
+ assert_equal 1, r.flags.size
82
+ assert_equal 0, r.options.size
83
+ assert_equal 0, r.values.size
84
+ assert_equal 1, r.double_slash_index
85
85
 
86
- flag0 = r.flags[0]
86
+ flag0 = r.flags[0]
87
87
 
88
- assert_equal '-d', flag0.given_name
89
- assert_equal '--debug', flag0.name
88
+ assert_equal '-d', flag0.given_name
89
+ assert_equal '--debug', flag0.name
90
90
 
91
- r.verify()
91
+ r.verify()
92
92
 
93
- assert_true debug
94
- end
93
+ assert_true debug
94
+ end
95
95
 
96
- def test_one_option_with_block
96
+ def test_one_option_with_block
97
97
 
98
- stdout = StringIO.new
99
- stderr = StringIO.new
98
+ stdout = StringIO.new
99
+ stderr = StringIO.new
100
100
 
101
- verb = nil
101
+ verb = nil
102
102
 
103
- climate = LibCLImate::Climate.new do |cl|
103
+ climate = LibCLImate::Climate.new do |cl|
104
104
 
105
- cl.add_option('--verbosity', alias: '-v') do |o, s|
105
+ cl.add_option('--verbosity', alias: '-v') do |o, s|
106
106
 
107
- verb = o.value
108
- end
107
+ verb = o.value
108
+ end
109
109
 
110
- cl.stdout = $stdout
111
- cl.stderr = $stderr
112
- end
110
+ cl.stdout = $stdout
111
+ cl.stderr = $stderr
112
+ end
113
113
 
114
- assert $stdout.equal? climate.stdout
115
- assert $stderr.equal? climate.stderr
114
+ assert $stdout.equal? climate.stdout
115
+ assert $stderr.equal? climate.stderr
116
116
 
117
- argv = [
117
+ argv = [
118
118
 
119
- '-v',
120
- 'chatty',
121
- ]
119
+ '-v',
120
+ 'chatty',
121
+ ]
122
122
 
123
- r = climate.parse argv
123
+ r = climate.parse argv
124
124
 
125
- assert_nil verb
125
+ assert_nil verb
126
126
 
127
- assert_eql climate, r.climate
128
- assert_equal 0, r.flags.size
129
- assert_equal 1, r.options.size
130
- assert_equal 0, r.values.size
131
- assert_nil r.double_slash_index
127
+ assert_eql climate, r.climate
128
+ assert_equal 0, r.flags.size
129
+ assert_equal 1, r.options.size
130
+ assert_equal 0, r.values.size
131
+ assert_nil r.double_slash_index
132
132
 
133
- option0 = r.options[0]
133
+ option0 = r.options[0]
134
134
 
135
- assert_equal '-v', option0.given_name
136
- assert_equal '--verbosity', option0.name
135
+ assert_equal '-v', option0.given_name
136
+ assert_equal '--verbosity', option0.name
137
137
 
138
- r.verify()
138
+ r.verify()
139
139
 
140
- assert_equal 'chatty', verb
141
- end
140
+ assert_equal 'chatty', verb
141
+ end
142
142
 
143
- def test_one_required_flag_that_is_missing
143
+ def test_one_required_flag_that_is_missing
144
144
 
145
- stdout = StringIO.new
146
- stderr = StringIO.new
145
+ stdout = StringIO.new
146
+ stderr = StringIO.new
147
147
 
148
- climate = LibCLImate::Climate.new do |cl|
148
+ climate = LibCLImate::Climate.new do |cl|
149
149
 
150
- cl.add_option('--verbosity', alias: '-v', required: true) do |o, s|
150
+ cl.add_option('--verbosity', alias: '-v', required: true) do |o, s|
151
151
 
152
- verb = o.value
153
- end
152
+ verb = o.value
153
+ end
154
154
 
155
- cl.stdout = $stdout
156
- cl.stderr = $stderr
157
- end
155
+ cl.stdout = $stdout
156
+ cl.stderr = $stderr
157
+ end
158
158
 
159
- assert $stdout.equal? climate.stdout
160
- assert $stderr.equal? climate.stderr
159
+ assert $stdout.equal? climate.stdout
160
+ assert $stderr.equal? climate.stderr
161
161
 
162
- argv = [
163
- '--',
164
- ]
162
+ argv = [
163
+ '--',
164
+ ]
165
165
 
166
- r = climate.parse argv
166
+ r = climate.parse argv
167
167
 
168
- assert_eql climate, r.climate
169
- assert_equal 0, r.flags.size
170
- assert_equal 0, r.options.size
171
- assert_equal 0, r.values.size
172
- assert_equal 0, r.double_slash_index
168
+ assert_eql climate, r.climate
169
+ assert_equal 0, r.flags.size
170
+ assert_equal 0, r.options.size
171
+ assert_equal 0, r.values.size
172
+ assert_equal 0, r.double_slash_index
173
173
 
174
- assert_raise_with_message(MissingRequiredException, /.*verbosity.*not specified/) { r.verify(raise_on_required: MissingRequiredException) }
175
- end
174
+ assert_raise_with_message(MissingRequiredException, /.*verbosity.*not specified/) { r.verify(raise_on_required: MissingRequiredException) }
175
+ end
176
176
  end
177
177
 
@@ -15,146 +15,146 @@ require 'stringio'
15
15
 
16
16
  class Test_Climate_parse_and_verify < Test::Unit::TestCase
17
17
 
18
- class VerifyException < RuntimeError; end
18
+ class VerifyException < RuntimeError; end
19
19
 
20
- class MissingRequiredException < VerifyException; end
21
- class UnrecognisedArgumentException < VerifyException; end
22
- class UnusedArgumentException < VerifyException; end
20
+ class MissingRequiredException < VerifyException; end
21
+ class UnrecognisedArgumentException < VerifyException; end
22
+ class UnusedArgumentException < VerifyException; end
23
23
 
24
- def test_empty_specs_empty_args
24
+ def test_empty_specs_empty_args
25
25
 
26
- stdout = StringIO.new
27
- stderr = StringIO.new
26
+ stdout = StringIO.new
27
+ stderr = StringIO.new
28
28
 
29
- climate = LibCLImate::Climate.new do |cl|
29
+ climate = LibCLImate::Climate.new do |cl|
30
30
 
31
- cl.stdout = $stdout
32
- cl.stderr = $stderr
33
- end
31
+ cl.stdout = $stdout
32
+ cl.stderr = $stderr
33
+ end
34
34
 
35
- assert $stdout.equal? climate.stdout
36
- assert $stderr.equal? climate.stderr
35
+ assert $stdout.equal? climate.stdout
36
+ assert $stderr.equal? climate.stderr
37
37
 
38
- argv = [
39
- ]
38
+ argv = [
39
+ ]
40
40
 
41
- r = climate.parse_and_verify argv
41
+ r = climate.parse_and_verify argv
42
42
 
43
- assert_eql climate, r.climate
44
- assert_equal 0, r.flags.size
45
- assert_equal 0, r.options.size
46
- assert_equal 0, r.values.size
47
- assert_nil r.double_slash_index
48
- end
43
+ assert_eql climate, r.climate
44
+ assert_equal 0, r.flags.size
45
+ assert_equal 0, r.options.size
46
+ assert_equal 0, r.values.size
47
+ assert_nil r.double_slash_index
48
+ end
49
49
 
50
- def test_one_flag_with_block
50
+ def test_one_flag_with_block
51
51
 
52
- stdout = StringIO.new
53
- stderr = StringIO.new
52
+ stdout = StringIO.new
53
+ stderr = StringIO.new
54
54
 
55
- debug = false
55
+ debug = false
56
56
 
57
- climate = LibCLImate::Climate.new do |cl|
57
+ climate = LibCLImate::Climate.new do |cl|
58
58
 
59
- cl.add_flag('--debug', alias: '-d') { debug = true }
59
+ cl.add_flag('--debug', alias: '-d') { debug = true }
60
60
 
61
- cl.stdout = $stdout
62
- cl.stderr = $stderr
63
- end
61
+ cl.stdout = $stdout
62
+ cl.stderr = $stderr
63
+ end
64
64
 
65
- assert $stdout.equal? climate.stdout
66
- assert $stderr.equal? climate.stderr
65
+ assert $stdout.equal? climate.stdout
66
+ assert $stderr.equal? climate.stderr
67
67
 
68
- argv = [
68
+ argv = [
69
69
 
70
- '-d',
71
- ]
70
+ '-d',
71
+ ]
72
72
 
73
- r = climate.parse_and_verify argv
73
+ r = climate.parse_and_verify argv
74
74
 
75
- assert_true debug
75
+ assert_true debug
76
76
 
77
- assert_eql climate, r.climate
78
- assert_equal 1, r.flags.size
79
- assert_equal 0, r.options.size
80
- assert_equal 0, r.values.size
81
- assert_nil r.double_slash_index
77
+ assert_eql climate, r.climate
78
+ assert_equal 1, r.flags.size
79
+ assert_equal 0, r.options.size
80
+ assert_equal 0, r.values.size
81
+ assert_nil r.double_slash_index
82
82
 
83
- flag0 = r.flags[0]
83
+ flag0 = r.flags[0]
84
84
 
85
- assert_equal '-d', flag0.given_name
86
- assert_equal '--debug', flag0.name
87
- end
85
+ assert_equal '-d', flag0.given_name
86
+ assert_equal '--debug', flag0.name
87
+ end
88
88
 
89
- def test_one_option_with_block
89
+ def test_one_option_with_block
90
90
 
91
- stdout = StringIO.new
92
- stderr = StringIO.new
91
+ stdout = StringIO.new
92
+ stderr = StringIO.new
93
93
 
94
- verb = nil
94
+ verb = nil
95
95
 
96
- climate = LibCLImate::Climate.new do |cl|
96
+ climate = LibCLImate::Climate.new do |cl|
97
97
 
98
- cl.add_option('--verbosity', alias: '-v') do |o, s|
98
+ cl.add_option('--verbosity', alias: '-v') do |o, s|
99
99
 
100
- verb = o.value
101
- end
100
+ verb = o.value
101
+ end
102
102
 
103
- cl.stdout = $stdout
104
- cl.stderr = $stderr
105
- end
103
+ cl.stdout = $stdout
104
+ cl.stderr = $stderr
105
+ end
106
106
 
107
- assert $stdout.equal? climate.stdout
108
- assert $stderr.equal? climate.stderr
107
+ assert $stdout.equal? climate.stdout
108
+ assert $stderr.equal? climate.stderr
109
109
 
110
- argv = [
110
+ argv = [
111
111
 
112
- '-v',
113
- 'chatty',
114
- ]
112
+ '-v',
113
+ 'chatty',
114
+ ]
115
115
 
116
- r = climate.parse_and_verify argv
116
+ r = climate.parse_and_verify argv
117
117
 
118
- assert_equal 'chatty', verb
118
+ assert_equal 'chatty', verb
119
119
 
120
- assert_eql climate, r.climate
121
- assert_equal 0, r.flags.size
122
- assert_equal 1, r.options.size
123
- assert_equal 0, r.values.size
124
- assert_nil r.double_slash_index
120
+ assert_eql climate, r.climate
121
+ assert_equal 0, r.flags.size
122
+ assert_equal 1, r.options.size
123
+ assert_equal 0, r.values.size
124
+ assert_nil r.double_slash_index
125
125
 
126
- option0 = r.options[0]
126
+ option0 = r.options[0]
127
127
 
128
- assert_equal '-v', option0.given_name
129
- assert_equal '--verbosity', option0.name
130
- end
128
+ assert_equal '-v', option0.given_name
129
+ assert_equal '--verbosity', option0.name
130
+ end
131
131
 
132
- def test_one_required_flag_that_is_missing
132
+ def test_one_required_flag_that_is_missing
133
133
 
134
- stdout = StringIO.new
135
- stderr = StringIO.new
134
+ stdout = StringIO.new
135
+ stderr = StringIO.new
136
136
 
137
- climate = LibCLImate::Climate.new do |cl|
137
+ climate = LibCLImate::Climate.new do |cl|
138
138
 
139
- cl.add_option('--verbosity', alias: '-v', required: true) do |o, s|
139
+ cl.add_option('--verbosity', alias: '-v', required: true) do |o, s|
140
140
 
141
- verb = o.value
142
- end
141
+ verb = o.value
142
+ end
143
143
 
144
- cl.stdout = $stdout
145
- cl.stderr = $stderr
146
- end
144
+ cl.stdout = $stdout
145
+ cl.stderr = $stderr
146
+ end
147
147
 
148
- assert $stdout.equal? climate.stdout
149
- assert $stderr.equal? climate.stderr
148
+ assert $stdout.equal? climate.stdout
149
+ assert $stderr.equal? climate.stderr
150
150
 
151
- argv = [
152
- ]
151
+ argv = [
152
+ ]
153
153
 
154
- assert_raise_with_message(MissingRequiredException, /.*verbosity.*not specified/) do
154
+ assert_raise_with_message(MissingRequiredException, /.*verbosity.*not specified/) do
155
155
 
156
- climate.parse_and_verify argv, raise_on_required: MissingRequiredException
157
- end
158
- end
156
+ climate.parse_and_verify argv, raise_on_required: MissingRequiredException
157
+ end
158
+ end
159
159
  end
160
160
 
@@ -15,74 +15,74 @@ require 'stringio'
15
15
 
16
16
  class Test_Climate_minimal < Test::Unit::TestCase
17
17
 
18
- def test_option_with_flag_specifications
18
+ def test_option_with_flag_specifications
19
19
 
20
- options = {}
20
+ options = {}
21
21
 
22
- climate = LibCLImate::Climate.new do |cl|
22
+ climate = LibCLImate::Climate.new do |cl|
23
23
 
24
- cl.add_option('--action', alias: '-a') { |o, a| options[:action] = o.value }
25
- cl.add_alias('--action=list', '-l')
26
- cl.add_alias('--action=change', '-c')
27
- end
24
+ cl.add_option('--action', alias: '-a') { |o, a| options[:action] = o.value }
25
+ cl.add_alias('--action=list', '-l')
26
+ cl.add_alias('--action=change', '-c')
27
+ end
28
28
 
29
- # invoke via option
30
- begin
31
- options = {}
29
+ # invoke via option
30
+ begin
31
+ options = {}
32
32
 
33
- argv = %w{ --action=action1 }
33
+ argv = %w{ --action=action1 }
34
34
 
35
- r = climate.run argv
35
+ r = climate.run argv
36
36
 
37
- assert_not_nil r
38
- assert_kind_of ::Hash, r
39
- assert 3 <= r.size
40
- assert_equal 0, r.flags[:given].size
37
+ assert_not_nil r
38
+ assert_kind_of ::Hash, r
39
+ assert 3 <= r.size
40
+ assert_equal 0, r.flags[:given].size
41
41
 
42
- assert_equal 1, options.size
43
- assert_not_nil options[:action]
44
- assert_equal 'action1', options[:action]
45
- end
42
+ assert_equal 1, options.size
43
+ assert_not_nil options[:action]
44
+ assert_equal 'action1', options[:action]
45
+ end
46
46
 
47
- # invoke via option specification
48
- begin
49
- options = {}
47
+ # invoke via option specification
48
+ begin
49
+ options = {}
50
50
 
51
- argv = %w{ -a action2 }
51
+ argv = %w{ -a action2 }
52
52
 
53
- r = climate.run argv
53
+ r = climate.run argv
54
54
 
55
- assert_equal 1, options.size
56
- assert_not_nil options[:action]
57
- assert_equal 'action2', options[:action]
58
- end
55
+ assert_equal 1, options.size
56
+ assert_not_nil options[:action]
57
+ assert_equal 'action2', options[:action]
58
+ end
59
59
 
60
- # invoke via flag specification
61
- begin
62
- options = {}
60
+ # invoke via flag specification
61
+ begin
62
+ options = {}
63
63
 
64
- argv = %w{ -c }
64
+ argv = %w{ -c }
65
65
 
66
- r = climate.run argv
66
+ r = climate.run argv
67
67
 
68
- assert_equal 1, options.size
69
- assert_not_nil options[:action]
70
- assert_equal 'change', options[:action]
71
- end
68
+ assert_equal 1, options.size
69
+ assert_not_nil options[:action]
70
+ assert_equal 'change', options[:action]
71
+ end
72
72
 
73
- # invoke via flag specification
74
- begin
75
- options = {}
73
+ # invoke via flag specification
74
+ begin
75
+ options = {}
76
76
 
77
- argv = %w{ -l }
77
+ argv = %w{ -l }
78
78
 
79
- r = climate.run argv
79
+ r = climate.run argv
80
80
 
81
- assert_equal 1, options.size
82
- assert_not_nil options[:action]
83
- assert_equal 'list', options[:action]
84
- end
85
- end
81
+ assert_equal 1, options.size
82
+ assert_not_nil options[:action]
83
+ assert_equal 'list', options[:action]
84
+ end
85
+ end
86
86
  end
87
87
 
88
88
  # ############################## end of file ############################# #