Class: Batali::Command::Install
- Inherits:
-
Batali::Command
- Object
- Bogo::Cli::Command
- Batali::Command
- Batali::Command::Install
- Defined in:
- lib/batali/command/install.rb
Overview
Install cookbooks based on manifest
Constant Summary
Constants inherited from Batali::Command
Instance Method Summary collapse
-
#execute! ⇒ Object
Install cookbooks.
Methods inherited from Batali::Command
#batali_file, #cache_directory, #dry_run, #infrastructure?, #initialize, #manifest
Constructor Details
This class inherits a constructor from Batali::Command
Instance Method Details
#execute! ⇒ Object
Install cookbooks
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/batali/command/install.rb', line 11 def execute! dry_run('Cookbook installation') do install_path = config.fetch(:path, 'cookbooks') run_action('Readying installation destination') do FileUtils.rm_rf(install_path) FileUtils.mkdir_p(install_path) nil end if(manifest.cookbook.nil? || manifest.cookbook.empty?) ui.error 'No cookbooks defined within manifest! Try resolving first. (`batali resolve`)' else run_action('Installing cookbooks') do manifest.cookbook.each_slice(100) do |units_slice| units_slice.map do |unit| Thread.new do if(unit.source.respond_to?(:cache_path)) unit.source.cache_path = cache_directory( Bogo::Utility.snake(unit.source.class.name.split('::').last) ) end asset_path = unit.source.asset final_path = File.join(install_path, unit.name) if(infrastructure?) final_path << "-#{unit.version}" end begin FileUtils.cp_r( File.join(asset_path, '.'), final_path ) ensure unit.source.clean_asset(asset_path) end end end.map(&:join) end nil end end end end |