summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/property.rb2
-rw-r--r--lib/chef/provider/package/rubygems.rb2
-rw-r--r--lib/chef/provider/template/content.rb14
-rw-r--r--lib/chef/provider/user/dscl.rb4
-rw-r--r--lib/chef/resource.rb2
-rw-r--r--lib/chef/resource/windows_share.rb2
-rw-r--r--lib/chef/run_context/cookbook_compiler.rb2
7 files changed, 14 insertions, 14 deletions
diff --git a/lib/chef/property.rb b/lib/chef/property.rb
index 720fa70dd1..819b82f384 100644
--- a/lib/chef/property.rb
+++ b/lib/chef/property.rb
@@ -706,7 +706,7 @@ class Chef
# As of this writing, `name` is the only Chef::Resource property created with the
# `property` definition, but this will allow for future properties to be extended
# as needed.
- !Chef::Resource.properties.keys.include?(name)
+ !Chef::Resource.properties.key?(name)
end
def exec_in_resource(resource, proc, *args)
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
index be4f1a149c..0f2c236166 100644
--- a/lib/chef/provider/package/rubygems.rb
+++ b/lib/chef/provider/package/rubygems.rb
@@ -188,7 +188,7 @@ class Chef
# Use the API that 'gem install' calls which does not pull down the rubygems universe
begin
rs = dependency_installer.resolve_dependencies gem_dependency.name, gem_dependency.requirement
- rs.specs.select { |s| s.name == gem_dependency.name }.first
+ rs.specs.find { |s| s.name == gem_dependency.name }
rescue Gem::UnsatisfiableDependencyError
nil
end
diff --git a/lib/chef/provider/template/content.rb b/lib/chef/provider/template/content.rb
index b4d62755c2..c3f95869e3 100644
--- a/lib/chef/provider/template/content.rb
+++ b/lib/chef/provider/template/content.rb
@@ -64,13 +64,13 @@ class Chef
context[:template_finder] = template_finder
# helper variables
- context[:cookbook_name] = new_resource.cookbook_name unless context.keys.include?(:coookbook_name)
- context[:recipe_name] = new_resource.recipe_name unless context.keys.include?(:recipe_name)
- context[:recipe_line_string] = new_resource.source_line unless context.keys.include?(:recipe_line_string)
- context[:recipe_path] = new_resource.source_line_file unless context.keys.include?(:recipe_path)
- context[:recipe_line] = new_resource.source_line_number unless context.keys.include?(:recipe_line)
- context[:template_name] = new_resource.source unless context.keys.include?(:template_name)
- context[:template_path] = template_location unless context.keys.include?(:template_path)
+ context[:cookbook_name] = new_resource.cookbook_name unless context.key?(:coookbook_name)
+ context[:recipe_name] = new_resource.recipe_name unless context.key?(:recipe_name)
+ context[:recipe_line_string] = new_resource.source_line unless context.key?(:recipe_line_string)
+ context[:recipe_path] = new_resource.source_line_file unless context.key?(:recipe_path)
+ context[:recipe_line] = new_resource.source_line_number unless context.key?(:recipe_line)
+ context[:template_name] = new_resource.source unless context.key?(:template_name)
+ context[:template_path] = template_location unless context.key?(:template_path)
context._extend_modules(new_resource.helper_modules)
output = context.render_template(template_location)
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index 4c056b00fd..7b86fa5269 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -562,7 +562,7 @@ in 'password', with the associated 'salt' and 'iterations'.")
# Sets a value in user information hash using Chef attributes as keys.
#
def dscl_set(user_hash, key, value)
- raise "Unknown dscl key #{key}" unless DSCL_PROPERTY_MAP.keys.include?(key)
+ raise "Unknown dscl key #{key}" unless DSCL_PROPERTY_MAP.key?(key)
user_hash[DSCL_PROPERTY_MAP[key]] = [ value ]
user_hash
@@ -572,7 +572,7 @@ in 'password', with the associated 'salt' and 'iterations'.")
# Gets a value from user information hash using Chef attributes as keys.
#
def dscl_get(user_hash, key)
- raise "Unknown dscl key #{key}" unless DSCL_PROPERTY_MAP.keys.include?(key)
+ raise "Unknown dscl key #{key}" unless DSCL_PROPERTY_MAP.key?(key)
# DSCL values are set as arrays
value = user_hash[DSCL_PROPERTY_MAP[key]]
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index bd6757c6f7..07003e9431 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -672,7 +672,7 @@ class Chef
ivars = instance_variables.map(&:to_sym) - HIDDEN_IVARS
ivars.each do |ivar|
iv = ivar.to_s.sub(/^@/, "")
- if all_props.keys.include?(iv)
+ if all_props.key?(iv)
text << " #{iv} #{all_props[iv]}\n"
elsif (value = instance_variable_get(ivar)) && !(value.respond_to?(:empty?) && value.empty?)
text << " #{iv} #{value_to_text(value)}\n"
diff --git a/lib/chef/resource/windows_share.rb b/lib/chef/resource/windows_share.rb
index 10533382f9..5e88f20967 100644
--- a/lib/chef/resource/windows_share.rb
+++ b/lib/chef/resource/windows_share.rb
@@ -59,7 +59,7 @@ class Chef
# Specifies the path of the location of the folder to share. The path must be fully qualified. Relative paths or paths that contain wildcard characters are not permitted.
property :path, String,
description: "The path of the folder to share. Required when creating. If the share already exists on a different path then it is deleted and re-created.",
- coerce: proc { |p| p.gsub(%r{/}, "\\") || p }
+ coerce: proc { |p| p.tr("/", "\\") || p }
# Specifies an optional description of the SMB share. A description of the share is displayed by running the Get-SmbShare cmdlet. The description may not contain more than 256 characters.
property :description, String,
diff --git a/lib/chef/run_context/cookbook_compiler.rb b/lib/chef/run_context/cookbook_compiler.rb
index 9d8ea87360..e1e4c215ad 100644
--- a/lib/chef/run_context/cookbook_compiler.rb
+++ b/lib/chef/run_context/cookbook_compiler.rb
@@ -325,7 +325,7 @@ class Chef
def count_files_by_segment(segment, root_alias = nil)
cookbook_collection.inject(0) do |count, cookbook_by_name|
- count + cookbook_by_name[1].segment_filenames(segment).size + (root_alias ? cookbook_by_name[1].files_for(:root_files).select { |record| record[:name] == root_alias }.size : 0)
+ count + cookbook_by_name[1].segment_filenames(segment).size + (root_alias ? cookbook_by_name[1].files_for(:root_files).count { |record| record[:name] == root_alias } : 0)
end
end