diff options
-rw-r--r-- | lib/chef/node_map.rb | 20 | ||||
-rw-r--r-- | lib/chef/platform/handler_map.rb | 40 | ||||
-rw-r--r-- | lib/chef/platform/provider_handler_map.rb | 4 | ||||
-rw-r--r-- | lib/chef/platform/resource_handler_map.rb | 4 |
4 files changed, 22 insertions, 46 deletions
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb index 9e64ccadc0..552c90b8d1 100644 --- a/lib/chef/node_map.rb +++ b/lib/chef/node_map.rb @@ -113,7 +113,7 @@ class Chef remaining end - protected + private # # Succeeds if: @@ -172,7 +172,8 @@ class Chef !!canonical == !!matcher[:canonical] end - def compare_matchers(key, new_matcher, matcher) + # @api private + def dispatch_compare_matchers(key, new_matcher, matcher) cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:block] } return cmp if cmp != 0 cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:filters][:platform_version] } @@ -189,6 +190,21 @@ class Chef 0 end + # + # "provides" lines with identical filters sort by class name (ascending). + # + def compare_matchers(key, new_matcher, matcher) + cmp = dispatch_compare_matchers(key, new_matcher, matcher) + if cmp == 0 + # Sort by class name (ascending) as well, if all other properties + # are exactly equal + if new_matcher[:value].is_a?(Class) && !new_matcher[:override] + cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:value].name } + end + end + cmp + end + def compare_matcher_properties(new_matcher, matcher) a = yield(new_matcher) b = yield(matcher) diff --git a/lib/chef/platform/handler_map.rb b/lib/chef/platform/handler_map.rb deleted file mode 100644 index da8f84237f..0000000000 --- a/lib/chef/platform/handler_map.rb +++ /dev/null @@ -1,40 +0,0 @@ -# -# Author:: John Keiser (<jkeiser@chef.io>) -# Copyright:: Copyright 2015-2016, Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "chef/node_map" - -class Chef - class Platform - class HandlerMap < Chef::NodeMap - # - # "provides" lines with identical filters sort by class name (ascending). - # - def compare_matchers(key, new_matcher, matcher) - cmp = super - if cmp == 0 - # Sort by class name (ascending) as well, if all other properties - # are exactly equal - if new_matcher[:value].is_a?(Class) && !new_matcher[:override] - cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:value].name } - end - end - cmp - end - end - end -end diff --git a/lib/chef/platform/provider_handler_map.rb b/lib/chef/platform/provider_handler_map.rb index 26acf150df..4f87a36d1d 100644 --- a/lib/chef/platform/provider_handler_map.rb +++ b/lib/chef/platform/provider_handler_map.rb @@ -17,12 +17,12 @@ # require "singleton" -require "chef/platform/handler_map" +require "chef/node_map" class Chef class Platform # @api private - class ProviderHandlerMap < Chef::Platform::HandlerMap + class ProviderHandlerMap < Chef::NodeMap include Singleton end end diff --git a/lib/chef/platform/resource_handler_map.rb b/lib/chef/platform/resource_handler_map.rb index be1b9c28f5..0aab04212f 100644 --- a/lib/chef/platform/resource_handler_map.rb +++ b/lib/chef/platform/resource_handler_map.rb @@ -17,12 +17,12 @@ # require "singleton" -require "chef/platform/handler_map" +require "chef/node_map" class Chef class Platform # @api private - class ResourceHandlerMap < Chef::Platform::HandlerMap + class ResourceHandlerMap < Chef::NodeMap include Singleton end end |