cft_smartcloud 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG +11 -0
- data/README.md +106 -0
- data/VERSION +1 -1
- data/bin/cft_smartcloud +33 -7
- data/bin/smartcloud +33 -7
- data/cft_smartcloud.gemspec +84 -20
- data/lib/config/config.yml +2 -0
- data/lib/curl_client.rb +42 -0
- data/lib/rest-client-1.6.6-master/.gitignore +6 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/README.rdoc +10 -1
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/Rakefile +0 -0
- data/lib/rest-client-1.6.6-master/VERSION +1 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/bin/restclient +5 -4
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/history.md +22 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/rest-client.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/rest_client.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/abstract_response.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/exceptions.rb +0 -0
- data/lib/rest-client-1.6.6-master/lib/restclient/net_http_ext.rb +55 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/payload.rb +17 -2
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/raw_response.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/request.rb +21 -19
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/resource.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient/response.rb +0 -0
- data/lib/{rest-client-1.6.3 → rest-client-1.6.6-master}/lib/restclient.rb +0 -0
- data/lib/rest-client-1.6.6-master/rest-client.gemspec +76 -0
- data/lib/rest-client-1.6.6-master/spec/abstract_response_spec.rb +85 -0
- data/lib/rest-client-1.6.6-master/spec/base.rb +16 -0
- data/lib/rest-client-1.6.6-master/spec/exceptions_spec.rb +98 -0
- data/lib/rest-client-1.6.6-master/spec/integration/certs/equifax.crt +19 -0
- data/lib/rest-client-1.6.6-master/spec/integration/certs/verisign.crt +14 -0
- data/lib/rest-client-1.6.6-master/spec/integration/request_spec.rb +25 -0
- data/lib/rest-client-1.6.6-master/spec/integration_spec.rb +38 -0
- data/lib/rest-client-1.6.6-master/spec/master_shake.jpg +0 -0
- data/lib/rest-client-1.6.6-master/spec/payload_spec.rb +234 -0
- data/lib/rest-client-1.6.6-master/spec/raw_response_spec.rb +17 -0
- data/lib/rest-client-1.6.6-master/spec/request2_spec.rb +40 -0
- data/lib/rest-client-1.6.6-master/spec/request_spec.rb +536 -0
- data/lib/rest-client-1.6.6-master/spec/resource_spec.rb +134 -0
- data/lib/rest-client-1.6.6-master/spec/response_spec.rb +169 -0
- data/lib/rest-client-1.6.6-master/spec/restclient_spec.rb +73 -0
- data/lib/slop-2.3.1/.gemtest +0 -0
- data/lib/slop-2.3.1/.gitignore +6 -0
- data/lib/slop-2.3.1/.yardopts +6 -0
- data/lib/slop-2.3.1/CHANGES.md +137 -0
- data/lib/slop-2.3.1/LICENSE +20 -0
- data/lib/slop-2.3.1/README.md +293 -0
- data/lib/slop-2.3.1/Rakefile +6 -0
- data/lib/slop-2.3.1/lib/slop.rb +1022 -0
- data/lib/slop-2.3.1/slop.gemspec +11 -0
- data/lib/slop-2.3.1/test/commands_test.rb +151 -0
- data/lib/slop-2.3.1/test/helper.rb +13 -0
- data/lib/slop-2.3.1/test/option_test.rb +198 -0
- data/lib/slop-2.3.1/test/slop_test.rb +574 -0
- data/lib/smartcloud.rb +186 -116
- data/lib/terminal-table-1.4.4/History.rdoc +53 -0
- data/lib/terminal-table-1.4.4/Manifest +24 -0
- data/lib/terminal-table-1.4.4/README.rdoc +240 -0
- data/lib/terminal-table-1.4.4/Rakefile +15 -0
- data/lib/terminal-table-1.4.4/Todo.rdoc +14 -0
- data/lib/terminal-table-1.4.4/examples/examples.rb +80 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/cell.rb +88 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/core_ext.rb +8 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/import.rb +4 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/row.rb +48 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/separator.rb +14 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/style.rb +61 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/table.rb +217 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/table_helper.rb +9 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table/version.rb +6 -0
- data/lib/terminal-table-1.4.4/lib/terminal-table.rb +27 -0
- data/lib/terminal-table-1.4.4/spec/cell_spec.rb +54 -0
- data/lib/terminal-table-1.4.4/spec/core_ext_spec.rb +18 -0
- data/lib/terminal-table-1.4.4/spec/import_spec.rb +11 -0
- data/lib/terminal-table-1.4.4/spec/spec.opts +1 -0
- data/lib/terminal-table-1.4.4/spec/spec_helper.rb +8 -0
- data/lib/terminal-table-1.4.4/spec/table_spec.rb +525 -0
- data/lib/terminal-table-1.4.4/tasks/docs.rake +13 -0
- data/lib/terminal-table-1.4.4/tasks/gemspec.rake +3 -0
- data/lib/terminal-table-1.4.4/tasks/spec.rake +25 -0
- data/lib/terminal-table-1.4.4/terminal-table.gemspec +30 -0
- data/responses/addresses +26 -0
- data/responses/addresses.blank +2 -0
- data/responses/instances +74 -0
- data/responses/keys +33 -0
- data/responses/locations +142 -0
- data/responses/offerings_image +3780 -0
- data/responses/storage +379 -0
- metadata +86 -22
- data/README.rdoc +0 -75
- data/lib/rest-client-1.6.3/VERSION +0 -1
- data/lib/rest-client-1.6.3/lib/restclient/net_http_ext.rb +0 -21
@@ -0,0 +1,11 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'slop'
|
3
|
+
s.version = '2.3.1'
|
4
|
+
s.summary = 'Option gathering made easy'
|
5
|
+
s.description = 'A simple DSL for gathering options and parsing the command line'
|
6
|
+
s.author = 'Lee Jarvis'
|
7
|
+
s.email = 'lee@jarvis.co'
|
8
|
+
s.homepage = 'http://github.com/injekt/slop'
|
9
|
+
s.files = `git ls-files`.split("\n")
|
10
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
11
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class CommandsTest < TestCase
|
4
|
+
test 'creating commands' do
|
5
|
+
slop = Slop.new do
|
6
|
+
command :foo do on :f, :foo, 'foo option' end
|
7
|
+
command :bar do on :f, :foo; on :b, :bar, true end
|
8
|
+
end
|
9
|
+
|
10
|
+
slop.commands.each_value do |command|
|
11
|
+
assert_kind_of Slop, command
|
12
|
+
end
|
13
|
+
|
14
|
+
assert 'foo option', slop.commands[:foo].options[:foo].description
|
15
|
+
|
16
|
+
slop.parse %w/bar --bar baz/
|
17
|
+
assert 'baz', slop.commands[:bar][:bar]
|
18
|
+
assert_nil slop.commands['bar']
|
19
|
+
end
|
20
|
+
|
21
|
+
test 'repeating existing commands' do
|
22
|
+
slop = Slop.new
|
23
|
+
assert slop.command :foo
|
24
|
+
assert_raises(ArgumentError) { slop.command :foo }
|
25
|
+
end
|
26
|
+
|
27
|
+
test 'commands inheriting options' do
|
28
|
+
slop = Slop.new :strict do
|
29
|
+
command :foo do end
|
30
|
+
end
|
31
|
+
assert slop.commands[:foo].instance_variable_get(:@strict)
|
32
|
+
end
|
33
|
+
|
34
|
+
test 'commands setting options' do
|
35
|
+
slop = Slop.new :strict => false do
|
36
|
+
command :foo, :strict => true do end
|
37
|
+
end
|
38
|
+
assert slop.commands[:foo].instance_variable_get(:@strict)
|
39
|
+
end
|
40
|
+
|
41
|
+
test 'inception' do
|
42
|
+
slop = Slop.new do
|
43
|
+
command(:foo) { command(:bar) { command(:baz) { on :f, 'D:' } } }
|
44
|
+
end
|
45
|
+
desc = slop.commands[:foo].commands[:bar].commands[:baz].options[:f].description
|
46
|
+
assert_equal 'D:', desc
|
47
|
+
end
|
48
|
+
|
49
|
+
test 'commands with banners' do
|
50
|
+
slop = Slop.new do
|
51
|
+
command(:foo, :banner => 'bar') { }
|
52
|
+
command(:bar) { banner 'bar' }
|
53
|
+
end
|
54
|
+
assert_equal 'bar', slop.commands[:foo].banner
|
55
|
+
assert_equal 'bar', slop.commands[:bar].banner
|
56
|
+
end
|
57
|
+
|
58
|
+
test 'executing on_empty on separate commands' do
|
59
|
+
incmd = inslop = false
|
60
|
+
slop = Slop.new do
|
61
|
+
command(:foo) { on(:bar) {}; on_empty { incmd = true }}
|
62
|
+
on_empty { inslop = true }
|
63
|
+
end
|
64
|
+
slop.parse %w//
|
65
|
+
assert inslop
|
66
|
+
refute incmd
|
67
|
+
inslop = false
|
68
|
+
slop.parse %w/foo/
|
69
|
+
assert incmd
|
70
|
+
refute inslop
|
71
|
+
end
|
72
|
+
|
73
|
+
test 'executing blocks' do
|
74
|
+
foo = bar = nil
|
75
|
+
slop = Slop.new
|
76
|
+
slop.command :foo do
|
77
|
+
on :v, :verbose
|
78
|
+
execute { |o, a| foo = o.verbose? }
|
79
|
+
end
|
80
|
+
slop.command :bar do
|
81
|
+
on :v, :verbose
|
82
|
+
execute { |o, a| bar = o.verbose? }
|
83
|
+
end
|
84
|
+
slop.parse %w[ foo --verbose ]
|
85
|
+
|
86
|
+
assert foo
|
87
|
+
refute bar
|
88
|
+
end
|
89
|
+
|
90
|
+
test 'executing blocks and command arguments' do
|
91
|
+
opts = args = nil
|
92
|
+
slop = Slop.new
|
93
|
+
slop.command :foo do
|
94
|
+
execute do |o, a|
|
95
|
+
opts = o
|
96
|
+
args = a
|
97
|
+
end
|
98
|
+
end
|
99
|
+
slop.parse %w[ foo bar baz ]
|
100
|
+
|
101
|
+
assert_equal %w[ bar baz ], args
|
102
|
+
assert_kind_of Slop, opts
|
103
|
+
end
|
104
|
+
|
105
|
+
test 'executing nested commands' do
|
106
|
+
args = nil
|
107
|
+
slop = Slop.new
|
108
|
+
slop.command :foo do
|
109
|
+
command :bar do
|
110
|
+
execute { |o, a| args = a }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
slop.parse %w[ foo bar baz ]
|
114
|
+
|
115
|
+
assert_equal %w[ baz ], args
|
116
|
+
end
|
117
|
+
|
118
|
+
test 'aliases' do
|
119
|
+
slop = Slop.new
|
120
|
+
slop.command :foo, :alias => :bar
|
121
|
+
slop.command :baz, :aliases => [:lorem, :ipsum]
|
122
|
+
|
123
|
+
assert_equal [:bar], slop.commands[:foo].aliases
|
124
|
+
assert_equal [:lorem, :ipsum], slop.commands[:baz].aliases
|
125
|
+
|
126
|
+
assert_raises(ArgumentError) { slop.command :lorem }
|
127
|
+
end
|
128
|
+
|
129
|
+
test 'command completion' do
|
130
|
+
foo = bar = bara = nil
|
131
|
+
slop = Slop.new
|
132
|
+
slop.command(:foo) { execute { foo = true } }
|
133
|
+
slop.parse %w[ fo ]
|
134
|
+
assert foo
|
135
|
+
|
136
|
+
slop.command(:bar) { execute { bar = true } }
|
137
|
+
slop.command(:bara) { execute { bara = true } }
|
138
|
+
slop.parse %w[ bar ]
|
139
|
+
assert bar
|
140
|
+
refute bara
|
141
|
+
end
|
142
|
+
|
143
|
+
test 'ambiguous command completion' do
|
144
|
+
io = StringIO.new
|
145
|
+
slop = Slop.new(:io => io)
|
146
|
+
slop.command :bar
|
147
|
+
slop.command :baz
|
148
|
+
slop.parse %w[ ba ]
|
149
|
+
assert_equal "Command 'ba' is ambiguous:\n bar, baz\n", io.string
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
unless Object.const_defined? 'Slop'
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'slop'
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'minitest/autorun'
|
7
|
+
require 'stringio'
|
8
|
+
|
9
|
+
class TestCase < MiniTest::Unit::TestCase
|
10
|
+
def self.test(name, &block)
|
11
|
+
define_method("test_#{name.gsub(/\W/, '_')}", &block) if block
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,198 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class OptionTest < TestCase
|
4
|
+
def option(*args, &block)
|
5
|
+
Slop.new.option(*args, &block)
|
6
|
+
end
|
7
|
+
|
8
|
+
def option_with_argument(*args, &block)
|
9
|
+
options = args.shift
|
10
|
+
slop = Slop.new
|
11
|
+
option = slop.opt(*args)
|
12
|
+
slop.parse(options)
|
13
|
+
slop.find {|opt| opt.key == option.key }
|
14
|
+
end
|
15
|
+
|
16
|
+
def option_value(*args, &block)
|
17
|
+
option_with_argument(*args, &block).argument_value
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'expects an argument if argument is true or optional is false' do
|
21
|
+
assert option(:f, :foo, 'foo', true).expects_argument?
|
22
|
+
assert option(:f, :argument => true).expects_argument?
|
23
|
+
assert option(:f, :optional => false).expects_argument?
|
24
|
+
|
25
|
+
refute option(:f, :foo).expects_argument?
|
26
|
+
end
|
27
|
+
|
28
|
+
test 'expects an argument if long option is suffixed with =' do
|
29
|
+
assert option(:f, :foo=).expects_argument?
|
30
|
+
assert option('f', 'foo=').expects_argument?
|
31
|
+
end
|
32
|
+
|
33
|
+
test 'accepts an optional argument if optional is true' do
|
34
|
+
assert option(:f, :optional => true).accepts_optional_argument?
|
35
|
+
assert option(:f, false, :optional => true).accepts_optional_argument?
|
36
|
+
|
37
|
+
refute option(:f, true).accepts_optional_argument?
|
38
|
+
end
|
39
|
+
|
40
|
+
test 'has a callback when passed a block or callback option' do
|
41
|
+
item = nil
|
42
|
+
option(:f){ item = "foo" }.call
|
43
|
+
assert_equal "foo", item
|
44
|
+
|
45
|
+
assert option(:callback => proc { item = "bar" }).call
|
46
|
+
assert_equal "bar", item
|
47
|
+
|
48
|
+
refute option(:f).call
|
49
|
+
end
|
50
|
+
|
51
|
+
test 'splits argument_value with :as => array' do
|
52
|
+
assert_equal %w/lee john bill/, option_value(
|
53
|
+
%w/--people lee,john,bill/, :people, true, :as => Array
|
54
|
+
)
|
55
|
+
|
56
|
+
assert_equal %w/lee john bill/, option_value(
|
57
|
+
%w/--people lee:john:bill/,
|
58
|
+
:people, true, :as => Array, :delimiter => ':'
|
59
|
+
)
|
60
|
+
|
61
|
+
assert_equal ['lee', 'john,bill'], option_value(
|
62
|
+
%w/--people lee,john,bill/,
|
63
|
+
:people, true, :as => Array, :limit => 2
|
64
|
+
)
|
65
|
+
|
66
|
+
assert_equal ['lee', 'john:bill'], option_value(
|
67
|
+
%w/--people lee:john:bill/,
|
68
|
+
:people, true, :as => Array, :limit => 2, :delimiter => ':'
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
test 'casting' do
|
73
|
+
assert_equal :foo, option_value(%w/--name foo/, :name, true, :as => Symbol)
|
74
|
+
assert_equal :foo, option_value(%w/--name foo/, :name, true, :as => :symbol)
|
75
|
+
assert_equal :foo, option_value(%w/--name foo/, :name, true, :as => :sym)
|
76
|
+
assert_equal 30, option_value(%w/--age 30/, :age, true, :as => Integer)
|
77
|
+
assert_equal "1.0", option_value(%w/--id 1/, :id, true, :as => Float).to_s
|
78
|
+
|
79
|
+
assert_equal -1, option_value(%w/-i -1/, :i, true, :as => Integer)
|
80
|
+
assert_equal -1, option_value(%w/-i -1.1/, :i, true, :as => Integer)
|
81
|
+
assert_equal "-1.1", option_value(%w/-i -1.1/, :i, true, :as => Float).to_s
|
82
|
+
assert_equal "foo", option_value(%w/--foo1 foo/, :foo1, true)
|
83
|
+
|
84
|
+
assert_equal 0, option_value(%w//, :v, :verbose, :as => :count)
|
85
|
+
assert_equal 1, option_value(%w/--verbose/, :v, :verbose, :as => :count)
|
86
|
+
assert_equal 2, option_value(%w/--verbose -v/, :v, :verbose, :as => :count)
|
87
|
+
assert_equal 3, option_value(%w/-vvv/, :v, :verbose, :as => :count)
|
88
|
+
end
|
89
|
+
|
90
|
+
test 'casting should return nil for optionless arguments' do
|
91
|
+
assert_equal nil, option_value(%w/-i/, :i, :as => :int)
|
92
|
+
assert_equal nil, option_value(%w/-i/, :i, :as => :str)
|
93
|
+
assert_equal nil, option_value(%w/-i/, :i, :as => :float)
|
94
|
+
assert_equal nil, option_value(%w/-i/, :i, :as => :array)
|
95
|
+
assert_equal nil, option_value(%w/-i/, :i, :as => :range)
|
96
|
+
end
|
97
|
+
|
98
|
+
test 'ranges' do
|
99
|
+
assert_equal (1..10), option_value(%w/-r 1..10/, :r, true, :as => Range)
|
100
|
+
assert_equal (1..10), option_value(%w/-r 1-10/, :r, true, :as => Range)
|
101
|
+
assert_equal (1..10), option_value(%w/-r 1,10/, :r, true, :as => Range)
|
102
|
+
assert_equal (1...10), option_value(%w/-r 1...10/, :r, true, :as => Range)
|
103
|
+
assert_equal (-1..10), option_value(%w/-r -1..10/, :r, true, :as => Range)
|
104
|
+
assert_equal (1..-10), option_value(%w/-r 1..-10/, :r, true, :as => Range)
|
105
|
+
|
106
|
+
# default back to the string unless a regex is successful
|
107
|
+
# return value.to_i if the value is /\A\d+\z/
|
108
|
+
# maybe this should raise if Slop#strict?
|
109
|
+
assert_equal "1abc10", option_value(%w/-r 1abc10/, :r, true, :as => Range)
|
110
|
+
assert_equal 1, option_value(%w/-r 1/, :r, true, :as => Range)
|
111
|
+
end
|
112
|
+
|
113
|
+
test 'printing options' do
|
114
|
+
slop = Slop.new
|
115
|
+
slop.opt :n, :name, 'Your name', true
|
116
|
+
slop.opt :age, 'Your age', true
|
117
|
+
slop.opt :V, 'Display the version'
|
118
|
+
|
119
|
+
assert_equal " -n, --name Your name", slop.options[:name].to_s
|
120
|
+
assert_equal " --age Your age", slop.options[:age].to_s
|
121
|
+
assert_equal " -V, Display the version", slop.options[:V].to_s
|
122
|
+
end
|
123
|
+
|
124
|
+
test 'falls back to default option' do
|
125
|
+
slop = Slop.new
|
126
|
+
slop.opt :foo, :optional => true, :default => 'lee'
|
127
|
+
slop.parse %w/--foo/
|
128
|
+
assert_equal 'lee', slop[:foo]
|
129
|
+
end
|
130
|
+
|
131
|
+
test 'key should default to long flag otherwise use short flag' do
|
132
|
+
assert_equal 'foo', option(:f, :foo).key
|
133
|
+
assert_equal 'b', option(:b).key
|
134
|
+
end
|
135
|
+
|
136
|
+
test 'tail to append items to the options list when printing help' do
|
137
|
+
slop = Slop.new
|
138
|
+
slop.on :f, :foo, :tail => true
|
139
|
+
slop.on :b, :bar
|
140
|
+
assert slop.to_s.strip =~ /foo$/
|
141
|
+
end
|
142
|
+
|
143
|
+
test 'do not print help for options with :help => false' do
|
144
|
+
slop = Slop.new
|
145
|
+
slop.on :f, :foo, :help => false
|
146
|
+
refute slop.help.include?('foo')
|
147
|
+
end
|
148
|
+
|
149
|
+
test 'appends a help string with :help => "string"' do
|
150
|
+
slop = Slop.new
|
151
|
+
slop.on :n, :name, 'Your name', true, :help => '<YOUR NAME HERE>'
|
152
|
+
assert_equal ' -n, --name <YOUR NAME HERE> Your name', slop.options[:name].to_s
|
153
|
+
end
|
154
|
+
|
155
|
+
test 'argument matching' do
|
156
|
+
slop = Slop.new
|
157
|
+
slop.on :f, :foo, true, :match => /^h/
|
158
|
+
|
159
|
+
assert_raises(Slop::InvalidArgumentError, /world/) { slop.parse %w/--foo world/ }
|
160
|
+
assert slop.parse %w/--foo hello/
|
161
|
+
end
|
162
|
+
|
163
|
+
test 'non-casting of nil options' do
|
164
|
+
slop = Slop.new { on :f, :foo, true, :as => String }
|
165
|
+
slop.parse []
|
166
|
+
|
167
|
+
assert_equal nil, slop[:foo]
|
168
|
+
refute_equal "", slop[:foo]
|
169
|
+
end
|
170
|
+
|
171
|
+
test 'counting options' do
|
172
|
+
slop = Slop.new { on :v; on :x }
|
173
|
+
slop.parse %w/-v -v -v -x/
|
174
|
+
assert_equal 1, slop.options[:x].count
|
175
|
+
assert_equal 3, slop.options[:v].count
|
176
|
+
end
|
177
|
+
|
178
|
+
test 'omit block execution with :unless option' do
|
179
|
+
item = nil
|
180
|
+
opts = Slop.new do
|
181
|
+
on :foo
|
182
|
+
on :bar, true, :unless => 'foo' do; item = "foo"; end
|
183
|
+
end
|
184
|
+
opts.parse %w/--foo --bar 1/
|
185
|
+
|
186
|
+
assert_equal "1", opts[:bar]
|
187
|
+
refute item
|
188
|
+
end
|
189
|
+
|
190
|
+
test 'raises MissingOptionError when an option is :required' do
|
191
|
+
opts = Slop.new do
|
192
|
+
on :foo, :required => true
|
193
|
+
end
|
194
|
+
|
195
|
+
assert_raises(Slop::MissingOptionError, /foo is required/) { opts.parse %w[ --bar ] }
|
196
|
+
assert_raises(Slop::MissingOptionError, /foo is required/) { opts.parse %w[ foo ] }
|
197
|
+
end
|
198
|
+
end
|