Class: Vagabond::Uploader::Berkshelf
- Inherits:
-
Knife
- Object
- Vagabond::Uploader
- Knife
- Vagabond::Uploader::Berkshelf
- Defined in:
- lib/vagabond/uploader/berkshelf.rb
Instance Attribute Summary
Attributes inherited from Vagabond::Uploader
#options, #store, #ui, #vagabondfile
Instance Method Summary collapse
-
#initialize(*args) ⇒ Berkshelf
constructor
A new instance of Berkshelf.
- #prepare ⇒ Object
- #vendor(*args) ⇒ Object
Methods inherited from Knife
Methods inherited from Vagabond::Uploader
Methods included from Helpers
Constructor Details
#initialize(*args) ⇒ Berkshelf
Returns a new instance of Berkshelf.
8 9 10 11 12 13 14 15 |
# File 'lib/vagabond/uploader/berkshelf.rb', line 8 def initialize(*args) super %w(berksfile).each do |k| unless([k]) raise ArgumentError.new "Option '#{k}' must be provided!" end end end |
Instance Method Details
#prepare ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vagabond/uploader/berkshelf.rb', line 17 def prepare path = File.join(store, 'berks.json') if(File.exists?(path)) cur = Mash.new(JSON.load(File.read(path))) else cur = Mash.new end url = [:chef_server_url] || 'http://127.0.0.1' if(cur[:chef].nil? || cur[:chef][:chef_server_url] != url) cur[:chef] = Mash.new(:chef_server_url => url) cur[:ssl] = Mash.new(:verify => false) File.open(path, 'w') do |file| file.write(JSON.dump(cur)) end end vendor [:cookbook_paths] = [File.join(store, 'cookbooks')] end |
#vendor(*args) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/vagabond/uploader/berkshelf.rb', line 36 def vendor(*args) FileUtils.mkdir_p(ckbk_store = File.join(store, 'cookbooks')) com = "berks install -b #{[:berksfile]} -p #{ckbk_store} #{Array([:berks_opts]).compact.flatten.join(' ')}" debug(com) cmd = Mixlib::ShellOut.new(com, :live_stream => [:debug]) cmd.run_command cmd.error! end |