Module: Vagabond::Helpers::Knife

Defined in:
lib/vagabond/helpers/knife.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



38
39
40
41
42
# File 'lib/vagabond/helpers/knife.rb', line 38

def included(klass)
  unless(klass.ancestors.include?(::Vagabond::Helpers::Commands))
    klass.send(:include, ::Vagabond::Helpers::Commands)
  end
end

Instance Method Details

#knife_command(action, opts = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/vagabond/helpers/knife.rb', line 11

def knife_command(action, opts={})
  conf = knife_config_build.to_a.map do |ary|
    scrub = ary.compact.map do |arg|
      if(arg)
        arg.gsub('_', '-')
      end
    end
    "--#{scrub.join(' ')}"
  end.join(' ')
  build_command("knife #{action} #{conf}", :shellout => opts)
end

#knife_config(args = {}) ⇒ Object



31
32
33
34
35
# File 'lib/vagabond/helpers/knife.rb', line 31

def knife_config(args = {})
  Settings[:knife] ||= Mash.new
  Settings[:knife].merge!(args)
  Settings[:knife]
end

#knife_config_buildObject



23
24
25
26
27
28
29
# File 'lib/vagabond/helpers/knife.rb', line 23

def knife_config_build
  base = Mash.new
  if(File.exists?(kconf = File.join(vagabondfile.store_directory, '.chef/knife.rb')))
    base[:config] = File.expand_path(kconf)
  end
  base.merge(knife_config)
end