diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-01-12 09:56:40 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-01-12 09:56:40 -0800 |
commit | 6610ebd39d19c3b8776d69a56a39c3b496b8b29f (patch) | |
tree | a5c282b16f71e3f8be0f3ed99310c82cc41ecd6d /lib/chef/knife/core/generic_presenter.rb | |
parent | 812101f11a6c33e49f401ad72598ca6ffb38adc4 (diff) | |
download | chef-6610ebd39d19c3b8776d69a56a39c3b496b8b29f.tar.gz |
really fix copslcg/really-fix-cops
Diffstat (limited to 'lib/chef/knife/core/generic_presenter.rb')
-rw-r--r-- | lib/chef/knife/core/generic_presenter.rb | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb index 2df9603faa..1b26becfa1 100644 --- a/lib/chef/knife/core/generic_presenter.rb +++ b/lib/chef/knife/core/generic_presenter.rb @@ -1,6 +1,6 @@ #-- # Author:: Daniel DeLeo (<dan@opscode.com>) -# Copyright:: Copyright (c) 2011 Opscode, Inc. +# Copyright:: Copyright (c) 2011-2016 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -150,18 +150,18 @@ class Chef def format_data_subset_for_display(data) subset = if config[:attribute] - result = {} - Array(config[:attribute]).each do |nested_value_spec| - nested_value = extract_nested_value(data, nested_value_spec) - result[nested_value_spec] = nested_value - end - result - elsif config[:run_list] - run_list = data.run_list.run_list - { "run_list" => run_list } - else - raise ArgumentError, "format_data_subset_for_display requires attribute, run_list, or id_only config option to be set" - end + result = {} + Array(config[:attribute]).each do |nested_value_spec| + nested_value = extract_nested_value(data, nested_value_spec) + result[nested_value_spec] = nested_value + end + result + elsif config[:run_list] + run_list = data.run_list.run_list + { "run_list" => run_list } + else + raise ArgumentError, "format_data_subset_for_display requires attribute, run_list, or id_only config option to be set" + end {name_or_id_for(data) => subset } end @@ -178,19 +178,19 @@ class Chef nested_value_spec.split(".").each do |attr| if data.nil? nil # don't get no method error on nil - # Must check :[] before attr because spec can include - # `keys` - want the key named `keys`, not a list of - # available keys. + # Must check :[] before attr because spec can include + # `keys` - want the key named `keys`, not a list of + # available keys. elsif data.respond_to?(:[]) && data.has_key?(attr) data = data[attr] elsif data.respond_to?(attr.to_sym) data = data.send(attr.to_sym) else data = begin - data.send(attr.to_sym) - rescue NoMethodError - nil - end + data.send(attr.to_sym) + rescue NoMethodError + nil + end end end ( !data.kind_of?(Array) && data.respond_to?(:to_hash) ) ? data.to_hash : data |