summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2019-08-07 10:24:16 -0700
committerTim Smith <tsmith84@gmail.com>2019-08-07 10:24:16 -0700
commit581a557efe1b3a685e2dfa092863c0addb914404 (patch)
treed85094e66dcd2182fe5bab6a6814ec7ed246f19b
parenta43b33e722a75fa3c875d2056d21271bbd451ef7 (diff)
downloadmixlib-config-581a557efe1b3a685e2dfa092863c0addb914404.tar.gz
Chefstyle fixes
Also add the badge to the readme
-rw-r--r--README.md1
-rw-r--r--Rakefile2
-rw-r--r--features/steps/config_steps.rb2
-rw-r--r--lib/mixlib/config.rb18
4 files changed, 13 insertions, 10 deletions
diff --git a/README.md b/README.md
index a52b674..171b70c 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# Mixlib::Config
[![Gem Version](https://badge.fury.io/rb/mixlib-config.svg)](https://badge.fury.io/rb/mixlib-config)
+[![Build status](https://badge.buildkite.com/038bff14d03b1f91115dbb444ca81b387bd23855413f017fc0.svg?branch=master)](https://buildkite.com/chef-oss/chef-mixlib-config-master-verify)
**Umbrella Project**: [Chef Foundation](https://github.com/chef/chef-oss-practices/blob/master/projects/chef-foundation.md)
diff --git a/Rakefile b/Rakefile
index b8e277a..c08da21 100644
--- a/Rakefile
+++ b/Rakefile
@@ -3,7 +3,7 @@ require "rspec/core/rake_task"
Bundler::GemHelper.install_tasks
-task default: [:style, :spec]
+task default: %i{style spec}
desc "Run specs"
RSpec::Core::RakeTask.new(:spec) do |spec|
diff --git a/features/steps/config_steps.rb b/features/steps/config_steps.rb
index 738f175..93b7373 100644
--- a/features/steps/config_steps.rb
+++ b/features/steps/config_steps.rb
@@ -46,7 +46,7 @@ Then(/^in configuration class '(.+)' config option '(.+)' is '(.+)'$/) do |class
end
When(/^I set '(.+)' to:$/) do |key, foo_table|
- ConfigIt[key.to_sym] = Array.new
+ ConfigIt[key.to_sym] = []
foo_table.hashes.each do |hash|
ConfigIt[key.to_sym] << hash["key"]
end
diff --git a/lib/mixlib/config.rb b/lib/mixlib/config.rb
index 6809b24..9937182 100644
--- a/lib/mixlib/config.rb
+++ b/lib/mixlib/config.rb
@@ -33,11 +33,11 @@ module Mixlib
class << base; attr_accessor :config_context_lists; end
class << base; attr_accessor :config_context_hashes; end
class << base; attr_accessor :config_parent; end
- base.configuration = Hash.new
- base.configurables = Hash.new
- base.config_contexts = Hash.new
- base.config_context_lists = Hash.new
- base.config_context_hashes = Hash.new
+ base.configuration = ({})
+ base.configurables = ({})
+ base.config_contexts = ({})
+ base.config_context_lists = ({})
+ base.config_context_hashes = ({})
base.initialize_mixlib_config
end
@@ -165,8 +165,8 @@ module Mixlib
# Resets all config options to their defaults.
def reset
- self.configuration = Hash.new
- config_contexts.values.each { |config_context| config_context.reset }
+ self.configuration = ({})
+ config_contexts.values.each(&:reset)
end
# Makes a copy of any non-default values.
@@ -372,6 +372,7 @@ module Mixlib
if config_contexts.key?(symbol)
raise ReopenedConfigContextWithConfigurableError, "Cannot redefine config_context #{symbol} as a configurable value"
end
+
configurables[symbol] = Configurable.new(symbol)
define_attr_accessor_methods(symbol)
end
@@ -531,9 +532,10 @@ module Mixlib
# <ArgumentError>:: if value is set to something other than true, false, or :warn
#
def config_strict_mode=(value)
- if ![ true, false, :warn, nil ].include?(value)
+ unless [ true, false, :warn, nil ].include?(value)
raise ArgumentError, "config_strict_mode must be true, false, nil or :warn"
end
+
@config_strict_mode = value
end