diff options
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/cookbook/gem_installer.rb | 7 | ||||
-rw-r--r-- | lib/chef/exceptions.rb | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/chef/cookbook/gem_installer.rb b/lib/chef/cookbook/gem_installer.rb index deac48ff78..79b62f7a72 100644 --- a/lib/chef/cookbook/gem_installer.rb +++ b/lib/chef/cookbook/gem_installer.rb @@ -40,6 +40,13 @@ class Chef cookbook_collection.each_value do |cookbook_version| cookbook_version.metadata.gems.each do |args| + if cookbook_gems[args.first].last.is_a?(Hash) + args << {} unless args.last.is_a?(Hash) + args.last.merge!(cookbook_gems[args.first].pop) do |key, v1, v2| + raise Chef::Exceptions::GemRequirementConflict.new(args.first, key, v1, v2) if v1 != v2 + v2 + end + end cookbook_gems[args.first] += args[1..-1] end end diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb index ca388d33cd..dafd445d2d 100644 --- a/lib/chef/exceptions.rb +++ b/lib/chef/exceptions.rb @@ -521,5 +521,11 @@ class Chef # exception specific to invalid usage of 'dsc_resource' resource class DSCModuleNameMissing < ArgumentError; end + + class GemRequirementConflict < RuntimeError + def initialize(gem_name, option, value1, value2) + super "Conflicting requirements for gem '#{gem_name}': Both #{value1.inspect} and #{value2.inspect} given for option #{option.inspect}" + end + end end end |