summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-05-06 12:09:09 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-05-12 15:50:50 -0700
commitd63fc34d0c6fdfbe72dafdf5d07a6cc9c6dd388e (patch)
tree85791c5b0b4776e0a83b4c14547863564b40ea8c
parentc21539fe2205fc61ca9e0a49b3b2702e76931632 (diff)
downloadpuppet-d63fc34d0c6fdfbe72dafdf5d07a6cc9c6dd388e.tar.gz
puppet-d63fc34d0c6fdfbe72dafdf5d07a6cc9c6dd388e.tar.xz
puppet-d63fc34d0c6fdfbe72dafdf5d07a6cc9c6dd388e.zip
Revert "(#7220) Add the ability to "inherit" options."
This reverts commit 9329a1f33b4d7df81ad8661de74f8a3656428570. Conflicts: spec/unit/interface/action_builder_spec.rb spec/unit/interface/action_spec.rb
-rw-r--r--lib/puppet/interface/action.rb5
-rw-r--r--lib/puppet/interface/action_builder.rb10
-rwxr-xr-xspec/unit/interface/action_builder_spec.rb62
-rwxr-xr-xspec/unit/interface/action_spec.rb59
4 files changed, 0 insertions, 136 deletions
diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb
index 114e5341b..622371a4e 100644
--- a/lib/puppet/interface/action.rb
+++ b/lib/puppet/interface/action.rb
@@ -254,11 +254,6 @@ WRAPPER
option
end
- def inherit_options_from(action)
- options = action.options.map { |opt| action.get_option(opt, false) }
- options.reject!(&:nil?).uniq.each { |option| add_option(option) }
- end
-
def option?(name)
@options_hash.include? name.to_sym
end
diff --git a/lib/puppet/interface/action_builder.rb b/lib/puppet/interface/action_builder.rb
index ba5531f1d..62db8de06 100644
--- a/lib/puppet/interface/action_builder.rb
+++ b/lib/puppet/interface/action_builder.rb
@@ -31,16 +31,6 @@ class Puppet::Interface::ActionBuilder
@action.add_option(option)
end
- def inherit_options_from(action)
- if action.is_a? Symbol
- name = action
- action = @face.get_action(name) or
- raise ArgumentError, "This Face has no action named #{name}!"
- end
-
- @action.inherit_options_from(action)
- end
-
def default(value = true)
@action.default = !!value
end
diff --git a/spec/unit/interface/action_builder_spec.rb b/spec/unit/interface/action_builder_spec.rb
index e9f10a1a6..c39860591 100755
--- a/spec/unit/interface/action_builder_spec.rb
+++ b/spec/unit/interface/action_builder_spec.rb
@@ -62,68 +62,6 @@ describe Puppet::Interface::ActionBuilder do
end
end
- describe "#inherit_options_from" do
- let :face do
- Puppet::Interface.new(:face_with_some_options, '0.0.1') do
- option '-w'
-
- action(:foo) do
- when_invoked do true end
- option '-x', '--ex'
- option '-y', '--why'
- end
-
- action(:bar) do
- when_invoked do true end
- option '-z', '--zee'
- end
-
- action(:baz) do
- when_invoked do true end
- option '-z', '--zed'
- end
- end
- end
-
- it 'should add the options from the specified action' do
- foo = face.get_action(:foo)
- action = Puppet::Interface::ActionBuilder.build(face, :inherit_options) do
- when_invoked do true end
- inherit_options_from foo
- end
- action.options.should == foo.options
- end
-
- it 'should add the options from multiple actions' do
- foo = face.get_action(:foo)
- bar = face.get_action(:bar)
- action = Puppet::Interface::ActionBuilder.build(face, :inherit_options) do
- when_invoked do true end
- inherit_options_from foo
- inherit_options_from bar
- end
- action.options.should == (foo.options + bar.options).uniq
- end
-
- it 'should permit symbolic names for actions in the same face' do
- foo = face.get_action(:foo)
- action = Puppet::Interface::ActionBuilder.build(face, :inherit_options) do
- when_invoked do true end
- inherit_options_from :foo
- end
- action.options.should == foo.options
- end
-
- it 'should raise a useful error if you supply a bad action name' do
- expect do
- Puppet::Interface::ActionBuilder.build(face, :inherit_options) do
- when_invoked do true end
- inherit_options_from :nowhere
- end
- end.to raise_error /nowhere/
- end
- end
-
context "inline documentation" do
it "should set the summary" do
action = Puppet::Interface::ActionBuilder.build(face, :foo) do
diff --git a/spec/unit/interface/action_spec.rb b/spec/unit/interface/action_spec.rb
index f43968709..9e539c68e 100755
--- a/spec/unit/interface/action_spec.rb
+++ b/spec/unit/interface/action_spec.rb
@@ -68,65 +68,6 @@ describe Puppet::Interface::Action do
end
end
- describe "#inherit_options_from" do
- let :face do
- Puppet::Interface.new(:face_with_some_options, '0.0.1') do
- option '-w'
-
- action(:foo) do
- when_invoked do true end
- option '-x', '--ex'
- option '-y', '--why'
- end
-
- action(:bar) do
- when_invoked do true end
- option '-z', '--zee'
- end
-
- action(:baz) do
- when_invoked do true end
- option '-z', '--zed'
- end
-
- action(:noopts) do
- # no options declared
- when_invoked do true end
- end
- end
- end
-
- subject { action = face.action(:new_action) { when_invoked do true end } }
-
- it 'should add the options from the specified action' do
- subject.inherit_options_from(foo = face.get_action(:foo))
- subject.options.should == foo.options
- end
-
- it 'should not die when the specified action has no options' do
- original_options = subject.options
- subject.inherit_options_from(face.get_action(:noopts))
- subject.options.should == original_options
- end
-
- it 'should add the options from multiple actions' do
- subject.inherit_options_from(foo = face.get_action(:foo))
- subject.inherit_options_from(bar = face.get_action(:bar))
- subject.options.should == (foo.options + bar.options).uniq
- end
-
- it 'should not inherit face options' do
- subject.expects(:add_option)
- subject.expects(:add_option).with(face.get_option(:w)).never
- subject.inherit_options_from(face.get_action(:bar))
- end
-
- it 'should raise an error if inheritance would duplicate options' do
- subject.inherit_options_from(face.get_action(:bar))
- expect { subject.inherit_options_from(face.get_action(:baz)) }.to raise_error
- end
- end
-
describe "when invoking" do
it "should be able to call other actions on the same object" do
face = Puppet::Interface.new(:my_face, '0.0.1') do