Sha256: ea9505a937e54b8487e2f822fe86e07b7821f4d11f12ecff7f8180e7fbbc1789
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 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"] = (@hash["recipes"] + sub_hash["recipes"]).uniq end if sub_hash && sub_hash["cookbook_paths"] @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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
soloist-0.0.6 | lib/soloist/chef_config_generator.rb |