Class: FoodCourt::Packager
- Inherits:
-
Object
- Object
- FoodCourt::Packager
- Defined in:
- lib/food_court/packager.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#current_path ⇒ Object
readonly
Returns the value of attribute current_path.
Instance Method Summary collapse
- #compile ⇒ Object
- #configure ⇒ Object
- #cookbook_paths ⇒ Object
- #cookbook_remote_locations ⇒ Object
-
#initialize(path = nil) ⇒ Packager
constructor
A new instance of Packager.
Constructor Details
#initialize(path = nil) ⇒ Packager
Returns a new instance of Packager.
8 9 10 |
# File 'lib/food_court/packager.rb', line 8 def initialize(path=nil) @current_path = path || Dir.pwd end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/food_court/packager.rb', line 6 def config @config end |
#current_path ⇒ Object (readonly)
Returns the value of attribute current_path.
6 7 8 |
# File 'lib/food_court/packager.rb', line 6 def current_path @current_path end |
Instance Method Details
#compile ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/food_court/packager.rb', line 12 def compile() time = Time.now deployment_dir = File.join(current_path, 'config/chef/deployments', time.strftime('%Y-%m-%d-%H-%M-%S')) FileUtils.mkdir_p deployment_dir dna = config[:dna] File.open(deployment_dir + "/dna.json", "w"){ |f| f.write(dna.to_json) } File.open(deployment_dir + "/solo.rb", "w") do |file| file.write <<-EOH file_cache_path '#{config[:file_cache_path]}' cookbook_path ['#{cookbook_paths.join("', '")}'] log_level :#{config[:log_level] || 'info'} EOH end FileUtils.cp_r File.join(current_path, 'config/chef/site-cookbooks'), File.join(deployment_dir, 'site-cookbooks') `cd #{deployment_dir} && tar czvf site-cookbooks.tar.gz site-cookbooks` return deployment_dir end |
#configure ⇒ Object
45 46 47 48 49 50 |
# File 'lib/food_court/packager.rb', line 45 def configure() order_path = File.join(current_path, 'config/chef', 'order.rb') raise "no order.rb found in path [#{order_path}]" unless File.exists?(order_path) config_file = File.read(order_path) @config ||= eval "#{config_file}" end |
#cookbook_paths ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/food_court/packager.rb', line 37 def cookbook_paths cache_path = config[:file_cache_path] books = [] config[:cookbooks].each{ |book, path| books << "#{cache_path}/#{book}"} books << "#{cache_path}/site-cookbooks" books end |
#cookbook_remote_locations ⇒ Object
33 34 35 |
# File 'lib/food_court/packager.rb', line 33 def cookbook_remote_locations config[:cookbooks].map{ |book, path| path } end |