applix 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -5
- data/.travis.yml +1 -1
- data/applix.gemspec +6 -5
- data/lib/applix.rb +49 -26
- data/lib/applix/hash.rb +4 -4
- data/lib/applix/version.rb +3 -1
- data/spec/applix_hash_spec.rb +20 -0
- data/spec/applix_spec.rb +98 -73
- data/spec/oattr_spec.rb +4 -4
- data/spec/spec_helper.rb +15 -0
- metadata +46 -100
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/applix.gemspec
CHANGED
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = 'extracting typed option hashes from command line arguments'
|
13
13
|
s.description = %q{
|
14
14
|
ApplixHash#from_argv builds hashes from ARGV like argument vectors
|
15
|
-
according to following examples:
|
16
|
-
|
15
|
+
according to following examples:
|
16
|
+
|
17
17
|
'-f' --> { :f => true }
|
18
18
|
'--flag' --> { :flag => true }
|
19
19
|
'--flag:false' --> { :flag => false }
|
@@ -26,11 +26,11 @@ Gem::Specification.new do |s|
|
|
26
26
|
'--txt:'"foo bar"'' --> { :txt => "foo bar" }
|
27
27
|
'--txt:%w{foo bar}' --> { :txt => ["foo", "bar"] }
|
28
28
|
'--now:Time.now' --> { :now => #<Date: 3588595/2,0,2299161> }
|
29
|
-
|
29
|
+
|
30
30
|
remaining arguments(non flag/options) are inserted as [:arguments,
|
31
31
|
args], eg:
|
32
32
|
Hash.from_argv %w(--foo --bar=loo 123 now)
|
33
|
-
becomes
|
33
|
+
becomes
|
34
34
|
{ :foo => true, :bar => 'loo', :arguments => ["123", "now"] }
|
35
35
|
}
|
36
36
|
|
@@ -51,9 +51,10 @@ Gem::Specification.new do |s|
|
|
51
51
|
s.add_development_dependency 'debugger'
|
52
52
|
end
|
53
53
|
|
54
|
+
# version class is read from
|
54
55
|
s.files = `git ls-files`.split("\n")
|
55
56
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
56
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map do |f|
|
57
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map do |f|
|
57
58
|
File.basename(f)
|
58
59
|
end
|
59
60
|
s.require_paths = ["lib"]
|
data/lib/applix.rb
CHANGED
@@ -1,36 +1,51 @@
|
|
1
1
|
require 'applix/hash'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
# command line options & argument routing controller. A typical usage
|
4
|
+
# Applix.main(ARGV). see also: ApplixHash for argument parsing options.
|
5
|
+
#
|
6
|
+
class Applix
|
7
|
+
|
8
|
+
# prints primitve usage in case of error,
|
9
|
+
#
|
10
|
+
def self.main argv, app_defaults = {}, &blk
|
11
|
+
self.main!(argv, app_defaults, &blk)
|
9
12
|
|
10
|
-
def self.main! argv, defaults = {}, &blk
|
11
|
-
self.main argv, defaults, &blk
|
12
13
|
rescue => e
|
13
|
-
puts <<-
|
14
|
+
puts <<-TXT
|
15
|
+
|
16
|
+
usage: #{$0} <args...>"
|
14
17
|
|
15
|
-
|
18
|
+
TXT
|
19
|
+
end
|
20
|
+
|
21
|
+
# raises exception on error
|
22
|
+
# dumps callstack in case of error when --debug is enabled
|
23
|
+
#
|
24
|
+
def self.main! argv, app_defaults = {}, &blk
|
25
|
+
app = Applix.new(app_defaults.merge(Hash.from_argv argv))
|
26
|
+
app.instance_eval(&blk)
|
27
|
+
app.run(argv, app_defaults, &blk)
|
16
28
|
|
17
|
-
|
29
|
+
rescue => e
|
30
|
+
#app.debug? and (puts %[ !! #{e}:\n#{e.backtrace.join "\n"}])
|
31
|
+
(puts %[ !! #{e}:\n#{e.backtrace.join "\n"}]) if app.debug?
|
32
|
+
raise
|
33
|
+
end
|
18
34
|
|
19
|
-
|
20
|
-
|
35
|
+
def debug?
|
36
|
+
@options[:debug] == true
|
21
37
|
end
|
22
38
|
|
23
|
-
def run argv, defaults
|
24
|
-
|
25
|
-
|
26
|
-
args = (
|
39
|
+
def run argv, defaults = {}
|
40
|
+
# run defaults are overloaded with argv command line options
|
41
|
+
run_options = defaults.merge(Hash.from_argv argv)
|
42
|
+
args = (run_options.delete :args)
|
27
43
|
|
28
44
|
# pre handle, can modify args & options
|
29
|
-
@prolog_cb.call(args,
|
30
|
-
|
45
|
+
@prolog_cb.call(args, run_options) unless @prolog_cb.nil?
|
31
46
|
|
32
47
|
# logic table for dispatching the command line onto an action
|
33
|
-
#
|
48
|
+
#
|
34
49
|
# id | name exits? any | action
|
35
50
|
# -- | -----------------+--------------
|
36
51
|
# 1 | - - | error: no any, mapped to #3 with name == :any
|
@@ -46,31 +61,39 @@ usage: #{$0} <args...>
|
|
46
61
|
task = tasks[name] || tasks[:any]
|
47
62
|
task or (raise "no such task: '#{name}'")
|
48
63
|
|
49
|
-
# case #4: we must un-shift the name back into the args list to
|
50
|
-
#
|
64
|
+
# case #4: we must un-shift the name back into the args list to let :any
|
65
|
+
# still sees it as first argument,
|
51
66
|
(args.unshift name.to_s) if(name != :any && task[:name] == :any)
|
52
67
|
|
53
68
|
# cluster for nesting or direct calling?
|
54
69
|
if task[:cluster]
|
55
70
|
#rc = Applix.main(args, options, &task[:code])
|
56
71
|
cluster_task = task[:name].to_sym
|
57
|
-
cluster_options =
|
72
|
+
cluster_options = run_options.merge(run_options[cluster_task] || {})
|
58
73
|
cluster_options.delete(cluster_task)
|
59
74
|
cluster_options.merge!(Hash.from_argv argv)
|
60
75
|
rc = Applix.main(args, cluster_options, &task[:code])
|
61
76
|
else
|
62
|
-
rc = task[:code].call(*args,
|
77
|
+
rc = task[:code].call(*args, run_options)
|
63
78
|
end
|
64
79
|
|
65
80
|
# post handle
|
66
81
|
unless @epilog_cb.nil?
|
67
|
-
rc = @epilog_cb.call(rc, args,
|
82
|
+
rc = @epilog_cb.call(rc, args, run_options)
|
68
83
|
end
|
69
84
|
|
70
85
|
rc # return result code from handle callbacks, not the epilog_cb
|
71
86
|
end
|
72
87
|
|
73
|
-
private
|
88
|
+
private
|
89
|
+
|
90
|
+
Defaults = {
|
91
|
+
debug: false,
|
92
|
+
}
|
93
|
+
|
94
|
+
def initialize app_defaults = {}
|
95
|
+
@options = (Defaults.merge app_defaults)
|
96
|
+
end
|
74
97
|
|
75
98
|
def prolog &blk
|
76
99
|
@prolog_cb = blk
|
data/lib/applix/hash.rb
CHANGED
@@ -2,7 +2,7 @@ module ApplixHash
|
|
2
2
|
|
3
3
|
module ClassMethods
|
4
4
|
# #from_argv builds hash from ARGV like argument vector according to
|
5
|
-
# following examples:
|
5
|
+
# following examples:
|
6
6
|
#
|
7
7
|
# '-f' --> { :f => true }
|
8
8
|
# '--flag' --> { :flag => true }
|
@@ -19,7 +19,7 @@ module ApplixHash
|
|
19
19
|
#
|
20
20
|
# remaining arguments(non flag/options) are inserted as [:args]. eg:
|
21
21
|
# Hash.from_argv %w(--foo --bar=loo 123 now)
|
22
|
-
# becomes
|
22
|
+
# becomes
|
23
23
|
# { :foo => true, :bar => 'loo', :args => ["123", "now"] }
|
24
24
|
#
|
25
25
|
def from_argv argv, opts = {}
|
@@ -29,7 +29,7 @@ module ApplixHash
|
|
29
29
|
break unless key
|
30
30
|
h[key] = val
|
31
31
|
args.shift
|
32
|
-
end
|
32
|
+
end
|
33
33
|
#[args, h]
|
34
34
|
h[:args] = args
|
35
35
|
h
|
@@ -39,7 +39,7 @@ module ApplixHash
|
|
39
39
|
# parse single flag/option into a [key, value] tuple. returns nil on non
|
40
40
|
# option/flag arguments.
|
41
41
|
def self.parse(arg)
|
42
|
-
m = /^(-(\w)|--(\w\w+))(([=:])(.+))?$/.match(arg)
|
42
|
+
m = /^(-(\w)|--(\w[\w-]+))(([=:])(.+))?$/.match(arg)
|
43
43
|
return [nil, arg] unless m # neither option nor flag -> straight arg
|
44
44
|
key = (m[2] || m[3]).to_sym
|
45
45
|
value = m[6][/(['"]?)(.*)\1$/,2] rescue true
|
data/lib/applix/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ApplixHash do
|
4
|
+
it 'parses dashed string options' do
|
5
|
+
(ApplixHash.parse '--foo-bar').should == ["foo-bar".to_sym, true]
|
6
|
+
(ApplixHash.parse '--foo-bar=321').should == ["foo-bar".to_sym, '321']
|
7
|
+
end
|
8
|
+
|
9
|
+
it "parses the old unit test..." do
|
10
|
+
# -f becomes { :f => true }
|
11
|
+
# --flag becomes { :flag => true }
|
12
|
+
(ApplixHash.parse '-f').should == [:f, true]
|
13
|
+
(ApplixHash.parse '--flag').should == [:flag, true]
|
14
|
+
# --flag:false becomes { :flag => false }
|
15
|
+
(ApplixHash.parse '--flag:false').should == [:flag, false]
|
16
|
+
|
17
|
+
# --option=value becomes { :option => "value" }
|
18
|
+
(ApplixHash.parse '--opt=val').should == [:opt, 'val']
|
19
|
+
end
|
20
|
+
end
|
data/spec/applix_spec.rb
CHANGED
@@ -2,62 +2,93 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Applix do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
cluster(:cluster) do
|
10
|
-
handle(:cmd) do |*args, options|
|
11
|
-
options.should == {:a => :cluster, :b => 2, :c => '5'}
|
12
|
-
args
|
13
|
-
end
|
14
|
-
end
|
5
|
+
context 'main' do
|
6
|
+
it 'catches unknown task errors' do
|
7
|
+
expect { Applix.main(%w(no-such-task)) {} }.
|
8
|
+
should_not raise_error /no-such-task/
|
15
9
|
end
|
16
|
-
end
|
17
10
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
args.should == %w(a b)
|
23
|
-
args.reverse!
|
24
|
-
}
|
25
|
-
handle(:a) { raise 'should not be called!' }
|
26
|
-
handle(:b) { :b_was_called }
|
11
|
+
context 'with captured I/O streams' do
|
12
|
+
it 'prints a minimal (better than nothing?) usage line on errors' do
|
13
|
+
output = capture(:stdout) { Applix.main(%w(no-such-task)) {} }
|
14
|
+
output.should =~ /usage: /
|
27
15
|
end
|
28
|
-
end.should == :b_was_called
|
29
|
-
end
|
30
16
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
handle(:foo) do
|
35
|
-
raise 'should not be called!'
|
17
|
+
it 'suppresses the callstack on errors' do
|
18
|
+
output = capture(:stdout) { Applix.main(%w(no-such-task)) {} }
|
19
|
+
output.should_not =~ /no such task:/
|
36
20
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
21
|
+
|
22
|
+
it 'shows callstack on --debug option' do
|
23
|
+
output = capture(:stdout) { Applix.main(%w(--debug no-such-task)) {} }
|
24
|
+
output.should =~ / !! no such task:/
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'dumps a stacktrace on main with a !' do
|
28
|
+
expect { Applix.main!(%w(no-such-task)) {} }.
|
29
|
+
should raise_error /no such task:/
|
43
30
|
end
|
44
|
-
end
|
31
|
+
end
|
45
32
|
end
|
46
33
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
options.should == {}
|
34
|
+
describe 'cluster' do
|
35
|
+
it 'cluster defaults shadow globals' do
|
36
|
+
args = %w(-c=5 cluster cmd)
|
37
|
+
Applix.main(args, a: :global, b: 2, :cluster => {a: :cluster, c: 3}) do
|
38
|
+
handle(:cmd) { raise 'should not be called!' }
|
39
|
+
cluster(:cluster) do
|
40
|
+
handle(:cmd) do |*args, options|
|
41
|
+
options.should == {:a => :cluster, :b => 2, :c => '5'}
|
55
42
|
args
|
56
43
|
end
|
57
44
|
end
|
58
45
|
end
|
59
|
-
end
|
60
|
-
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'calls cluster prolog' do
|
49
|
+
Applix.main(%w(foo a b)) do
|
50
|
+
cluster(:foo) do
|
51
|
+
prolog { |args, options|
|
52
|
+
args.should == %w(a b)
|
53
|
+
args.reverse!
|
54
|
+
}
|
55
|
+
handle(:a) { raise 'should not be called!' }
|
56
|
+
handle(:b) { :b_was_called }
|
57
|
+
end
|
58
|
+
end.should == :b_was_called
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'support :cluster for nesting' do
|
62
|
+
args = %w(-a -b:2 foo bar p1 p2)
|
63
|
+
Applix.main(args) do
|
64
|
+
handle(:foo) do
|
65
|
+
raise 'should not be called!'
|
66
|
+
end
|
67
|
+
cluster(:foo) do
|
68
|
+
handle(:bar) do |*args, options|
|
69
|
+
args.should == %w(p1 p2)
|
70
|
+
options.should == {:a => true, :b => 2}
|
71
|
+
args
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end.should == %w{p1 p2}
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'can even cluster clusters' do
|
78
|
+
args = %w(foo bar f p1 p2)
|
79
|
+
Applix.main(args) do
|
80
|
+
cluster(:foo) do
|
81
|
+
cluster(:bar) do
|
82
|
+
handle(:f) do |*args, options|
|
83
|
+
args.should == %w(p1 p2)
|
84
|
+
options.should == {}
|
85
|
+
args
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end.should == %w{p1 p2}
|
90
|
+
end
|
91
|
+
end #.cluster
|
61
92
|
|
62
93
|
it 'prolog can even temper with arguments to modify the handle sequence' do
|
63
94
|
Applix.main(['a', 'b']) do
|
@@ -77,7 +108,7 @@ describe Applix do
|
|
77
108
|
options[:prolog] = Time.now
|
78
109
|
}
|
79
110
|
|
80
|
-
handle(:func) { |*_, options|
|
111
|
+
handle(:func) { |*_, options|
|
81
112
|
options[:prolog]
|
82
113
|
}
|
83
114
|
end.should_not == nil
|
@@ -86,7 +117,7 @@ describe Applix do
|
|
86
117
|
it 'epilog has access to task handler results' do
|
87
118
|
Applix.main(['func']) do
|
88
119
|
# @epilog will NOT make it into the handle invocation
|
89
|
-
epilog { |rc, *_|
|
120
|
+
epilog { |rc, *_|
|
90
121
|
rc.should == [1, 2, 3]
|
91
122
|
rc.reverse
|
92
123
|
}
|
@@ -99,18 +130,18 @@ describe Applix do
|
|
99
130
|
Applix.main(['func']) do
|
100
131
|
|
101
132
|
# @prolog will be available in handle invocations
|
102
|
-
prolog {
|
103
|
-
@prolog = :prolog
|
133
|
+
prolog {
|
134
|
+
@prolog = :prolog
|
104
135
|
}
|
105
136
|
|
106
137
|
# @epilog will NOT make it into the handle invocation
|
107
138
|
epilog { |rc, *_|
|
108
|
-
@epilog = :epilog
|
109
|
-
rc
|
139
|
+
@epilog = :epilog
|
140
|
+
rc
|
110
141
|
}
|
111
142
|
|
112
|
-
handle(:func) {
|
113
|
-
[@prolog, @epilog]
|
143
|
+
handle(:func) {
|
144
|
+
[@prolog, @epilog]
|
114
145
|
}
|
115
146
|
end.should == [:prolog, nil]
|
116
147
|
end
|
@@ -118,12 +149,12 @@ describe Applix do
|
|
118
149
|
it 'runs epilog callback after handle' do
|
119
150
|
last_action = nil
|
120
151
|
Applix.main([:func]) do
|
121
|
-
epilog { |rc, *_|
|
152
|
+
epilog { |rc, *_|
|
122
153
|
# handle was already executed
|
123
154
|
last_action.should == :handle
|
124
155
|
last_action = :epilog
|
125
156
|
}
|
126
|
-
handle(:func) {
|
157
|
+
handle(:func) {
|
127
158
|
# epilog block should not have been executed yet
|
128
159
|
last_action.should == nil
|
129
160
|
last_action = :handle
|
@@ -135,7 +166,7 @@ describe Applix do
|
|
135
166
|
it 'supports :any as fallback on command lines without matching task' do
|
136
167
|
Applix.main(%w(--opt1 foo param1 param2), {:opt2 => false}) do
|
137
168
|
handle(:not_called) { raise "can't possible happen" }
|
138
|
-
any do |*args, options|
|
169
|
+
any do |*args, options|
|
139
170
|
args.should == ["foo", "param1", "param2"]
|
140
171
|
options.should == {:opt1 => true, :opt2 => false}
|
141
172
|
end
|
@@ -144,7 +175,7 @@ describe Applix do
|
|
144
175
|
|
145
176
|
it 'any does not shadow existing tasks' do
|
146
177
|
Applix.main(['--opt1', 'foo', "param1", "param2"], {:opt2 => false}) do
|
147
|
-
handle(:foo) do |*args, options|
|
178
|
+
handle(:foo) do |*args, options|
|
148
179
|
args.should == ["param1", "param2"]
|
149
180
|
options.should == {:opt1 => true, :opt2 => false}
|
150
181
|
end
|
@@ -155,7 +186,7 @@ describe Applix do
|
|
155
186
|
it 'supports :any when task does not depend on first arguments' do
|
156
187
|
%w(bla fasel laber red).each do |name|
|
157
188
|
Applix.main(['--opt1', name, "param1", "param2"], {:opt2 => false}) do
|
158
|
-
any do |*args, options|
|
189
|
+
any do |*args, options|
|
159
190
|
args.should == [name, "param1", "param2"]
|
160
191
|
options.should == {:opt1 => true, :opt2 => false}
|
161
192
|
end
|
@@ -170,37 +201,31 @@ describe Applix do
|
|
170
201
|
end.should == :func_return
|
171
202
|
end
|
172
203
|
|
173
|
-
it '
|
204
|
+
it 'passes arguments to function' do
|
174
205
|
argv = ['func', 'p1', 'p2']
|
175
|
-
Applix.main(argv)
|
176
|
-
|
177
|
-
end.should == %w{p1 p2}
|
206
|
+
subject = Applix.main(argv) { handle(:func) {|*args, options| args} }
|
207
|
+
subject.should eq(%w(p1 p2))
|
178
208
|
end
|
179
209
|
|
180
|
-
it '
|
210
|
+
it 'passes a default options hash to function' do
|
181
211
|
argv = %w(func)
|
182
212
|
Applix.main(argv) do
|
183
213
|
handle(:func) { |*_, options| options }
|
184
|
-
end.should
|
214
|
+
end.should eq({})
|
185
215
|
end
|
186
216
|
|
187
217
|
it 'should pass a processed options hash' do
|
188
218
|
argv = %w(-a --bar func)
|
189
219
|
Applix.main(argv) do
|
190
220
|
handle(:func) { |*_, options| options }
|
191
|
-
end.should
|
221
|
+
end.should include(:a => true, :bar => true)
|
192
222
|
end
|
193
223
|
|
224
|
+
it 'parses dashes in string options' do
|
225
|
+
end
|
226
|
+
|
194
227
|
it "should parse the old unit test..." do
|
195
|
-
#
|
196
|
-
# --flag becomes { :flag => true }
|
197
|
-
(ApplixHash.parse '-f').should == [:f, true]
|
198
|
-
(ApplixHash.parse '--flag').should == [:flag, true]
|
199
|
-
# --flag:false becomes { :flag => false }
|
200
|
-
(ApplixHash.parse '--flag:false').should == [:flag, false]
|
201
|
-
|
202
|
-
# --option=value becomes { :option => "value" }
|
203
|
-
(ApplixHash.parse '--opt=val').should == [:opt, 'val']
|
228
|
+
# see applix_hash_spec.rb
|
204
229
|
|
205
230
|
# --int=1 becomes { :int => "1" }
|
206
231
|
# --int:1 becomes { :int => 1 }
|
data/spec/oattr_spec.rb
CHANGED
@@ -17,18 +17,18 @@ describe OAttr do
|
|
17
17
|
Foo.oattr.should_not == nil
|
18
18
|
end
|
19
19
|
it "should define a bar method" do
|
20
|
-
class Foo;
|
20
|
+
class Foo;
|
21
21
|
oattr :bar
|
22
|
-
def initialize; @options = { :bar => 123}; end;
|
22
|
+
def initialize; @options = { :bar => 123}; end;
|
23
23
|
end
|
24
24
|
(Foo.new.respond_to? :bar).should == true
|
25
25
|
Foo.new.bar.should == 123
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should handle container options" do
|
29
|
-
class Foo;
|
29
|
+
class Foo;
|
30
30
|
oattr :xxx, :foo, :container => :params
|
31
|
-
def initialize; @params = { :xxx => 321}; end;
|
31
|
+
def initialize; @params = { :xxx => 321}; end;
|
32
32
|
end
|
33
33
|
(Foo.new.respond_to? :xxx).should == true
|
34
34
|
Foo.new.xxx.should == 321
|
data/spec/spec_helper.rb
CHANGED
@@ -12,3 +12,18 @@ RSpec.configure do |config|
|
|
12
12
|
config.after :each do
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
# captures standard output streams to help testing console I/O
|
17
|
+
#
|
18
|
+
def capture(*streams)
|
19
|
+
streams.map! { |stream| stream.to_s }
|
20
|
+
begin
|
21
|
+
result = StringIO.new
|
22
|
+
streams.each { |stream| eval "$#{stream} = result" }
|
23
|
+
yield
|
24
|
+
ensure
|
25
|
+
streams.each { |stream| eval("$#{stream} = #{stream.upcase}") }
|
26
|
+
end
|
27
|
+
result.string
|
28
|
+
end
|
29
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: applix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-29 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: daemons
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70225028432700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,15 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
24
|
+
version_requirements: *70225028432700
|
30
25
|
- !ruby/object:Gem::Dependency
|
31
26
|
name: rspec
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &70225028432280 !ruby/object:Gem::Requirement
|
33
28
|
none: false
|
34
29
|
requirements:
|
35
30
|
- - ! '>='
|
@@ -37,15 +32,10 @@ dependencies:
|
|
37
32
|
version: '0'
|
38
33
|
type: :development
|
39
34
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
35
|
+
version_requirements: *70225028432280
|
46
36
|
- !ruby/object:Gem::Dependency
|
47
37
|
name: rspec-mocks
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &70225028431860 !ruby/object:Gem::Requirement
|
49
39
|
none: false
|
50
40
|
requirements:
|
51
41
|
- - ! '>='
|
@@ -53,15 +43,10 @@ dependencies:
|
|
53
43
|
version: '0'
|
54
44
|
type: :development
|
55
45
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
46
|
+
version_requirements: *70225028431860
|
62
47
|
- !ruby/object:Gem::Dependency
|
63
48
|
name: guard
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirement: &70225028431440 !ruby/object:Gem::Requirement
|
65
50
|
none: false
|
66
51
|
requirements:
|
67
52
|
- - ! '>='
|
@@ -69,15 +54,10 @@ dependencies:
|
|
69
54
|
version: '0'
|
70
55
|
type: :development
|
71
56
|
prerelease: false
|
72
|
-
version_requirements:
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
57
|
+
version_requirements: *70225028431440
|
78
58
|
- !ruby/object:Gem::Dependency
|
79
59
|
name: guard-rspec
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirement: &70225028463500 !ruby/object:Gem::Requirement
|
81
61
|
none: false
|
82
62
|
requirements:
|
83
63
|
- - ! '>='
|
@@ -85,15 +65,10 @@ dependencies:
|
|
85
65
|
version: '0'
|
86
66
|
type: :development
|
87
67
|
prerelease: false
|
88
|
-
version_requirements:
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
68
|
+
version_requirements: *70225028463500
|
94
69
|
- !ruby/object:Gem::Dependency
|
95
70
|
name: growl
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirement: &70225028463080 !ruby/object:Gem::Requirement
|
97
72
|
none: false
|
98
73
|
requirements:
|
99
74
|
- - ! '>='
|
@@ -101,15 +76,10 @@ dependencies:
|
|
101
76
|
version: '0'
|
102
77
|
type: :development
|
103
78
|
prerelease: false
|
104
|
-
version_requirements:
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
79
|
+
version_requirements: *70225028463080
|
110
80
|
- !ruby/object:Gem::Dependency
|
111
81
|
name: debugger
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
82
|
+
requirement: &70225028462640 !ruby/object:Gem::Requirement
|
113
83
|
none: false
|
114
84
|
requirements:
|
115
85
|
- - ! '>='
|
@@ -117,15 +87,10 @@ dependencies:
|
|
117
87
|
version: '0'
|
118
88
|
type: :development
|
119
89
|
prerelease: false
|
120
|
-
version_requirements:
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ! '>='
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
90
|
+
version_requirements: *70225028462640
|
126
91
|
description: ! "\n ApplixHash#from_argv builds hashes from ARGV like argument vectors\n
|
127
|
-
\ according to following examples
|
128
|
-
|
92
|
+
\ according to following examples:\n\n '-f' --> { :f
|
93
|
+
\ => true }\n '--flag' --> { :flag => true }\n '--flag:false'
|
129
94
|
\ --> { :flag => false }\n '--flag=false' --> { :flag =>
|
130
95
|
'false' }\n '--option=value' --> { :option => \"value\" }\n '--int=1'
|
131
96
|
\ --> { :int => \"1\" }\n '--float=2.3' --> { :float
|
@@ -133,52 +98,34 @@ description: ! "\n ApplixHash#from_argv builds hashes from ARGV like argument
|
|
133
98
|
bar\"' --> { :txt => \"foo bar\" }\n '--txt:'\"foo bar\"'' -->
|
134
99
|
{ :txt => \"foo bar\" }\n '--txt:%w{foo bar}' --> { :txt => [\"foo\",
|
135
100
|
\"bar\"] }\n '--now:Time.now' --> { :now => #<Date: 3588595/2,0,2299161>
|
136
|
-
}\n
|
137
|
-
|
138
|
-
|
139
|
-
\ "
|
101
|
+
}\n\n remaining arguments(non flag/options) are inserted as [:arguments,\n args],
|
102
|
+
eg:\n Hash.from_argv %w(--foo --bar=loo 123 now)\n becomes\n {
|
103
|
+
:foo => true, :bar => 'loo', :arguments => [\"123\", \"now\"] }\n "
|
140
104
|
email:
|
141
105
|
- dirk.luesebrink@artcom.de
|
142
106
|
executables: []
|
143
107
|
extensions: []
|
144
108
|
extra_rdoc_files: []
|
145
109
|
files:
|
146
|
-
-
|
147
|
-
|
148
|
-
-
|
149
|
-
|
150
|
-
-
|
151
|
-
|
152
|
-
-
|
153
|
-
|
154
|
-
-
|
155
|
-
|
156
|
-
-
|
157
|
-
|
158
|
-
-
|
159
|
-
|
160
|
-
-
|
161
|
-
|
162
|
-
-
|
163
|
-
|
164
|
-
-
|
165
|
-
UmFrZWZpbGU=
|
166
|
-
- !binary |-
|
167
|
-
YXBwbGl4LmdlbXNwZWM=
|
168
|
-
- !binary |-
|
169
|
-
bGliL2FwcGxpeC5yYg==
|
170
|
-
- !binary |-
|
171
|
-
bGliL2FwcGxpeC9oYXNoLnJi
|
172
|
-
- !binary |-
|
173
|
-
bGliL2FwcGxpeC9vYXR0ci5yYg==
|
174
|
-
- !binary |-
|
175
|
-
bGliL2FwcGxpeC92ZXJzaW9uLnJi
|
176
|
-
- !binary |-
|
177
|
-
c3BlYy9hcHBsaXhfc3BlYy5yYg==
|
178
|
-
- !binary |-
|
179
|
-
c3BlYy9vYXR0cl9zcGVjLnJi
|
180
|
-
- !binary |-
|
181
|
-
c3BlYy9zcGVjX2hlbHBlci5yYg==
|
110
|
+
- .autotest
|
111
|
+
- .document
|
112
|
+
- .gitignore
|
113
|
+
- .rspec
|
114
|
+
- .travis.yml
|
115
|
+
- Gemfile
|
116
|
+
- Guardfile
|
117
|
+
- LICENSE
|
118
|
+
- README.mkd
|
119
|
+
- Rakefile
|
120
|
+
- applix.gemspec
|
121
|
+
- lib/applix.rb
|
122
|
+
- lib/applix/hash.rb
|
123
|
+
- lib/applix/oattr.rb
|
124
|
+
- lib/applix/version.rb
|
125
|
+
- spec/applix_hash_spec.rb
|
126
|
+
- spec/applix_spec.rb
|
127
|
+
- spec/oattr_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
182
129
|
homepage: http://github.com/crux/applix
|
183
130
|
licenses: []
|
184
131
|
post_install_message:
|
@@ -199,14 +146,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
146
|
version: '0'
|
200
147
|
requirements: []
|
201
148
|
rubyforge_project:
|
202
|
-
rubygems_version: 1.8.
|
149
|
+
rubygems_version: 1.8.15
|
203
150
|
signing_key:
|
204
151
|
specification_version: 3
|
205
152
|
summary: extracting typed option hashes from command line arguments
|
206
153
|
test_files:
|
207
|
-
-
|
208
|
-
|
209
|
-
-
|
210
|
-
|
211
|
-
|
212
|
-
c3BlYy9zcGVjX2hlbHBlci5yYg==
|
154
|
+
- spec/applix_hash_spec.rb
|
155
|
+
- spec/applix_spec.rb
|
156
|
+
- spec/oattr_spec.rb
|
157
|
+
- spec/spec_helper.rb
|
158
|
+
has_rdoc:
|