diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-02 15:09:07 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-02 15:09:07 -0700 |
commit | 7a1a6c8ef26c787e4b6dd1602f3d158b37e81720 (patch) | |
tree | 1e390cd535b38368d091cbb33e5d419408d5ce00 /lib/chef/node_map.rb | |
parent | 77f8739a4741e2370e40ec39345a92a6ea393a1a (diff) | |
download | chef-7a1a6c8ef26c787e4b6dd1602f3d158b37e81720.tar.gz |
fix Layout/EmptyLineAfterGuardClause
i like this one, gives visual priority to returns or raises that are
buried in the middle of things.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/node_map.rb')
-rw-r--r-- | lib/chef/node_map.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb index f54b3dc6bb..c2715965eb 100644 --- a/lib/chef/node_map.rb +++ b/lib/chef/node_map.rb @@ -120,6 +120,7 @@ class Chef # def get(node, key, canonical: nil) return nil unless map.key?(key) + map[key].map do |matcher| return matcher[:klass] if node_matches?(node, matcher) && canonical_matches?(canonical, matcher) end @@ -140,6 +141,7 @@ class Chef # def list(node, key, canonical: nil) return [] unless map.key?(key) + map[key].select do |matcher| node_matches?(node, matcher) && canonical_matches?(canonical, matcher) end.map { |matcher| matcher[:klass] } @@ -155,6 +157,7 @@ class Chef # @return [Hash] deleted entries in the same format as the @map def delete_class(klass) raise "please use a Class type for the klass argument" unless klass.is_a?(Class) + deleted = {} map.each do |key, matchers| deleted_matchers = [] @@ -225,6 +228,7 @@ class Chef # It's super common for the filter to be nil. Catch that so we don't # spend any time here. return true if !filters[attribute] + filter_values = Array(filters[attribute]) value = node[attribute] @@ -242,6 +246,7 @@ class Chef # It's super common for the filter to be nil. Catch that so we don't # spend any time here. return true if !filters[attribute] + filter_values = Array(filters[attribute]) value = node[attribute] @@ -257,6 +262,7 @@ class Chef # def matches_target_mode?(filters) return true unless Chef::Config.target_mode? + !!filters[:target_mode] end @@ -270,16 +276,19 @@ class Chef def block_matches?(node, block) return true if block.nil? + block.call node end def node_matches?(node, matcher) return true if !node + filters_match?(node, matcher) && block_matches?(node, matcher[:block]) end def canonical_matches?(canonical, matcher) return true if canonical.nil? + !!canonical == !!matcher[:canonical] end @@ -289,16 +298,22 @@ class Chef def compare_matchers(key, new_matcher, matcher) cmp = compare_matcher_properties(new_matcher[:block], matcher[:block]) return cmp if cmp != 0 + cmp = compare_matcher_properties(new_matcher[:platform_version], matcher[:platform_version]) return cmp if cmp != 0 + cmp = compare_matcher_properties(new_matcher[:platform], matcher[:platform]) return cmp if cmp != 0 + cmp = compare_matcher_properties(new_matcher[:platform_family], matcher[:platform_family]) return cmp if cmp != 0 + cmp = compare_matcher_properties(new_matcher[:os], matcher[:os]) return cmp if cmp != 0 + cmp = compare_matcher_properties(new_matcher[:override], matcher[:override]) return cmp if cmp != 0 + # If all things are identical, return 0 0 end |