Class: Vagabond::Uploader::Librarian

Inherits:
Knife show all
Defined in:
lib/vagabond/uploader/librarian.rb

Constant Summary

Constants included from Helpers

Helpers::GEN_NAME_LENGTH, Helpers::RAND_CHARS

Instance Attribute Summary

Attributes inherited from Vagabond::Uploader

#options, #store, #ui

Instance Method Summary collapse

Methods inherited from Knife

#upload

Methods inherited from Vagabond::Uploader

#upload

Methods included from Helpers

included

Constructor Details

#initialize(*args) ⇒ Librarian

Returns a new instance of Librarian.



7
8
9
10
11
12
13
14
15
# File 'lib/vagabond/uploader/librarian.rb', line 7

def initialize(*args)
  super
  unless(options[:cheffile])
    raise ArgumentError.new "Option 'cheffile' is required!"
  end
  unless(File.exists?(options[:cheffile]))
    raise ArgumentError.new "Option 'cheffile' is not a valid path!"
  end
end

Instance Method Details

#prepareObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vagabond/uploader/librarian.rb', line 17

def prepare
  if(File.directory?(File.join(store, 'cookbooks')))
    com = 'librarian-chef update' # TODO: Check path in .librarian config
  else
    com = "librarian-chef install --path=#{File.join(store, 'cookbooks')}"
  end
  debug(com)
  cmd = Mixlib::ShellOut.new(com,
    :live_stream => options[:debug],
    :cwd => File.dirname(options[:cheffile])
  )
  cmd.run_command
  cmd.error!
  options[:cookbook_paths] = [File.join(store, 'cookbooks')]
end