acclaim 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,3 +1,3 @@
1
1
  require 'rookie'
2
2
 
3
- Rookie::Tasks.new 'acclaim.gemspec'
3
+ Rookie::Tasks.new('acclaim.gemspec').define_tasks!
@@ -142,34 +142,24 @@ module Acclaim
142
142
  superclass == Acclaim::Command
143
143
  end
144
144
 
145
- # Finds the root of the command hierarchy.
146
- def root
147
- command = self
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
- # Walks the command inheritance tree, yielding each command successively
157
- # until the root command.
158
- alias until_root root
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 sequence of commands from #root that leads to this command.
161
- def path
162
- Array.new.tap do |parents|
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
- # Return this command's parent commands.
171
- def parents
172
- path.tap { |path| path.pop; path.reverse! }
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
- path.tap do |path|
182
+ command_path.tap do |path|
193
183
  path.shift unless options.include_root?
194
184
  end.map(&:line).join ' '
195
185
  end
@@ -16,7 +16,7 @@ module Acclaim
16
16
  # Patch version.
17
17
  #
18
18
  # Increments denote changes in implementation.
19
- PATCH = 1
19
+ PATCH = 2
20
20
 
21
21
  # Build version.
22
22
  #
@@ -64,15 +64,15 @@ describe Acclaim::Command do
64
64
  end
65
65
  end
66
66
 
67
- describe '::path' do
67
+ describe '::command_path' do
68
68
  it 'should return an array containing only the root command itself' do
69
- subject.path.should == [ root_command ]
69
+ subject.command_path.should == [ subject ]
70
70
  end
71
71
  end
72
72
 
73
- describe '::parents' do
74
- it 'should return an empty array' do
75
- subject.parents.should == []
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 '::path' do
145
+ describe '::command_path' do
146
146
  it 'should return an array containing the root command and the subcommand, in order' do
147
- subject.path.should == [ root_command, subcommand ]
147
+ subject.command_path.should == [ root_command, subject ]
148
148
  end
149
149
  end
150
150
 
151
- describe '::parents' do
152
- it 'should return the root command' do
153
- subject.parents.should == [ root_command ]
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.1
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: &17374400 !ruby/object:Gem::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: *17374400
24
+ version_requirements: *11055320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &17373960 !ruby/object:Gem::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: *17373960
35
+ version_requirements: *11054640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rookie
38
- requirement: &17373240 !ruby/object:Gem::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: *17373240
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: 3127084049849445509
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: 3127084049849445509
107
+ hash: -2150306043143248332
108
108
  requirements: []
109
109
  rubyforge_project:
110
110
  rubygems_version: 1.8.10