Class: Vagabond::Uploader::Librarian

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

Instance Attribute Summary

Attributes inherited from Vagabond::Uploader

#options, #store, #ui, #vagabondfile

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.



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

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



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

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
  cmd = build_command(com, :shellout => {:cwd => File.dirname(options[:cheffile])})
  cmd.run_command
  cmd.error!
  options[:cookbook_paths] = [File.join(store, 'cookbooks')]
end