optitron 0.1.8 → 0.1.9
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.
- data/Gemfile.lock +13 -13
- data/lib/optitron/class_dsl.rb +20 -3
- data/lib/optitron/version.rb +1 -1
- data/optitron.gemspec +5 -5
- data/spec/cli_spec.rb +17 -0
- metadata +11 -13
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
optitron (0.1.
|
5
|
-
callsite (
|
6
|
-
ruby2ruby (
|
7
|
-
ruby_parser (
|
8
|
-
sexp_processor (
|
4
|
+
optitron (0.1.8)
|
5
|
+
callsite (~> 0.0.4)
|
6
|
+
ruby2ruby (~> 1.2.4)
|
7
|
+
ruby_parser (~> 2.0)
|
8
|
+
sexp_processor (~> 3.0.4)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: http://rubygems.org/
|
@@ -13,22 +13,22 @@ GEM
|
|
13
13
|
callsite (0.0.4)
|
14
14
|
rake (0.8.7)
|
15
15
|
rspec (1.3.0)
|
16
|
-
ruby2ruby (1.2.
|
16
|
+
ruby2ruby (1.2.5)
|
17
17
|
ruby_parser (~> 2.0)
|
18
18
|
sexp_processor (~> 3.0)
|
19
|
-
ruby_parser (2.0.
|
19
|
+
ruby_parser (2.0.5)
|
20
20
|
sexp_processor (~> 3.0)
|
21
|
-
sexp_processor (3.0.
|
21
|
+
sexp_processor (3.0.5)
|
22
22
|
|
23
23
|
PLATFORMS
|
24
24
|
ruby
|
25
25
|
|
26
26
|
DEPENDENCIES
|
27
|
-
bundler (
|
28
|
-
callsite (
|
27
|
+
bundler (~> 1.0.0)
|
28
|
+
callsite (~> 0.0.4)
|
29
29
|
optitron!
|
30
30
|
rake
|
31
31
|
rspec
|
32
|
-
ruby2ruby (
|
33
|
-
ruby_parser (
|
34
|
-
sexp_processor (
|
32
|
+
ruby2ruby (~> 1.2.4)
|
33
|
+
ruby_parser (~> 2.0)
|
34
|
+
sexp_processor (~> 3.0.4)
|
data/lib/optitron/class_dsl.rb
CHANGED
@@ -25,9 +25,26 @@ class Optitron
|
|
25
25
|
|
26
26
|
def process_class(exp)
|
27
27
|
exp.shift
|
28
|
-
@current_class
|
29
|
-
|
30
|
-
|
28
|
+
current_class_size = @current_class.size
|
29
|
+
case exp.first
|
30
|
+
when Symbol
|
31
|
+
@current_class << exp.first.to_sym
|
32
|
+
process(exp)
|
33
|
+
else
|
34
|
+
if exp.first.first == :colon2
|
35
|
+
exp.first.shift
|
36
|
+
class_exp = exp.shift
|
37
|
+
class_exp[0, class_exp.size - 1].each do |const|
|
38
|
+
@current_class << const.last
|
39
|
+
end
|
40
|
+
@current_class << class_exp.last
|
41
|
+
else
|
42
|
+
raise
|
43
|
+
end
|
44
|
+
exp.shift
|
45
|
+
process(exp.first)
|
46
|
+
end
|
47
|
+
@current_class.slice!(current_class_size, @current_class.size)
|
31
48
|
exp.clear
|
32
49
|
exp
|
33
50
|
end
|
data/lib/optitron/version.rb
CHANGED
data/optitron.gemspec
CHANGED
@@ -15,11 +15,11 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.required_rubygems_version = ">= 1.3.6"
|
16
16
|
s.rubyforge_project = "optitron"
|
17
17
|
|
18
|
-
s.add_dependency "ruby_parser", "
|
19
|
-
s.add_dependency "callsite", "
|
20
|
-
s.add_dependency "ruby2ruby", "
|
21
|
-
s.add_dependency "sexp_processor", "
|
22
|
-
s.add_development_dependency "bundler", "
|
18
|
+
s.add_dependency "ruby_parser", "~> 2.0"
|
19
|
+
s.add_dependency "callsite", "~> 0.0.4"
|
20
|
+
s.add_dependency "ruby2ruby", "~> 1.2.4"
|
21
|
+
s.add_dependency "sexp_processor", "~> 3.0.4"
|
22
|
+
s.add_development_dependency "bundler", "~> 1.0.0"
|
23
23
|
s.add_development_dependency "rake"
|
24
24
|
s.add_development_dependency "rspec"
|
25
25
|
|
data/spec/cli_spec.rb
CHANGED
@@ -77,6 +77,18 @@ class CLIExampleWithArgHinting < Optitron::CLI
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
+
module Nested; end
|
81
|
+
class Nested::NestedExample < Optitron::CLI
|
82
|
+
|
83
|
+
class_opt 'verbose'
|
84
|
+
|
85
|
+
desc "Use this too"
|
86
|
+
opt 'another_opt'
|
87
|
+
def use_too(one, two = 'three')
|
88
|
+
puts "using this too #{one} #{two} #{params['another_opt']} #{@env}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
80
92
|
|
81
93
|
describe "Optitron::Parser defaults" do
|
82
94
|
it "should generate the correct help" do
|
@@ -118,4 +130,9 @@ describe "Optitron::Parser defaults" do
|
|
118
130
|
AModule::CLIInAModule.build
|
119
131
|
AModule::CLIInAModule.optitron_parser.help.should == "Commands\n\nmethod [arg1] # a method\n\nGlobal options\n\n-?/--help # Print help message"
|
120
132
|
end
|
133
|
+
|
134
|
+
it "should dispatch from within a different sort of module" do
|
135
|
+
Nested::NestedExample.build
|
136
|
+
AModule::CLIInAModule.optitron_parser.help.should == "Commands\n\nmethod [arg1] # a method\n\nGlobal options\n\n-?/--help # Print help message"
|
137
|
+
end
|
121
138
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optitron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 9
|
10
|
+
version: 0.1.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joshua Hull
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-02 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
hash: 3
|
30
30
|
segments:
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
|
-
- -
|
42
|
+
- - ~>
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
hash: 23
|
45
45
|
segments:
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
requirement: &id003 !ruby/object:Gem::Requirement
|
56
56
|
none: false
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - ~>
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
hash: 23
|
61
61
|
segments:
|
@@ -71,7 +71,7 @@ dependencies:
|
|
71
71
|
requirement: &id004 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ~>
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
hash: 15
|
77
77
|
segments:
|
@@ -87,16 +87,14 @@ dependencies:
|
|
87
87
|
requirement: &id005 !ruby/object:Gem::Requirement
|
88
88
|
none: false
|
89
89
|
requirements:
|
90
|
-
- -
|
90
|
+
- - ~>
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
hash:
|
92
|
+
hash: 23
|
93
93
|
segments:
|
94
94
|
- 1
|
95
95
|
- 0
|
96
96
|
- 0
|
97
|
-
|
98
|
-
- 3
|
99
|
-
version: 1.0.0.rc.3
|
97
|
+
version: 1.0.0
|
100
98
|
type: :development
|
101
99
|
version_requirements: *id005
|
102
100
|
- !ruby/object:Gem::Dependency
|