Class: Spiceweasel::Knife
- Inherits:
-
Object
- Object
- Spiceweasel::Knife
- Includes:
- CommandHelper
- Defined in:
- lib/spiceweasel/knife.rb
Overview
create knife commands from the manifest
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 = {}, allknifes = []) ⇒ Knife
constructor
A new instance of Knife.
-
#validate(command, allknifes) ⇒ Object
test that the knife command exists.
Methods included from CommandHelper
#bundler?, #create_command, #delete_command
Constructor Details
#initialize(knives = {}, allknifes = []) ⇒ Knife
Returns a new instance of Knife.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/spiceweasel/knife.rb', line 27 def initialize(knives = {}, allknifes = []) @create = [] return unless knives 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 |
Instance Attribute Details
#create ⇒ Object (readonly)
Returns the value of attribute create.
25 26 27 |
# File 'lib/spiceweasel/knife.rb', line 25 def create @create end |
#knife_list ⇒ Object (readonly)
Returns the value of attribute knife_list.
25 26 27 |
# File 'lib/spiceweasel/knife.rb', line 25 def knife_list @knife_list end |
Instance Method Details
#validate(command, allknifes) ⇒ Object
test that the knife command exists
48 49 50 51 52 53 |
# File 'lib/spiceweasel/knife.rb', line 48 def validate(command, allknifes) return if allknifes.index { |x| x.start_with?("knife #{command}") } STDERR.puts "ERROR: 'knife #{command}' is not a currently supported command for knife." exit(-1) end |