Class: Spiceweasel::Knife
- Inherits:
-
Object
- Object
- Spiceweasel::Knife
- Includes:
- CommandHelper
- Defined in:
- lib/spiceweasel/knife.rb
Instance Attribute Summary collapse
-
#create ⇒ Object
readonly
Returns the value of attribute create.
-
#knife_list ⇒ Object
readonly
Returns the value of attribute knife_list.
Instance Method Summary collapse
-
#initialize(knives = {}) ⇒ Knife
constructor
A new instance of Knife.
-
#validate(command, allknifes) ⇒ Object
test that the knife command exists.
Methods included from CommandHelper
#create_command, #delete_command
Constructor Details
#initialize(knives = {}) ⇒ Knife
Returns a new instance of Knife.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/spiceweasel/knife.rb', line 28 def initialize(knives = {}) @create = Array.new if knives allknifes = Mixlib::ShellOut.new('knife -h').run_command.stdout.split(/\n/) allknifes.keep_if {|x| x.start_with?('knife')} Spiceweasel::Log.debug(allknifes) knives.each do |knife| Spiceweasel::Log.debug("knife: #{knife}") knife.keys.each do |knf| validate(knf, allknifes) unless Spiceweasel::Config[:novalidation] if knife[knf] knife[knf].each do || create_command("knife #{knf} #{}") end else create_command("knife #{knf}") end end end end end |
Instance Attribute Details
#create ⇒ Object (readonly)
Returns the value of attribute create.
26 27 28 |
# File 'lib/spiceweasel/knife.rb', line 26 def create @create end |
#knife_list ⇒ Object (readonly)
Returns the value of attribute knife_list.
26 27 28 |
# File 'lib/spiceweasel/knife.rb', line 26 def knife_list @knife_list end |
Instance Method Details
#validate(command, allknifes) ⇒ Object
test that the knife command exists
51 52 53 54 55 56 |
# File 'lib/spiceweasel/knife.rb', line 51 def validate(command, allknifes) unless allknifes.index {|x| x.start_with?("knife #{command}")} STDERR.puts "ERROR: 'knife #{command}' is not a currently supported command for knife." exit(-1) end end |