Sha256: b6699cf4dca68209d250521ba19e72e1514cc200aa7d00280db1c15368bbeb9c
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
require 'tempfile' require 'json' require 'chef/application/solo' module Natives class App def install(packages) create_tmp_attrs_file(Array(packages)) do |attrs_file| run_chef_solo(attrs_file) end end def run_chef_solo(json_attrs_file) ARGV.clear [ '-c', File.join(gem_base_path, 'chef-solo', 'config.rb'), '-o', 'natives', '-j', json_attrs_file.to_path ].each do |token| ARGV << token end Chef::Application::Solo.new.run end def create_tmp_attrs_file(packages, &block) file = Tempfile.new('natives.temp_attrs_file') file.write(json_attrs(packages)) file.flush file.rewind begin block.call(file) ensure file.close! end end protected def gem_base_path File.absolute_path(File.join(File.dirname(__FILE__), '..', '..')) end def json_attrs(packages) { "natives" => { "install_list" => { "rubygems" => packages } } }.to_json end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
natives-0.1.1 | lib/natives/app.rb |
natives-0.1.0 | lib/natives/app.rb |