acclaim 0.2.1 → 0.2.2
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/Rakefile +1 -1
- data/lib/acclaim/command.rb +14 -24
- data/lib/acclaim/version.rb +1 -1
- data/spec/acclaim/command_spec.rb +10 -10
- metadata +9 -9
data/Rakefile
CHANGED
data/lib/acclaim/command.rb
CHANGED
@@ -142,34 +142,24 @@ module Acclaim
|
|
142
142
|
superclass == Acclaim::Command
|
143
143
|
end
|
144
144
|
|
145
|
-
#
|
146
|
-
def
|
147
|
-
|
148
|
-
until command.root?
|
149
|
-
yield command if block_given?
|
150
|
-
command = command.superclass
|
151
|
-
end
|
152
|
-
yield command if block_given?
|
153
|
-
command
|
145
|
+
# Returns all command ancestors of this command.
|
146
|
+
def command_ancestors
|
147
|
+
ancestors - Acclaim::Command.ancestors
|
154
148
|
end
|
155
149
|
|
156
|
-
#
|
157
|
-
|
158
|
-
|
150
|
+
# Progresively yields each command ancestor to the given block.
|
151
|
+
def each_command_ancestor(&block)
|
152
|
+
command_ancestors.each &block
|
153
|
+
end
|
159
154
|
|
160
|
-
# Returns the
|
161
|
-
def
|
162
|
-
|
163
|
-
until_root do |command|
|
164
|
-
parents << command
|
165
|
-
end
|
166
|
-
parents.reverse!
|
167
|
-
end
|
155
|
+
# Returns the root of the command hierarchy.
|
156
|
+
def root
|
157
|
+
command_ancestors.last
|
168
158
|
end
|
169
159
|
|
170
|
-
#
|
171
|
-
def
|
172
|
-
|
160
|
+
# Returns the sequence of commands from #root that leads to this command.
|
161
|
+
def command_path
|
162
|
+
command_ancestors.reverse
|
173
163
|
end
|
174
164
|
|
175
165
|
# Computes the full command line of this command, which takes parent
|
@@ -189,7 +179,7 @@ module Acclaim
|
|
189
179
|
# => "command do something"
|
190
180
|
def full_line(*args)
|
191
181
|
options = args.extract_ribbon!
|
192
|
-
|
182
|
+
command_path.tap do |path|
|
193
183
|
path.shift unless options.include_root?
|
194
184
|
end.map(&:line).join ' '
|
195
185
|
end
|
data/lib/acclaim/version.rb
CHANGED
@@ -64,15 +64,15 @@ describe Acclaim::Command do
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
describe '::
|
67
|
+
describe '::command_path' do
|
68
68
|
it 'should return an array containing only the root command itself' do
|
69
|
-
subject.
|
69
|
+
subject.command_path.should == [ subject ]
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
describe '::
|
74
|
-
it 'should return an
|
75
|
-
subject.
|
73
|
+
describe '::command_ancestors' do
|
74
|
+
it 'should return an array containing only the command itself' do
|
75
|
+
subject.command_ancestors.should == [ subject ]
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -142,15 +142,15 @@ describe Acclaim::Command do
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
-
describe '::
|
145
|
+
describe '::command_path' do
|
146
146
|
it 'should return an array containing the root command and the subcommand, in order' do
|
147
|
-
subject.
|
147
|
+
subject.command_path.should == [ root_command, subject ]
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
|
-
describe '::
|
152
|
-
it 'should return the root command' do
|
153
|
-
subject.
|
151
|
+
describe '::command_ancestors' do
|
152
|
+
it 'should return an array containing the command itself and the root command, in order' do
|
153
|
+
subject.command_ancestors.should == [ subject, root_command ]
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acclaim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-01-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ribbon
|
16
|
-
requirement: &
|
16
|
+
requirement: &11055320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *11055320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &11054640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *11054640
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rookie
|
38
|
-
requirement: &
|
38
|
+
requirement: &11053820 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *11053820
|
47
47
|
description: Command-line option parser and command interface.
|
48
48
|
email: matheus.a.m.moreira@gmail.com
|
49
49
|
executables: []
|
@@ -95,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
segments:
|
97
97
|
- 0
|
98
|
-
hash:
|
98
|
+
hash: -2150306043143248332
|
99
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
100
|
none: false
|
101
101
|
requirements:
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
version: '0'
|
105
105
|
segments:
|
106
106
|
- 0
|
107
|
-
hash:
|
107
|
+
hash: -2150306043143248332
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
110
|
rubygems_version: 1.8.10
|