summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2016-12-13 10:38:22 -0500
committerGitHub <noreply@github.com>2016-12-13 10:38:22 -0500
commitc489be4c9686c357120a9c5a0c25048aef5c4129 (patch)
tree996226aac176f7494b702eace0a49993307e2048
parent6a5888a49eb3e1a3f34f28cee9f0cd510fd46393 (diff)
parent5fbdf841ec3e4abce1e8dd05f46bddeb00492887 (diff)
downloadchef-c489be4c9686c357120a9c5a0c25048aef5c4129.tar.gz
Merge pull request #5636 from chef/lcg/remove-chef-platform-handler-class
remove Chef::Platform::HandlerMap
-rw-r--r--lib/chef/node_map.rb20
-rw-r--r--lib/chef/platform/handler_map.rb40
-rw-r--r--lib/chef/platform/provider_handler_map.rb4
-rw-r--r--lib/chef/platform/resource_handler_map.rb4
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