Sha256: 8cb44916191da6451c4440487e6fdffb0c1c5624737c8ec3f1a6747e1d8c2f3b
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
require 'yaml' class ChefConfigGenerator def initialize(yaml_string, relative_path_to_soloistrc) @hash = YAML.load(yaml_string) @relative_path_to_soloistrc = relative_path_to_soloistrc merge_env_variable_switches end def merge_env_variable_switches return unless @hash["env_variable_switches"] @hash["env_variable_switches"].keys.each do |variable| sub_hash = @hash["env_variable_switches"][variable][ENV[variable]] if sub_hash && sub_hash["recipes"] @hash["recipes"] = (@hash["recipes"] + sub_hash["recipes"]).uniq end if sub_hash && sub_hash["cookbook_paths"] @hash["cookbook_paths"] = (@hash["cookbook_paths"] + sub_hash["cookbook_paths"]).uniq end end end def cookbook_paths (@hash["cookbook_paths"] || @hash["Cookbook_Paths"]).map do |v| (v =~ /\//) == 0 ? v : "#{FileUtils.pwd}/#{@relative_path_to_soloistrc}/#{v}" end end def solo_rb "cookbook_path #{cookbook_paths.inspect}" end def json_hash recipes = @hash["Recipes"] || @hash["recipes"] { "recipes" => recipes } end def json_file json_hash.to_json end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
soloist-0.0.5 | lib/soloist/chef_config_generator.rb |
soloist-0.0.4 | lib/soloist/chef_config_generator.rb |