diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-12-06 13:57:02 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-06 13:57:02 -0800 |
commit | 54b2cd9929f21e1ee1f059a6d8960fe0ccca2e34 (patch) | |
tree | 5558e05781e8baea8d6aff164e5bdf9f37ffcb77 | |
parent | cbd1ca4925c793f60e80a8fdb1e5d6aa9f93559a (diff) | |
parent | 17579dfe81c7df31d1a28f7d62b846520f45f32c (diff) | |
download | mixlib-config-54b2cd9929f21e1ee1f059a6d8960fe0ccca2e34.tar.gz |
Merge pull request #69 from chef/chefstyle
Resolve chefstyle and expeditor issues
-rw-r--r-- | .expeditor/config.yml | 26 | ||||
-rw-r--r-- | features/steps/config_steps.rb | 2 | ||||
-rw-r--r-- | lib/mixlib/config.rb | 42 | ||||
-rw-r--r-- | lib/mixlib/config/version.rb | 2 | ||||
-rw-r--r-- | spec/mixlib/config_spec.rb | 48 |
5 files changed, 63 insertions, 57 deletions
diff --git a/.expeditor/config.yml b/.expeditor/config.yml index 17baaec..1a078cb 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -1,33 +1,39 @@ +# Documentation available at https://expeditor.chef.io/docs/getting-started/ --- +# Slack channel in Chef Software slack to send notifications about build failures, etc slack: notify_channel: chef-notify +# This publish is triggered by the `built_in:publish_rubygems` artifact_action. +rubygems: + - mixlib-config + github: + # This deletes the GitHub PR branch after successfully merged into the release branch + delete_branch_on_merge: true + # The tag format to use (e.g. v1.0.0) version_tag_format: "v{{version}}" + # allow bumping the minor release via label minor_bump_labels: - - "Version: Bump Minor" + - "Expeditor: Bump Minor Version" changelog: rollup_header: Changes not yet released to rubygems.org -rubygems: - - mixlib-config - +# These actions are taken, in order they are specified, anytime a Pull Request is merged. merge_actions: - built_in:bump_version: ignore_labels: - - "Version: Skip Bump" + - "Expeditor: Skip Version Bump" - "Expeditor: Skip All" - bash:.expeditor/update_version.sh: - only_if: - - built_in:bump_version + only_if: built_in:bump_version - built_in:update_changelog: ignore_labels: - - "Changelog: Skip Update" + - "Expeditor: Exclude From Changelog" - "Expeditor: Skip All" - built_in:build_gem: - only_if: - - built_in:bump_version + only_if: built_in:bump_version promote: actions: diff --git a/features/steps/config_steps.rb b/features/steps/config_steps.rb index ac42082..738f175 100644 --- a/features/steps/config_steps.rb +++ b/features/steps/config_steps.rb @@ -21,7 +21,7 @@ end When(/^I set '(.+)' to '(.+)' in configuration class '(.+)'$/) do |key, value, classname| - #ConfigIt[key.to_sym] = value + # ConfigIt[key.to_sym] = value if classname == "ConfigIt" ConfigIt[key.to_sym] = value elsif classname == "ConfigItToo" diff --git a/lib/mixlib/config.rb b/lib/mixlib/config.rb index aa56cea..6809b24 100644 --- a/lib/mixlib/config.rb +++ b/lib/mixlib/config.rb @@ -141,14 +141,14 @@ module Mixlib # <True>:: If the config option exists # <False>:: If the config option does not exist def key?(key) - configuration.has_key?(key.to_sym) || config_contexts.has_key?(key.to_sym) + configuration.key?(key.to_sym) || config_contexts.key?(key.to_sym) end alias_method :has_key?, :key? def is_default?(key) symbol = key.to_sym - if configurables.has_key?(symbol) + if configurables.key?(symbol) configurables[symbol].is_default?(configuration) else raise ArgumentError, "config option must exist, and not be a context to check for default values" @@ -250,9 +250,9 @@ module Mixlib # === Returns # self def restore(hash) - self.configuration = hash.reject { |key, value| config_contexts.has_key?(key) } + self.configuration = hash.reject { |key, value| config_contexts.key?(key) } config_contexts.each do |key, config_context| - if hash.has_key?(key) + if hash.key?(key) config_context.restore(hash[key]) else config_context.reset @@ -260,7 +260,7 @@ module Mixlib end config_context_lists.each do |key, meta| meta[:values] = [] - if hash.has_key?(key) + if hash.key?(key) hash[key].each do |val| context = define_context(meta[:definition_blocks]) context.restore(val) @@ -270,7 +270,7 @@ module Mixlib end config_context_hashes.each do |key, meta| meta[:values] = {} - if hash.has_key?(key) + if hash.key?(key) hash[key].each do |vkey, val| context = define_context(meta[:definition_blocks]) context.restore(val) @@ -289,7 +289,7 @@ module Mixlib # self def merge!(hash) hash.each do |key, value| - if config_contexts.has_key?(key) + if config_contexts.key?(key) # Grab the config context and let internal_get cache it if so desired config_contexts[key].restore(value) else @@ -369,7 +369,7 @@ module Mixlib # The value of the config option. def configurable(symbol, &block) unless configurables[symbol] - if config_contexts.has_key?(symbol) + if config_contexts.key?(symbol) raise ReopenedConfigContextWithConfigurableError, "Cannot redefine config_context #{symbol} as a configurable value" end configurables[symbol] = Configurable.new(symbol) @@ -397,11 +397,11 @@ module Mixlib # block<Block>: a block that will be run in the context of this new config # class. def config_context(symbol, &block) - if configurables.has_key?(symbol) + if configurables.key?(symbol) raise ReopenedConfigurableWithConfigContextError, "Cannot redefine config value #{symbol} with a config context" end - if config_contexts.has_key?(symbol) + if config_contexts.key?(symbol) context = config_contexts[symbol] else context = Class.new @@ -435,11 +435,11 @@ module Mixlib # block<Block>: a block that will be run in the context of this new config # class. def config_context_list(plural_symbol, singular_symbol, &block) - if configurables.has_key?(plural_symbol) + if configurables.key?(plural_symbol) raise ReopenedConfigurableWithConfigContextError, "Cannot redefine config value #{plural_symbol} with a config context" end - unless config_context_lists.has_key?(plural_symbol) + unless config_context_lists.key?(plural_symbol) config_context_lists[plural_symbol] = { definition_blocks: [], values: [], @@ -467,11 +467,11 @@ module Mixlib # block<Block>: a block that will be run in the context of this new config # class. def config_context_hash(plural_symbol, singular_symbol, &block) - if configurables.has_key?(plural_symbol) + if configurables.key?(plural_symbol) raise ReopenedConfigurableWithConfigContextError, "Cannot redefine config value #{plural_symbol} with a config context" end - unless config_context_hashes.has_key?(plural_symbol) + unless config_context_hashes.key?(plural_symbol) config_context_hashes[plural_symbol] = { definition_blocks: [], values: {}, @@ -604,9 +604,9 @@ module Mixlib # value<Object>:: Value to be set in config hash # def internal_set(symbol, value) - if configurables.has_key?(symbol) + if configurables.key?(symbol) configurables[symbol].set(configuration, value) - elsif config_contexts.has_key?(symbol) + elsif config_contexts.key?(symbol) config_contexts[symbol].restore(value.to_hash) else if config_strict_mode == :warn @@ -619,13 +619,13 @@ module Mixlib end def internal_get(symbol) - if configurables.has_key?(symbol) + if configurables.key?(symbol) configurables[symbol].get(configuration) - elsif config_contexts.has_key?(symbol) + elsif config_contexts.key?(symbol) config_contexts[symbol] - elsif config_context_lists.has_key?(symbol) + elsif config_context_lists.key?(symbol) config_context_lists[symbol] - elsif config_context_hashes.has_key?(symbol) + elsif config_context_hashes.key?(symbol) config_context_hashes[symbol] else if config_strict_mode == :warn @@ -702,7 +702,7 @@ module Mixlib # Adds a single new context to the list meta.send :define_method, singular_symbol do |key, &block| context_hash_details = internal_get(plural_symbol) - context = if context_hash_details[:values].has_key? key + context = if context_hash_details[:values].key? key context_hash_details[:values][key] else new_context = define_context(context_hash_details[:definition_blocks]) diff --git a/lib/mixlib/config/version.rb b/lib/mixlib/config/version.rb index cc450d2..82ab263 100644 --- a/lib/mixlib/config/version.rb +++ b/lib/mixlib/config/version.rb @@ -19,7 +19,7 @@ module Mixlib module Config - VERSION = "2.2.14" + VERSION = "2.2.14".freeze end end diff --git a/spec/mixlib/config_spec.rb b/spec/mixlib/config_spec.rb index a08e3cc..de4147b 100644 --- a/spec/mixlib/config_spec.rb +++ b/spec/mixlib/config_spec.rb @@ -157,9 +157,9 @@ describe Mixlib::Config do end it "returns true or false with has_key?" do - expect(ConfigIt.has_key?(:monkey)).to be false + expect(ConfigIt.key?(:monkey)).to be false ConfigIt[:monkey] = "gotcha" - expect(ConfigIt.has_key?(:monkey)).to be true + expect(ConfigIt.key?(:monkey)).to be true end it "returns true or false with key?" do @@ -845,13 +845,13 @@ describe Mixlib::Config do # retrieve the default value if it was set. the code in chef/chef which merges # knife config values into cli values will be sensitive to this behavior. it "defaults values do not show up when querying with #has_key?" do - expect(@klass.blah.has_key?(:x)).to be false + expect(@klass.blah.key?(:x)).to be false expect(@klass.blah.x).to be 5 end it "if we assign the values, they show up when querying with #has_key?" do @klass.blah.x = 5 - expect(@klass.blah.has_key?(:x)).to be true + expect(@klass.blah.key?(:x)).to be true end end @@ -953,7 +953,7 @@ describe Mixlib::Config do end it "has_key? finds the subcontext" do - expect(@klass.has_key?(:blah)).to be true + expect(@klass.key?(:blah)).to be true end it "key? finds the subcontext" do @@ -1199,13 +1199,13 @@ describe Mixlib::Config do describe ".from_yaml" do let(:yaml) do - <<-EOH ---- -foo: - - bar - - baz - - matazz -alpha: beta + <<~EOH + --- + foo: + - bar + - baz + - matazz + alpha: beta EOH end @@ -1225,15 +1225,15 @@ alpha: beta describe ".from_json" do let(:json) do - <<-EOH -{ - "foo": [ - "bar", - "baz", - "matazz" - ], - "alpha": "beta" -} + <<~EOH + { + "foo": [ + "bar", + "baz", + "matazz" + ], + "alpha": "beta" + } EOH end @@ -1253,9 +1253,9 @@ alpha: beta describe ".from_toml" do let(:toml) do - <<-EOH -foo = ["bar", "baz", "matazz"] -alpha = "beta" + <<~EOH + foo = ["bar", "baz", "matazz"] + alpha = "beta" EOH end |