diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-08-19 10:21:27 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-08-19 10:21:27 -0700 |
commit | a95fc372c19c0e38019202045d7db08ab51e8f16 (patch) | |
tree | fe6b97bdc7ef60a79cf68a542356dc3652a1570b | |
parent | 2cf0918e2b04c234463521590a159abccd610d6d (diff) | |
download | ohai-a95fc372c19c0e38019202045d7db08ab51e8f16.tar.gz |
fixing Lint/UselessAccessModifier
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/ohai/config.rb | 51 | ||||
-rw-r--r-- | spec/support/integration_helper.rb | 2 |
2 files changed, 28 insertions, 25 deletions
diff --git a/lib/ohai/config.rb b/lib/ohai/config.rb index 76951a77..4d4e886b 100644 --- a/lib/ohai/config.rb +++ b/lib/ohai/config.rb @@ -31,29 +31,30 @@ module Ohai # These methods need to be defined before they are used as config defaults, # otherwise they will get method_missing'd to nil. - private - - def self.default_hints_path - [ ChefConfig::Config.platform_specific_path("/etc/chef/ohai/hints") ] - end + class << self + def merge_deprecated_config + [ :hints_path, :plugin_path ].each do |option| + if has_key?(option) && send(option) != send("default_#{option}".to_sym) + Ohai::Log.warn(option_deprecated(option)) + end + end - def self.default_plugin_path - [ File.expand_path(File.join(File.dirname(__FILE__), "plugins")) ] - end + ohai.merge!(configuration) + end - public + private - # Copy deprecated configuration options into the ohai config context. - def self.merge_deprecated_config - [ :hints_path, :plugin_path ].each do |option| - if has_key?(option) && send(option) != send("default_#{option}".to_sym) - Ohai::Log.warn(option_deprecated(option)) - end + def default_hints_path + [ ChefConfig::Config.platform_specific_path("/etc/chef/ohai/hints") ] end - ohai.merge!(configuration) + def default_plugin_path + [ File.expand_path(File.join(File.dirname(__FILE__), "plugins")) ] + end end + # Copy deprecated configuration options into the ohai config context. + # Keep "old" config defaults around so anyone calling Ohai::Config[:key] # won't be broken. Also allows users to append to configuration options # (e.g., Ohai::Config[:plugin_path] << some_path) in their config files. @@ -105,22 +106,24 @@ module Ohai default :plugin_path, Ohai::Config.default_plugin_path end - private + class << self + private - def self.option_deprecated(option) - <<-EOM.chomp!.tr("\n", " ") + def option_deprecated(option) + <<-EOM.chomp!.tr("\n", " ") Ohai::Config[:#{option}] is set. Ohai::Config[:#{option}] is deprecated and will be removed in future releases of ohai. Use ohai.#{option} in your configuration file to configure :#{option} for ohai. -EOM - end + EOM + end - def self.option_might_be_deprecated(option) - option_deprecated(option) + <<-EOM.chomp!.tr("\n", " ") + def option_might_be_deprecated(option) + option_deprecated(option) + <<-EOM.chomp!.tr("\n", " ") If your configuration file is used with other applications which configure :#{option}, and you have not configured Ohai::Config[:#{option}], you may disregard this warning. -EOM + EOM + end end end diff --git a/spec/support/integration_helper.rb b/spec/support/integration_helper.rb index ce61b3f1..6391b34f 100644 --- a/spec/support/integration_helper.rb +++ b/spec/support/integration_helper.rb @@ -18,7 +18,7 @@ module IntegrationSupport end end - def with_plugin(plugin_path, contents) + def with_plugin(plugin_path, contents) # filename = path_to(plugin_path) dir = File.dirname(filename) FileUtils.mkdir_p(dir) unless dir == "." |