summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/action_collection.rb4
-rw-r--r--lib/chef/application.rb6
-rw-r--r--lib/chef/chef_fs/chef_fs_data_store.rb8
-rw-r--r--lib/chef/chef_fs/command_line.rb10
-rw-r--r--lib/chef/chef_fs/config.rb2
-rw-r--r--lib/chef/chef_fs/data_handler/data_handler_base.rb4
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/acls_dir.rb4
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb4
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb4
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb4
-rw-r--r--lib/chef/chef_fs/file_system/repository/file_system_entry.rb2
-rw-r--r--lib/chef/cookbook/manifest_v0.rb4
-rw-r--r--lib/chef/cookbook/manifest_v2.rb2
-rw-r--r--lib/chef/cookbook/metadata.rb4
-rw-r--r--lib/chef/cookbook/synchronizer.rb4
-rw-r--r--lib/chef/cookbook/syntax_check.rb4
-rw-r--r--lib/chef/cookbook_manifest.rb4
-rw-r--r--lib/chef/cookbook_version.rb8
-rw-r--r--lib/chef/data_collector/config_validation.rb2
-rw-r--r--lib/chef/deprecated.rb2
-rw-r--r--lib/chef/dsl/platform_introspection.rb4
-rw-r--r--lib/chef/encrypted_data_bag_item/decryptor.rb2
-rw-r--r--lib/chef/event_loggers/base.rb4
-rw-r--r--lib/chef/exceptions.rb4
-rw-r--r--lib/chef/file_access_control/unix.rb4
-rw-r--r--lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb4
-rw-r--r--lib/chef/guard_interpreter/resource_guard_interpreter.rb2
-rw-r--r--lib/chef/http.rb8
-rw-r--r--lib/chef/http/json_input.rb2
-rw-r--r--lib/chef/knife.rb6
-rw-r--r--lib/chef/knife/bootstrap.rb14
-rw-r--r--lib/chef/knife/config_list_profiles.rb8
-rw-r--r--lib/chef/knife/cookbook_delete.rb8
-rw-r--r--lib/chef/knife/cookbook_download.rb2
-rw-r--r--lib/chef/knife/cookbook_upload.rb8
-rw-r--r--lib/chef/knife/core/gem_glob_loader.rb8
-rw-r--r--lib/chef/knife/core/generic_presenter.rb4
-rw-r--r--lib/chef/knife/core/node_editor.rb4
-rw-r--r--lib/chef/knife/core/object_loader.rb2
-rw-r--r--lib/chef/knife/core/subcommand_loader.rb2
-rw-r--r--lib/chef/knife/diff.rb4
-rw-r--r--lib/chef/knife/environment_compare.rb8
-rw-r--r--lib/chef/knife/exec.rb2
-rw-r--r--lib/chef/knife/list.rb8
-rw-r--r--lib/chef/knife/node_run_list_add.rb4
-rw-r--r--lib/chef/knife/node_run_list_remove.rb4
-rw-r--r--lib/chef/knife/node_run_list_set.rb4
-rw-r--r--lib/chef/knife/role_env_run_list_add.rb6
-rw-r--r--lib/chef/knife/role_env_run_list_set.rb6
-rw-r--r--lib/chef/knife/role_run_list_add.rb6
-rw-r--r--lib/chef/knife/role_run_list_set.rb6
-rw-r--r--lib/chef/knife/show.rb4
-rw-r--r--lib/chef/knife/ssh.rb4
-rw-r--r--lib/chef/knife/status.rb4
-rw-r--r--lib/chef/knife/supermarket_list.rb2
-rw-r--r--lib/chef/mash.rb4
-rw-r--r--lib/chef/mixin/convert_to_class_name.rb6
-rw-r--r--lib/chef/mixin/params_validate.rb4
-rw-r--r--lib/chef/mixin/powershell_type_coercions.rb8
-rw-r--r--lib/chef/mixin/properties.rb2
-rw-r--r--lib/chef/mixin/versioned_api.rb4
-rw-r--r--lib/chef/mixin/which.rb8
-rw-r--r--lib/chef/node.rb2
-rw-r--r--lib/chef/node/attribute.rb16
-rw-r--r--lib/chef/node/common_api.rb8
-rw-r--r--lib/chef/node/immutable_collections.rb4
-rw-r--r--lib/chef/node_map.rb6
-rw-r--r--lib/chef/policy_builder/expand_node_object.rb4
-rw-r--r--lib/chef/policy_builder/policyfile.rb16
-rw-r--r--lib/chef/property.rb4
-rw-r--r--lib/chef/provider.rb12
-rw-r--r--lib/chef/provider/apt_repository.rb12
-rw-r--r--lib/chef/provider/dsc_resource.rb6
-rw-r--r--lib/chef/provider/dsc_script.rb10
-rw-r--r--lib/chef/provider/file.rb6
-rw-r--r--lib/chef/provider/git.rb6
-rw-r--r--lib/chef/provider/group.rb4
-rw-r--r--lib/chef/provider/group/dscl.rb6
-rw-r--r--lib/chef/provider/group/gpasswd.rb2
-rw-r--r--lib/chef/provider/group/groupadd.rb2
-rw-r--r--lib/chef/provider/group/pw.rb2
-rw-r--r--lib/chef/provider/group/solaris.rb2
-rw-r--r--lib/chef/provider/group/suse.rb4
-rw-r--r--lib/chef/provider/group/usermod.rb6
-rw-r--r--lib/chef/provider/ifconfig.rb2
-rw-r--r--lib/chef/provider/ifconfig/aix.rb2
-rw-r--r--lib/chef/provider/launchd.rb2
-rw-r--r--lib/chef/provider/mount/solaris.rb6
-rw-r--r--lib/chef/provider/osx_profile.rb4
-rw-r--r--lib/chef/provider/package.rb4
-rw-r--r--lib/chef/provider/package/apt.rb14
-rw-r--r--lib/chef/provider/package/bff.rb4
-rw-r--r--lib/chef/provider/package/cab.rb12
-rw-r--r--lib/chef/provider/package/chocolatey.rb2
-rw-r--r--lib/chef/provider/package/dnf.rb2
-rw-r--r--lib/chef/provider/package/dnf/python_helper.rb4
-rw-r--r--lib/chef/provider/package/dpkg.rb8
-rw-r--r--lib/chef/provider/package/ips.rb2
-rw-r--r--lib/chef/provider/package/msu.rb4
-rw-r--r--lib/chef/provider/package/openbsd.rb2
-rw-r--r--lib/chef/provider/package/portage.rb4
-rw-r--r--lib/chef/provider/package/powershell.rb2
-rw-r--r--lib/chef/provider/package/rpm.rb4
-rw-r--r--lib/chef/provider/package/rubygems.rb18
-rw-r--r--lib/chef/provider/package/snap.rb6
-rw-r--r--lib/chef/provider/package/solaris.rb4
-rw-r--r--lib/chef/provider/package/windows.rb4
-rw-r--r--lib/chef/provider/package/yum.rb2
-rw-r--r--lib/chef/provider/package/yum/python_helper.rb4
-rw-r--r--lib/chef/provider/package/zypper.rb4
-rw-r--r--lib/chef/provider/registry_key.rb12
-rw-r--r--lib/chef/provider/remote_file/http.rb4
-rw-r--r--lib/chef/provider/service.rb4
-rw-r--r--lib/chef/provider/service/aix.rb2
-rw-r--r--lib/chef/provider/service/aixinit.rb4
-rw-r--r--lib/chef/provider/service/debian.rb4
-rw-r--r--lib/chef/provider/service/freebsd.rb8
-rw-r--r--lib/chef/provider/service/gentoo.rb8
-rw-r--r--lib/chef/provider/service/macosx.rb14
-rw-r--r--lib/chef/provider/service/openbsd.rb6
-rw-r--r--lib/chef/provider/service/redhat.rb4
-rw-r--r--lib/chef/provider/service/simple.rb12
-rw-r--r--lib/chef/provider/service/systemd.rb2
-rw-r--r--lib/chef/provider/service/upstart.rb4
-rw-r--r--lib/chef/provider/subversion.rb6
-rw-r--r--lib/chef/provider/systemd_unit.rb2
-rw-r--r--lib/chef/provider/template.rb2
-rw-r--r--lib/chef/provider/user.rb6
-rw-r--r--lib/chef/provider/user/dscl.rb4
-rw-r--r--lib/chef/provider/windows_env.rb4
-rw-r--r--lib/chef/provider/windows_task.rb12
-rw-r--r--lib/chef/provider/zypper_repository.rb2
-rw-r--r--lib/chef/resource.rb4
-rw-r--r--lib/chef/resource/apt_preference.rb2
-rw-r--r--lib/chef/resource/apt_repository.rb2
-rw-r--r--lib/chef/resource/apt_update.rb2
-rw-r--r--lib/chef/resource/build_essential.rb2
-rw-r--r--lib/chef/resource/chef_handler.rb2
-rw-r--r--lib/chef/resource/dmg_package.rb2
-rw-r--r--lib/chef/resource/dsc_resource.rb4
-rw-r--r--lib/chef/resource/homebrew_cask.rb2
-rw-r--r--lib/chef/resource/homebrew_tap.rb2
-rw-r--r--lib/chef/resource/hostname.rb10
-rw-r--r--lib/chef/resource/locale.rb4
-rw-r--r--lib/chef/resource/macos_userdefaults.rb4
-rw-r--r--lib/chef/resource/ohai_hint.rb2
-rw-r--r--lib/chef/resource/openssl_dhparam.rb2
-rw-r--r--lib/chef/resource/openssl_rsa_private_key.rb4
-rw-r--r--lib/chef/resource/openssl_rsa_public_key.rb2
-rw-r--r--lib/chef/resource/openssl_x509_certificate.rb2
-rw-r--r--lib/chef/resource/registry_key.rb2
-rw-r--r--lib/chef/resource/rhsm_errata.rb2
-rw-r--r--lib/chef/resource/rhsm_errata_level.rb2
-rw-r--r--lib/chef/resource/rhsm_register.rb4
-rw-r--r--lib/chef/resource/rhsm_repo.rb2
-rw-r--r--lib/chef/resource/rhsm_subscription.rb2
-rw-r--r--lib/chef/resource/sudo.rb6
-rw-r--r--lib/chef/resource/swap_file.rb2
-rw-r--r--lib/chef/resource/sysctl.rb4
-rw-r--r--lib/chef/resource/systemd_unit.rb6
-rw-r--r--lib/chef/resource/timezone.rb2
-rw-r--r--lib/chef/resource/windows_auto_run.rb2
-rw-r--r--lib/chef/resource/windows_feature.rb2
-rw-r--r--lib/chef/resource/windows_feature_dism.rb2
-rw-r--r--lib/chef/resource/windows_feature_powershell.rb2
-rw-r--r--lib/chef/resource/windows_font.rb10
-rw-r--r--lib/chef/resource/windows_package.rb2
-rw-r--r--lib/chef/resource/windows_pagefile.rb2
-rw-r--r--lib/chef/resource/windows_path.rb2
-rw-r--r--lib/chef/resource/windows_printer.rb2
-rw-r--r--lib/chef/resource/windows_printer_port.rb2
-rw-r--r--lib/chef/resource/windows_service.rb2
-rw-r--r--lib/chef/resource/windows_shortcut.rb2
-rw-r--r--lib/chef/resource/windows_task.rb10
-rw-r--r--lib/chef/resource/yum_repository.rb2
-rw-r--r--lib/chef/resource/zypper_repository.rb4
-rw-r--r--lib/chef/resource_reporter.rb4
-rw-r--r--lib/chef/run_list.rb4
-rw-r--r--lib/chef/run_list/versioned_recipe_list.rb4
-rw-r--r--lib/chef/runner.rb2
-rw-r--r--lib/chef/search/query.rb2
-rw-r--r--lib/chef/shell/ext.rb4
-rw-r--r--lib/chef/util/backup.rb4
-rw-r--r--lib/chef/util/dsc/resource_store.rb8
-rw-r--r--lib/chef/util/powershell/cmdlet.rb4
-rw-r--r--lib/chef/util/threaded_job_queue.rb6
-rw-r--r--lib/chef/win32/registry.rb4
-rw-r--r--lib/chef/win32/security/acl.rb2
-rw-r--r--lib/chef/win32/security/sid.rb8
190 files changed, 440 insertions, 440 deletions
diff --git a/lib/chef/action_collection.rb b/lib/chef/action_collection.rb
index 7b1997cfaf..892a4e5a51 100644
--- a/lib/chef/action_collection.rb
+++ b/lib/chef/action_collection.rb
@@ -104,14 +104,14 @@ class Chef
# @return [Chef::ActionCollection]
#
def filtered_collection(max_nesting: nil, up_to_date: true, skipped: true, updated: true, failed: true, unprocessed: true)
- subrecords = action_records.select do |rec|
+ subrecords = action_records.select { |rec|
( max_nesting.nil? || rec.nesting_level <= max_nesting ) &&
( rec.status == :up_to_date && up_to_date ||
rec.status == :skipped && skipped ||
rec.status == :updated && updated ||
rec.status == :failed && failed ||
rec.status == :unprocessed && unprocessed )
- end
+ }
self.class.new(events, run_context, subrecords)
end
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index a632a97319..5c998d303b 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -323,7 +323,7 @@ class Chef
def fork_chef_client
logger.info "Forking #{Chef::Dist::PRODUCT} instance to converge..."
- pid = fork do
+ pid = fork {
# Want to allow forked processes to finish converging when
# TERM singal is received (exit gracefully)
trap("TERM") do
@@ -342,7 +342,7 @@ class Chef
else
exit 0
end
- end
+ }
logger.trace "Fork successful. Waiting for new chef pid: #{pid}"
result = Process.waitpid2(pid)
handle_child_exit(result)
@@ -367,7 +367,7 @@ class Chef
rescue Exception => error
logger.fatal("Configuration error #{error.class}: #{error.message}")
filtered_trace = error.backtrace.grep(/#{Regexp.escape(config_file_path)}/)
- filtered_trace.each { |line| logger.fatal(" " + line ) }
+ filtered_trace.each do |line| logger.fatal(" " + line ) end
Chef::Application.fatal!("Aborting due to error in '#{config_file_path}'", error)
end
diff --git a/lib/chef/chef_fs/chef_fs_data_store.rb b/lib/chef/chef_fs/chef_fs_data_store.rb
index 807d5e0155..9cf5dfbf81 100644
--- a/lib/chef/chef_fs/chef_fs_data_store.rb
+++ b/lib/chef/chef_fs/chef_fs_data_store.rb
@@ -541,12 +541,12 @@ class Chef
elsif %w{cookbooks cookbook_artifacts}.include?(path[0]) && path.length == 2
if chef_fs.versioned_cookbooks || path[0] == "cookbook_artifacts"
- result = with_entry([ path[0] ]) do |entry|
+ result = with_entry([ path[0] ]) { |entry|
# list /cookbooks/name = filter /cookbooks/name-version down to name
entry.children.map { |child| split_name_version(child.name) }
.select { |name, version| name == path[1] }
.map { |name, version| version }
- end
+ }
if result.empty?
raise ChefZero::DataStore::DataNotFoundError.new(path)
end
@@ -559,7 +559,7 @@ class Chef
end
else
- result = with_entry(path) do |entry|
+ result = with_entry(path) { |entry|
begin
entry.children.map { |c| zero_filename(c) }.sort
rescue Chef::ChefFS::FileSystem::NotFoundError => e
@@ -570,7 +570,7 @@ class Chef
raise ChefZero::DataStore::DataNotFoundError.new(to_zero_path(e.entry), e)
end
end
- end
+ }
# Older versions of chef-zero do not understand policies and cookbook_artifacts,
# don't give that stuff to them
diff --git a/lib/chef/chef_fs/command_line.rb b/lib/chef/chef_fs/command_line.rb
index 265b95e22d..5ae4010f9a 100644
--- a/lib/chef/chef_fs/command_line.rb
+++ b/lib/chef/chef_fs/command_line.rb
@@ -140,9 +140,9 @@ class Chef
end
def self.diff(pattern, old_root, new_root, recurse_depth, get_content)
- Chef::ChefFS::Parallelizer.parallelize(Chef::ChefFS::FileSystem.list_pairs(pattern, old_root, new_root)) do |old_entry, new_entry|
+ Chef::ChefFS::Parallelizer.parallelize(Chef::ChefFS::FileSystem.list_pairs(pattern, old_root, new_root)) { |old_entry, new_entry|
diff_entries(old_entry, new_entry, recurse_depth, get_content)
- end.flatten(1)
+ }.flatten(1)
end
# Diff two known entries (could be files or dirs)
@@ -153,9 +153,9 @@ class Chef
if recurse_depth == 0
[ [ :common_subdirectories, old_entry, new_entry ] ]
else
- Chef::ChefFS::Parallelizer.parallelize(Chef::ChefFS::FileSystem.child_pairs(old_entry, new_entry)) do |old_child, new_child|
+ Chef::ChefFS::Parallelizer.parallelize(Chef::ChefFS::FileSystem.child_pairs(old_entry, new_entry)) { |old_child, new_child|
Chef::ChefFS::CommandLine.diff_entries(old_child, new_child, recurse_depth ? recurse_depth - 1 : nil, get_content)
- end.flatten(1)
+ }.flatten(1)
end
# If old is a directory and new is a file
@@ -255,7 +255,7 @@ class Chef
json_object.map { |o| sort_keys(o) }
elsif json_object.is_a?(Hash)
new_hash = {}
- json_object.keys.sort.each { |key| new_hash[key] = sort_keys(json_object[key]) }
+ json_object.keys.sort.each do |key| new_hash[key] = sort_keys(json_object[key]) end
new_hash
else
json_object
diff --git a/lib/chef/chef_fs/config.rb b/lib/chef/chef_fs/config.rb
index 83e82bfa0c..a3f1e77e8c 100644
--- a/lib/chef/chef_fs/config.rb
+++ b/lib/chef/chef_fs/config.rb
@@ -45,7 +45,7 @@ class Chef
"policies" => "policy",
"policy_groups" => "policy_group",
}.freeze
- INFLECTIONS.each { |k, v| k.freeze; v.freeze }
+ INFLECTIONS.each do |k, v| k.freeze; v.freeze end
INFLECTIONS.freeze
# ChefFS supports three modes of operation: "static", "everything", and
diff --git a/lib/chef/chef_fs/data_handler/data_handler_base.rb b/lib/chef/chef_fs/data_handler/data_handler_base.rb
index d51e54e8ab..8913c35d0f 100644
--- a/lib/chef/chef_fs/data_handler/data_handler_base.rb
+++ b/lib/chef/chef_fs/data_handler/data_handler_base.rb
@@ -96,7 +96,7 @@ class Chef
# name to recipe[name]. Then calls uniq on the result.
#
def normalize_run_list(run_list)
- run_list.map do |item|
+ run_list.map { |item|
case item.to_s
when /^recipe\[.*\]$/
item # explicit recipe
@@ -105,7 +105,7 @@ class Chef
else
"recipe[#{item}]"
end
- end.uniq
+ }.uniq
end
#
diff --git a/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb b/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb
index 03b003586b..f24c6bc9f8 100644
--- a/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb
@@ -48,7 +48,7 @@ class Chef
def children
if @children.nil?
- @children = ENTITY_TYPES.map do |entity_type|
+ @children = ENTITY_TYPES.map { |entity_type|
# All three of these can be versioned (NAME-VERSION), but only have
# one ACL that covers them all (NAME.json).
case entity_type
@@ -59,7 +59,7 @@ class Chef
else
AclDir.new(entity_type, self)
end
- end
+ }
@children << AclEntry.new("organization.json", self, true) # the org acl is retrieved as GET /organizations/ORGNAME/ANYTHINGATALL/_acl
end
@children
diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
index 15729b7206..0db52326ab 100644
--- a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb
@@ -62,7 +62,7 @@ class Chef
# we need to make sure we don't rethrow the exception. (child(name)
# is not supposed to fail.)
- children.find { |child| child.name == name }
+ children.find do |child| child.name == name end
rescue Chef::ChefFS::FileSystem::NotFoundError
nil
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb b/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb
index 76897df093..b9b9c7cb41 100644
--- a/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb
@@ -28,9 +28,9 @@ class Chef
class NodesDir < RestListDir
# Identical to RestListDir.children, except supports environments
def children
- @children ||= root.get_json(env_api_path).keys.sort.map do |key|
+ @children ||= root.get_json(env_api_path).keys.sort.map { |key|
make_child_entry(key, true)
- end
+ }
rescue Timeout::Error => e
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "Timeout retrieving children: #{e}")
rescue Net::HTTPClientException => e
diff --git a/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb b/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb
index d2c5bdc9b7..cf672e3c22 100644
--- a/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb
@@ -72,9 +72,9 @@ class Chef
#
def children
# Grab the names of the children, append json, and make child entries
- @children ||= root.get_json(api_path).keys.sort.map do |key|
+ @children ||= root.get_json(api_path).keys.sort.map { |key|
make_child_entry(key, true)
- end
+ }
rescue Timeout::Error => e
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:children, self, e, "Timeout retrieving children: #{e}")
rescue Net::HTTPClientException => e
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb
index de1f071fb3..a05923b017 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb
@@ -163,11 +163,11 @@ class Chef
def root_dir
existing_paths = root_paths.select { |path| File.exists?(path) }
if existing_paths.size > 0
- MultiplexedDir.new(existing_paths.map do |path|
+ MultiplexedDir.new(existing_paths.map { |path|
dir = FileSystemEntry.new(name, parent, path)
dir.write_pretty_json = !!write_pretty_json
dir
- end)
+ })
end
end
diff --git a/lib/chef/chef_fs/file_system/repository/file_system_entry.rb b/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
index 7c2d3e1522..279e2a801f 100644
--- a/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
+++ b/lib/chef/chef_fs/file_system/repository/file_system_entry.rb
@@ -82,7 +82,7 @@ class Chef
# Except cookbooks and data bag dirs, all things must be json files
Dir.entries(file_path).sort
.map { |child_name| make_child_entry(child_name) }
- .select { |new_child| new_child.fs_entry_valid? && can_have_child?(new_child.name, new_child.dir?) }
+ .select do |new_child| new_child.fs_entry_valid? && can_have_child?(new_child.name, new_child.dir?) end
rescue Errno::ENOENT
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
end
diff --git a/lib/chef/cookbook/manifest_v0.rb b/lib/chef/cookbook/manifest_v0.rb
index a4c60e5827..4edf5d3dd2 100644
--- a/lib/chef/cookbook/manifest_v0.rb
+++ b/lib/chef/cookbook/manifest_v0.rb
@@ -30,7 +30,7 @@ class Chef
def from_hash(hash)
response = Mash.new(hash)
- response[:all_files] = COOKBOOK_SEGMENTS.inject([]) do |memo, segment|
+ response[:all_files] = COOKBOOK_SEGMENTS.inject([]) { |memo, segment|
next memo if hash[segment].nil? || hash[segment].empty?
hash[segment].each do |file|
@@ -39,7 +39,7 @@ class Chef
end
response.delete(segment)
memo
- end
+ }
response
end
diff --git a/lib/chef/cookbook/manifest_v2.rb b/lib/chef/cookbook/manifest_v2.rb
index 2b98c3550c..ff7b9605a0 100644
--- a/lib/chef/cookbook/manifest_v2.rb
+++ b/lib/chef/cookbook/manifest_v2.rb
@@ -31,7 +31,7 @@ class Chef
def to_h(manifest)
result = manifest.manifest.dup
- result["all_files"].map! { |file| file.delete("full_path"); file }
+ result["all_files"].map! do |file| file.delete("full_path"); file end
result["frozen?"] = manifest.frozen_version?
result["chef_type"] = "cookbook_version"
result.to_hash
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb
index d5821a799e..617607df98 100644
--- a/lib/chef/cookbook/metadata.rb
+++ b/lib/chef/cookbook/metadata.rb
@@ -397,9 +397,9 @@ class Chef
# @return [Array<Array<String>]] Simple object representation of version constraints (for json)
def gem_requirements_to_array(*deps)
deps.map do |dep|
- dep.requirement.requirements.map do |op, version|
+ dep.requirement.requirements.map { |op, version|
"#{op} #{version}"
- end.sort
+ }.sort
end
end
diff --git a/lib/chef/cookbook/synchronizer.rb b/lib/chef/cookbook/synchronizer.rb
index b6bcd2c150..72762a4189 100644
--- a/lib/chef/cookbook/synchronizer.rb
+++ b/lib/chef/cookbook/synchronizer.rb
@@ -122,7 +122,7 @@ class Chef
[]
end
- @files ||= cookbooks.inject([]) do |memo, cookbook|
+ @files ||= cookbooks.inject([]) { |memo, cookbook|
cookbook.each_file do |manifest_record|
part = manifest_record[:name].split("/")[0]
if lazy.include?(part)
@@ -134,7 +134,7 @@ class Chef
end
end
memo
- end
+ }
end
def files_by_cookbook
diff --git a/lib/chef/cookbook/syntax_check.rb b/lib/chef/cookbook/syntax_check.rb
index 6c1f710f6d..8b8c1e85d0 100644
--- a/lib/chef/cookbook/syntax_check.rb
+++ b/lib/chef/cookbook/syntax_check.rb
@@ -214,7 +214,7 @@ class Chef
def invalid_erb_file(erb_file, error_message)
file_relative_path = erb_file[/^#{Regexp.escape(cookbook_path + File::Separator)}(.*)/, 1]
Chef::Log.fatal("Erb template #{file_relative_path} has a syntax error:")
- error_message.each_line { |l| Chef::Log.fatal(l.chomp) }
+ error_message.each_line do |l| Chef::Log.fatal(l.chomp) end
nil
end
@@ -249,7 +249,7 @@ class Chef
def invalid_ruby_file(ruby_file, error_message)
file_relative_path = ruby_file[/^#{Regexp.escape(cookbook_path + File::Separator)}(.*)/, 1]
Chef::Log.fatal("Cookbook file #{file_relative_path} has a ruby syntax error:")
- error_message.each_line { |l| Chef::Log.fatal(l.chomp) }
+ error_message.each_line do |l| Chef::Log.fatal(l.chomp) end
false
end
diff --git a/lib/chef/cookbook_manifest.rb b/lib/chef/cookbook_manifest.rb
index b16eeccbca..2005c67a5c 100644
--- a/lib/chef/cookbook_manifest.rb
+++ b/lib/chef/cookbook_manifest.rb
@@ -192,7 +192,7 @@ class Chef
def by_parent_directory
@by_parent_directory ||=
- manifest[:all_files].inject({}) do |memo, file|
+ manifest[:all_files].inject({}) { |memo, file|
parts = file[:name].split("/")
parent = if parts.length == 1
"root_files"
@@ -203,7 +203,7 @@ class Chef
memo[parent] ||= []
memo[parent] << file
memo
- end
+ }
end
def root_files
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index d546724fa0..0adfff3a48 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -249,13 +249,13 @@ class Chef
error_message << error_locations.join("\n")
existing_files = segment_filenames(segment)
# Strip the root_dir prefix off all files for readability
- pretty_existing_files = existing_files.map do |path|
+ pretty_existing_files = existing_files.map { |path|
if root_dir
path[root_dir.length + 1..-1]
else
path
end
- end
+ }
# Show the files that the cookbook does have. If the user made a typo,
# hopefully they'll see it here.
unless pretty_existing_files.empty?
@@ -280,7 +280,7 @@ class Chef
def relative_filenames_in_preferred_directory(node, segment, dirname)
preferences = preferences_for_path(node, segment, dirname)
filenames_by_pref = {}
- preferences.each { |pref| filenames_by_pref[pref] = [] }
+ preferences.each do |pref| filenames_by_pref[pref] = [] end
files_for(segment).each do |manifest_record|
manifest_record_path = manifest_record[:path]
@@ -320,7 +320,7 @@ class Chef
def preferred_manifest_records_for_directory(node, segment, dirname)
preferences = preferences_for_path(node, segment, dirname)
records_by_pref = {}
- preferences.each { |pref| records_by_pref[pref] = [] }
+ preferences.each do |pref| records_by_pref[pref] = [] end
files_for(segment).each do |manifest_record|
manifest_record_path = manifest_record[:path]
diff --git a/lib/chef/data_collector/config_validation.rb b/lib/chef/data_collector/config_validation.rb
index 8bc409f03c..931f1a8d46 100644
--- a/lib/chef/data_collector/config_validation.rb
+++ b/lib/chef/data_collector/config_validation.rb
@@ -105,7 +105,7 @@ class Chef
# validate an output_location file
def validate_file!(file)
- open(file, "a") {}
+ open(file, "a") do end
rescue Errno::ENOENT
raise Chef::Exceptions::ConfigurationError,
"Chef::Config[:data_collector][:output_locations][:files] contains the location #{file}, which is a non existent file path."
diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb
index cda8e197d3..3f855530eb 100644
--- a/lib/chef/deprecated.rb
+++ b/lib/chef/deprecated.rb
@@ -80,7 +80,7 @@ class Chef
# Don't buffer the whole file in memory, so read it one line at a time.
line_no = $2.to_i
location_file = ::File.open($1)
- (line_no - 1).times { location_file.readline } # Read all the lines we don't care about.
+ (line_no - 1).times do location_file.readline end # Read all the lines we don't care about.
relevant_line = location_file.readline
relevant_line.match?(/#.*chef:silence_deprecation($|[^:]|:#{self.class.deprecation_key})/)
end
diff --git a/lib/chef/dsl/platform_introspection.rb b/lib/chef/dsl/platform_introspection.rb
index 3f79782798..50ab57cb4f 100644
--- a/lib/chef/dsl/platform_introspection.rb
+++ b/lib/chef/dsl/platform_introspection.rb
@@ -110,7 +110,7 @@ class Chef
@values["default"] = value
else
assert_valid_platform_values!(platforms, value)
- Array(platforms).each { |platform| @values[platform.to_s] = normalize_keys(value) }
+ Array(platforms).each do |platform| @values[platform.to_s] = normalize_keys(value) end
value
end
end
@@ -211,7 +211,7 @@ class Chef
if platform_family.to_s == "default"
@values["default"] = value
else
- Array(platform_family).each { |family| @values[family.to_s] = value }
+ Array(platform_family).each do |family| @values[family.to_s] = value end
value
end
end
diff --git a/lib/chef/encrypted_data_bag_item/decryptor.rb b/lib/chef/encrypted_data_bag_item/decryptor.rb
index 1ddc99391d..88c800341c 100644
--- a/lib/chef/encrypted_data_bag_item/decryptor.rb
+++ b/lib/chef/encrypted_data_bag_item/decryptor.rb
@@ -192,7 +192,7 @@ class Chef::EncryptedDataBagItem
expected_bytes = expected_hmac.bytes.to_a
candidate_hmac_bytes = Base64.decode64(@encrypted_data["hmac"]).bytes.to_a
valid = expected_bytes.size ^ candidate_hmac_bytes.size
- expected_bytes.zip(candidate_hmac_bytes) { |x, y| valid |= x ^ y.to_i }
+ expected_bytes.zip(candidate_hmac_bytes) do |x, y| valid |= x ^ y.to_i end
valid == 0
end
end
diff --git a/lib/chef/event_loggers/base.rb b/lib/chef/event_loggers/base.rb
index b1a2f84988..5a29c9f7fe 100644
--- a/lib/chef/event_loggers/base.rb
+++ b/lib/chef/event_loggers/base.rb
@@ -36,9 +36,9 @@ class Chef
end
def self.available_event_loggers
- event_loggers_by_name.select do |key, val|
+ event_loggers_by_name.select { |key, val|
val.available?
- end.keys
+ }.keys
end
def self.new(name)
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
index 2d7ac374cb..18423245a7 100644
--- a/lib/chef/exceptions.rb
+++ b/lib/chef/exceptions.rb
@@ -491,13 +491,13 @@ class Chef
attr_reader :resources_found
def initialize(resources_found)
@resources_found = resources_found
- matches_info = @resources_found.each do |r|
+ matches_info = @resources_found.each { |r|
if r["Module"].nil?
"Resource #{r["Name"]} was found in #{r["Module"]["Name"]}"
else
"Resource #{r["Name"]} is a binary resource"
end
- end
+ }
super "Found multiple resources matching #{matches_info[0]["Module"]["Name"]}:\n#{(matches_info.map { |f| f["Module"]["Version"] }).uniq.join("\n")}"
end
end
diff --git a/lib/chef/file_access_control/unix.rb b/lib/chef/file_access_control/unix.rb
index 4d3ac84eb0..77782fb55f 100644
--- a/lib/chef/file_access_control/unix.rb
+++ b/lib/chef/file_access_control/unix.rb
@@ -129,7 +129,7 @@ class Chef
end
rescue ArgumentError
provider.requirements.assert(:create, :create_if_missing, :touch) do |a|
- a.assertion { false }
+ a.assertion do false end
a.failure_message(Chef::Exceptions::GroupIDNotFound, "cannot determine group id for '#{resource.group}', does the group exist on this system?")
a.whyrun("Assuming group #{resource.group} would have been created")
end
@@ -278,7 +278,7 @@ class Chef
end
rescue ArgumentError
provider.requirements.assert(:create, :create_if_missing, :touch) do |a|
- a.assertion { false }
+ a.assertion do false end
a.failure_message(Chef::Exceptions::UserIDNotFound, "cannot determine user id for '#{resource.owner}', does the user exist on this system?")
a.whyrun("Assuming user #{resource.owner} would have been created")
end
diff --git a/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb b/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
index e33e5cea1a..4672f15226 100644
--- a/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
@@ -60,9 +60,9 @@ class Chef
end
def missing_roles_explained
- run_list_expansion.missing_roles_with_including_role.map do |role, includer|
+ run_list_expansion.missing_roles_with_including_role.map { |role, includer|
"* #{role} included by '#{includer}'"
- end.join("\n")
+ }.join("\n")
end
def run_list_expansion
diff --git a/lib/chef/guard_interpreter/resource_guard_interpreter.rb b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
index adab16f5bf..5400f053ce 100644
--- a/lib/chef/guard_interpreter/resource_guard_interpreter.rb
+++ b/lib/chef/guard_interpreter/resource_guard_interpreter.rb
@@ -71,7 +71,7 @@ class Chef
# Coerce to an array to be safe. This could happen with a legacy
# resource or something overriding the default_action code in a
# subclass.
- Array(run_action).each { |action_to_run| @resource.run_action(action_to_run) }
+ Array(run_action).each do |action_to_run| @resource.run_action(action_to_run) end
resource_updated = @resource.updated
rescue Mixlib::ShellOut::ShellCommandFailed
resource_updated = nil
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index 5546156031..8a2eea703a 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -179,12 +179,12 @@ class Chef
method = :GET
method, url, processed_headers, data = apply_request_middleware(method, url, headers, data)
- response, rest_request, return_value = send_http_request(method, url, processed_headers, data) do |http_response|
+ response, rest_request, return_value = send_http_request(method, url, processed_headers, data) { |http_response|
if http_response.is_a?(Net::HTTPSuccess)
tempfile = stream_to_tempfile(url, http_response, tempfile, &progress_block)
end
apply_stream_complete_middleware(http_response, rest_request, return_value)
- end
+ }
return nil if response.is_a?(Net::HTTPRedirection)
unless response.is_a?(Net::HTTPSuccess)
@@ -226,12 +226,12 @@ class Chef
method = :GET
method, url, processed_headers, data = apply_request_middleware(method, url, headers, data)
- response, rest_request, return_value = send_http_request(method, url, processed_headers, data) do |http_response|
+ response, rest_request, return_value = send_http_request(method, url, processed_headers, data) { |http_response|
if http_response.is_a?(Net::HTTPSuccess)
tempfile = stream_to_tempfile(url, http_response, tempfile)
end
apply_stream_complete_middleware(http_response, rest_request, return_value)
- end
+ }
return nil if response.is_a?(Net::HTTPRedirection)
diff --git a/lib/chef/http/json_input.rb b/lib/chef/http/json_input.rb
index f7204d4ccc..fa7bc9c196 100644
--- a/lib/chef/http/json_input.rb
+++ b/lib/chef/http/json_input.rb
@@ -33,7 +33,7 @@ class Chef
def handle_request(method, url, headers = {}, data = false)
if data && should_encode_as_json?(headers)
- headers.delete_if { |key, _value| key.casecmp("content-type") == 0 }
+ headers.delete_if do |key, _value| key.casecmp("content-type") == 0 end
headers["Content-Type"] = "application/json"
json_opts = {}
json_opts[:validate_utf8] = opts[:validate_utf8] if opts.key?(:validate_utf8)
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index 28634d9e44..fd4db6e3d1 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -301,16 +301,16 @@ class Chef
# Mixlib::CLI ignores the embedded name_args
@name_args = parse_options(argv)
@name_args.delete(command_name_words.join("-"))
- @name_args.reject! { |name_arg| command_name_words.delete(name_arg) }
+ @name_args.reject! do |name_arg| command_name_words.delete(name_arg) end
# knife node run_list add requires that we have extra logic to handle
# the case that command name words could be joined by an underscore :/
command_name_joined = command_name_words.join("_")
- @name_args.reject! { |name_arg| command_name_joined == name_arg }
+ @name_args.reject! do |name_arg| command_name_joined == name_arg end
# Similar handling for hyphens.
command_name_joined = command_name_words.join("-")
- @name_args.reject! { |name_arg| command_name_joined == name_arg }
+ @name_args.reject! do |name_arg| command_name_joined == name_arg end
if config[:help]
msg opt_parser
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index e892f1f2c9..3eeb10fb61 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -502,14 +502,14 @@ class Chef
bootstrap_files = []
bootstrap_files << File.join(File.dirname(__FILE__), "bootstrap/templates", "#{template}.erb")
bootstrap_files << File.join(Knife.chef_config_dir, "bootstrap", "#{template}.erb") if Chef::Knife.chef_config_dir
- Chef::Util::PathHelper.home(".chef", "bootstrap", "#{template}.erb") { |p| bootstrap_files << p }
+ Chef::Util::PathHelper.home(".chef", "bootstrap", "#{template}.erb") do |p| bootstrap_files << p end
bootstrap_files << Gem.find_files(File.join("chef", "knife", "bootstrap", "#{template}.erb"))
bootstrap_files.flatten!
- template_file = Array(bootstrap_files).find do |bootstrap_template|
+ template_file = Array(bootstrap_files).find { |bootstrap_template|
Chef::Log.trace("Looking for bootstrap template in #{File.dirname(bootstrap_template)}")
File.exists?(bootstrap_template)
- end
+ }
unless template_file
ui.info("Can not find bootstrap definition for #{template}")
@@ -604,9 +604,9 @@ class Chef
def perform_bootstrap(remote_bootstrap_script_path)
ui.info("Bootstrapping #{ui.color(server_name, :bold)}")
cmd = bootstrap_command(remote_bootstrap_script_path)
- r = connection.run_command(cmd) do |data|
+ r = connection.run_command(cmd) { |data|
ui.msg("#{ui.color(" [#{connection.hostname}]", :cyan)} #{data}")
- end
+ }
if r.exit_status != 0
ui.error("The following error occurred on #{server_name}:")
ui.error(r.stderr)
@@ -644,9 +644,9 @@ class Chef
raise
else
ui.warn("Failed to authenticate #{opts[:user]} to #{server_name} - trying password auth")
- password = ui.ask("Enter password for #{opts[:user]}@#{server_name}.") do |q|
+ password = ui.ask("Enter password for #{opts[:user]}@#{server_name}.") { |q|
q.echo = false
- end
+ }
end
opts.merge! force_ssh_password_opts(password)
diff --git a/lib/chef/knife/config_list_profiles.rb b/lib/chef/knife/config_list_profiles.rb
index fb40b30b0a..86f25243c1 100644
--- a/lib/chef/knife/config_list_profiles.rb
+++ b/lib/chef/knife/config_list_profiles.rb
@@ -38,7 +38,7 @@ class Chef
end
current_profile = self.class.config_loader.credentials_profile(config[:profile])
- profiles = credentials_data.keys.map do |profile|
+ profiles = credentials_data.keys.map { |profile|
if config[:ignore_knife_rb]
# Don't do any fancy loading nonsense, just the raw data.
profile_data = credentials_data[profile]
@@ -64,7 +64,7 @@ class Chef
server_url: Chef::Config[:chef_server_url],
}
end
- end
+ }
# Try to reset the config.
unless config[:ignore_knife_rb]
@@ -90,9 +90,9 @@ class Chef
profile[:client_key] = profile[:client_key].to_s.gsub(/^#{Regexp.escape(Dir.home)}/, "~") if profile[:client_key]
end
# Render the data to a 2D array that will be used for the table.
- table_data = [["", "Profile", "Client", "Key", "Server"]] + profiles.map do |profile|
+ table_data = [["", "Profile", "Client", "Key", "Server"]] + profiles.map { |profile|
[profile[:active] ? "*" : ""] + profile.values_at(:profile, :client_name, :client_key, :server_url).map(&:to_s)
- end
+ }
# Compute column widths.
column_widths = Array.new(table_data.first.length) do |i|
table_data.map { |row| row[i].length + padding }.max
diff --git a/lib/chef/knife/cookbook_delete.rb b/lib/chef/knife/cookbook_delete.rb
index 98e54f486d..ab1e793f08 100644
--- a/lib/chef/knife/cookbook_delete.rb
+++ b/lib/chef/knife/cookbook_delete.rb
@@ -85,9 +85,9 @@ class Chef
end
def available_versions
- @available_versions ||= rest.get("cookbooks/#{@cookbook_name}").map do |name, url_and_version|
+ @available_versions ||= rest.get("cookbooks/#{@cookbook_name}").map { |name, url_and_version|
url_and_version["versions"].map { |url_by_version| url_by_version["version"] }
- end.flatten
+ }.flatten
rescue Net::HTTPClientException => e
if e.to_s =~ /^404/
ui.error("Cannot find a cookbook named #{@cookbook_name} to delete.")
@@ -112,13 +112,13 @@ class Chef
ui.error("No versions specified, exiting")
exit(1)
end
- versions = responses.map do |response|
+ versions = responses.map { |response|
if version = valid_responses[response]
version
else
ui.error("#{response} is not a valid choice, skipping it")
end
- end
+ }
versions.compact
end
diff --git a/lib/chef/knife/cookbook_download.rb b/lib/chef/knife/cookbook_download.rb
index aa6458a5d0..2a58478cd5 100644
--- a/lib/chef/knife/cookbook_download.rb
+++ b/lib/chef/knife/cookbook_download.rb
@@ -112,7 +112,7 @@ class Chef
@available_versions ||= begin
versions = Chef::CookbookVersion.available_versions(@cookbook_name)
unless versions.nil?
- versions.map! { |version| Chef::Version.new(version) }
+ versions.map! do |version| Chef::Version.new(version) end
versions.sort!
end
versions
diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb
index d73fa9ae68..1f9f232b60 100644
--- a/lib/chef/knife/cookbook_upload.rb
+++ b/lib/chef/knife/cookbook_upload.rb
@@ -217,9 +217,9 @@ class Chef
# MUST!! dup the cookbook version object--it memoizes its
# manifest object, but the manifest becomes invalid when you
# regenerate the metadata
- broken_files = cookbook.dup.manifest_records_by_path.select do |path, info|
+ broken_files = cookbook.dup.manifest_records_by_path.select { |path, info|
info[CHECKSUM].nil? || info[CHECKSUM] !~ MATCH_CHECKSUM
- end
+ }
unless broken_files.empty?
broken_filenames = Array(broken_files).map { |path, info| path }
ui.error "The cookbook #{cookbook.name} has one or more broken files"
@@ -232,9 +232,9 @@ class Chef
def check_for_dependencies!(cookbook)
# for all dependencies, check if the version is on the server, or
# the version is in the cookbooks being uploaded. If not, exit and warn the user.
- missing_dependencies = cookbook.metadata.dependencies.reject do |cookbook_name, version|
+ missing_dependencies = cookbook.metadata.dependencies.reject { |cookbook_name, version|
check_server_side_cookbooks(cookbook_name, version) || check_uploading_cookbooks(cookbook_name, version)
- end
+ }
unless missing_dependencies.empty?
missing_cookbook_names = missing_dependencies.map { |cookbook_name, version| "'#{cookbook_name}' version '#{version}'" }
diff --git a/lib/chef/knife/core/gem_glob_loader.rb b/lib/chef/knife/core/gem_glob_loader.rb
index 8fe228b848..a133515bdf 100644
--- a/lib/chef/knife/core/gem_glob_loader.rb
+++ b/lib/chef/knife/core/gem_glob_loader.rb
@@ -81,19 +81,19 @@ class Chef
files = []
if check_load_path
- files = $LOAD_PATH.map do |load_path|
+ files = $LOAD_PATH.map { |load_path|
Dir["#{File.expand_path glob, Chef::Util::PathHelper.escape_glob_dir(load_path)}#{Gem.suffix_pattern}"]
- end.flatten.select { |file| File.file? file.untaint }
+ }.flatten.select { |file| File.file? file.untaint }
end
- gem_files = latest_gem_specs.map do |spec|
+ gem_files = latest_gem_specs.map { |spec|
# Gem::Specification#matches_for_glob wasn't added until RubyGems 1.8
if spec.respond_to? :matches_for_glob
spec.matches_for_glob("#{glob}#{Gem.suffix_pattern}")
else
check_spec_for_glob(spec, glob)
end
- end.flatten
+ }.flatten
files.concat gem_files
files.uniq! if check_load_path
diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb
index 90f529a3d9..e3bb7d366d 100644
--- a/lib/chef/knife/core/generic_presenter.rb
+++ b/lib/chef/knife/core/generic_presenter.rb
@@ -214,10 +214,10 @@ class Chef
collected
end
else
- versions_by_cookbook = item.inject({}) do |collected, ( cookbook, versions )|
+ versions_by_cookbook = item.inject({}) { |collected, ( cookbook, versions )|
collected[cookbook] = versions["versions"].map { |v| v["version"] }
collected
- end
+ }
key_length = versions_by_cookbook.empty? ? 0 : versions_by_cookbook.keys.map(&:size).max + 2
versions_by_cookbook.sort.map do |cookbook, versions|
"#{cookbook.ljust(key_length)} #{versions.join(" ")}"
diff --git a/lib/chef/knife/core/node_editor.rb b/lib/chef/knife/core/node_editor.rb
index 753ee01704..5dc88cb4cc 100644
--- a/lib/chef/knife/core/node_editor.rb
+++ b/lib/chef/knife/core/node_editor.rb
@@ -67,9 +67,9 @@ class Chef
policy_name
policy_group
run_list
- }.reject do |key|
+ }.reject { |key|
pristine_copy[key] == updated_copy[key]
- end
+ }
updated_properties.any? && updated_properties
end
diff --git a/lib/chef/knife/core/object_loader.rb b/lib/chef/knife/core/object_loader.rb
index 087213fadf..a7630a65f7 100644
--- a/lib/chef/knife/core/object_loader.rb
+++ b/lib/chef/knife/core/object_loader.rb
@@ -80,7 +80,7 @@ class Chef
def find_all_object_dirs(path)
path = File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path(path)), "*")
objects = Dir.glob(path)
- objects.delete_if { |o| !File.directory?(o) }
+ objects.delete_if do |o| !File.directory?(o) end
objects.map { |o| File.basename(o) }
end
diff --git a/lib/chef/knife/core/subcommand_loader.rb b/lib/chef/knife/core/subcommand_loader.rb
index 5b9474515a..60f6a9adff 100644
--- a/lib/chef/knife/core/subcommand_loader.rb
+++ b/lib/chef/knife/core/subcommand_loader.rb
@@ -83,7 +83,7 @@ class Chef
def load_commands
return true if @loaded
- subcommand_files.each { |subcommand| Kernel.load subcommand }
+ subcommand_files.each do |subcommand| Kernel.load subcommand end
@loaded = true
end
diff --git a/lib/chef/knife/diff.rb b/lib/chef/knife/diff.rb
index 3e9336aacc..1dfa1777a4 100644
--- a/lib/chef/knife/diff.rb
+++ b/lib/chef/knife/diff.rb
@@ -64,9 +64,9 @@ class Chef
error = false
begin
patterns.each do |pattern|
- found_error = Chef::ChefFS::CommandLine.diff_print(pattern, chef_fs, local_fs, config[:recurse] ? nil : 1, output_mode, proc { |entry| format_path(entry) }, config[:diff_filter], ui ) do |diff|
+ found_error = Chef::ChefFS::CommandLine.diff_print(pattern, chef_fs, local_fs, config[:recurse] ? nil : 1, output_mode, proc { |entry| format_path(entry) }, config[:diff_filter], ui ) { |diff|
stdout.print diff
- end
+ }
error = true if found_error
end
rescue Chef::ChefFS::FileSystem::OperationFailedError => e
diff --git a/lib/chef/knife/environment_compare.rb b/lib/chef/knife/environment_compare.rb
index 38e259a856..3c9ef3c013 100644
--- a/lib/chef/knife/environment_compare.rb
+++ b/lib/chef/knife/environment_compare.rb
@@ -94,19 +94,19 @@ class Chef
def cookbook_list(constraints)
result = {}
- constraints.each_value { |cb| result.merge!(cb) }
+ constraints.each_value do |cb| result.merge!(cb) end
result
end
def matrix_output(cookbooks, constraints)
rows = [ "" ]
environments = []
- constraints.each_key { |e| environments << e.to_s }
+ constraints.each_key do |e| environments << e.to_s end
columns = environments.count + 1
- environments.each { |env| rows << ui.color(env, :bold) }
+ environments.each do |env| rows << ui.color(env, :bold) end
cookbooks.each_key do |c|
total = []
- environments.each { |n| total << constraints[n][c] }
+ environments.each do |n| total << constraints[n][c] end
if total.uniq.count == 1
next if config[:mismatch]
diff --git a/lib/chef/knife/exec.rb b/lib/chef/knife/exec.rb
index 4b7f570aec..9455d76571 100644
--- a/lib/chef/knife/exec.rb
+++ b/lib/chef/knife/exec.rb
@@ -44,7 +44,7 @@ class Chef::Knife::Exec < Chef::Knife
# Default script paths are chef-repo/.chef/scripts and ~/.chef/scripts
config[:script_path] << File.join(Chef::Knife.chef_config_dir, "scripts") if Chef::Knife.chef_config_dir
- Chef::Util::PathHelper.home(".chef", "scripts") { |p| config[:script_path] << p }
+ Chef::Util::PathHelper.home(".chef", "scripts") do |p| config[:script_path] << p end
scripts = Array(name_args)
context = Object.new
diff --git a/lib/chef/knife/list.rb b/lib/chef/knife/list.rb
index e5e196ecea..d4b169e832 100644
--- a/lib/chef/knife/list.rb
+++ b/lib/chef/knife/list.rb
@@ -65,7 +65,7 @@ class Chef
patterns = name_args.length == 0 ? [""] : name_args
# Get the top-level matches
- all_results = parallelize(pattern_args_from(patterns)) do |pattern|
+ all_results = parallelize(pattern_args_from(patterns)) { |pattern|
pattern_results = Chef::ChefFS::FileSystem.list(config[:local] ? local_fs : chef_fs, pattern).to_a
if pattern_results.first && !pattern_results.first.exists? && pattern.exact_path
@@ -73,13 +73,13 @@ class Chef
self.exit_code = 1
end
pattern_results
- end.flatten(1).to_a
+ }.flatten(1).to_a
# Process directories
if !config[:bare_directories]
- dir_results = parallelize(all_results.select(&:dir?)) do |result|
+ dir_results = parallelize(all_results.select(&:dir?)) { |result|
add_dir_result(result)
- end.flatten(1)
+ }.flatten(1)
else
dir_results = []
diff --git a/lib/chef/knife/node_run_list_add.rb b/lib/chef/knife/node_run_list_add.rb
index 9b50e2483a..5d962415ca 100644
--- a/lib/chef/knife/node_run_list_add.rb
+++ b/lib/chef/knife/node_run_list_add.rb
@@ -43,9 +43,9 @@ class Chef
node = Chef::Node.load(@name_args[0])
if @name_args.size > 2
# Check for nested lists and create a single plain one
- entries = @name_args[1..-1].map do |entry|
+ entries = @name_args[1..-1].map { |entry|
entry.split(",").map(&:strip)
- end.flatten
+ }.flatten
else
# Convert to array and remove the extra spaces
entries = @name_args[1].split(",").map(&:strip)
diff --git a/lib/chef/knife/node_run_list_remove.rb b/lib/chef/knife/node_run_list_remove.rb
index 36c98a724b..f5d1795e4a 100644
--- a/lib/chef/knife/node_run_list_remove.rb
+++ b/lib/chef/knife/node_run_list_remove.rb
@@ -34,9 +34,9 @@ class Chef
if @name_args.size > 2
# Check for nested lists and create a single plain one
- entries = @name_args[1..-1].map do |entry|
+ entries = @name_args[1..-1].map { |entry|
entry.split(",").map(&:strip)
- end.flatten
+ }.flatten
else
# Convert to array and remove the extra spaces
entries = @name_args[1].split(",").map(&:strip)
diff --git a/lib/chef/knife/node_run_list_set.rb b/lib/chef/knife/node_run_list_set.rb
index eae05003ff..9b35edb70d 100644
--- a/lib/chef/knife/node_run_list_set.rb
+++ b/lib/chef/knife/node_run_list_set.rb
@@ -36,9 +36,9 @@ class Chef
exit 1
elsif @name_args.size > 2
# Check for nested lists and create a single plain one
- entries = @name_args[1..-1].map do |entry|
+ entries = @name_args[1..-1].map { |entry|
entry.split(",").map(&:strip)
- end.flatten
+ }.flatten
else
# Convert to array and remove the extra spaces
entries = @name_args[1].split(",").map(&:strip)
diff --git a/lib/chef/knife/role_env_run_list_add.rb b/lib/chef/knife/role_env_run_list_add.rb
index 8f6a5cadba..e37e920360 100644
--- a/lib/chef/knife/role_env_run_list_add.rb
+++ b/lib/chef/knife/role_env_run_list_add.rb
@@ -56,7 +56,7 @@ class Chef
role.run_list_for(environment).each do |entry|
nlist << entry
end
- entries.each { |e| nlist << e }
+ entries.each do |e| nlist << e end
role.env_run_lists_add(environment => nlist)
end
end
@@ -68,9 +68,9 @@ class Chef
if @name_args.size > 2
# Check for nested lists and create a single plain one
- entries = @name_args[2..-1].map do |entry|
+ entries = @name_args[2..-1].map { |entry|
entry.split(",").map(&:strip)
- end.flatten
+ }.flatten
else
# Convert to array and remove the extra spaces
entries = @name_args[2].split(",").map(&:strip)
diff --git a/lib/chef/knife/role_env_run_list_set.rb b/lib/chef/knife/role_env_run_list_set.rb
index 084bc02aff..3723bf65b7 100644
--- a/lib/chef/knife/role_env_run_list_set.rb
+++ b/lib/chef/knife/role_env_run_list_set.rb
@@ -37,7 +37,7 @@ class Chef
unless role.env_run_lists.key?(environment)
role.env_run_lists_add(environment => nlist)
end
- entries.each { |e| nlist << e }
+ entries.each do |e| nlist << e end
role.env_run_lists_add(environment => nlist)
end
@@ -51,9 +51,9 @@ class Chef
exit 1
elsif @name_args.size > 2
# Check for nested lists and create a single plain one
- entries = @name_args[2..-1].map do |entry|
+ entries = @name_args[2..-1].map { |entry|
entry.split(",").map(&:strip)
- end.flatten
+ }.flatten
else
# Convert to array and remove the extra spaces
entries = @name_args[2].split(",").map(&:strip)
diff --git a/lib/chef/knife/role_run_list_add.rb b/lib/chef/knife/role_run_list_add.rb
index 3c4961cbe1..7a6f23b9e4 100644
--- a/lib/chef/knife/role_run_list_add.rb
+++ b/lib/chef/knife/role_run_list_add.rb
@@ -56,7 +56,7 @@ class Chef
role.run_list_for(environment).each do |entry|
nlist << entry
end
- entries.each { |e| nlist << e }
+ entries.each do |e| nlist << e end
role.env_run_lists_add(environment => nlist)
end
end
@@ -68,9 +68,9 @@ class Chef
if @name_args.size > 1
# Check for nested lists and create a single plain one
- entries = @name_args[1..-1].map do |entry|
+ entries = @name_args[1..-1].map { |entry|
entry.split(",").map(&:strip)
- end.flatten
+ }.flatten
else
# Convert to array and remove the extra spaces
entries = @name_args[1].split(",").map(&:strip)
diff --git a/lib/chef/knife/role_run_list_set.rb b/lib/chef/knife/role_run_list_set.rb
index 7302797c33..604b162a3a 100644
--- a/lib/chef/knife/role_run_list_set.rb
+++ b/lib/chef/knife/role_run_list_set.rb
@@ -36,7 +36,7 @@ class Chef
unless role.env_run_lists.key?(environment)
role.env_run_lists_add(environment => nlist)
end
- entries.each { |e| nlist << e }
+ entries.each do |e| nlist << e end
role.env_run_lists_add(environment => nlist)
end
@@ -50,9 +50,9 @@ class Chef
exit 1
elsif @name_args.size > 1
# Check for nested lists and create a single plain one
- entries = @name_args[1..-1].map do |entry|
+ entries = @name_args[1..-1].map { |entry|
entry.split(",").map(&:strip)
- end.flatten
+ }.flatten
else
# Convert to array and remove the extra spaces
entries = @name_args[1].split(",").map(&:strip)
diff --git a/lib/chef/knife/show.rb b/lib/chef/knife/show.rb
index 0e5ab9d0fe..7bce07dfcf 100644
--- a/lib/chef/knife/show.rb
+++ b/lib/chef/knife/show.rb
@@ -36,7 +36,7 @@ class Chef
def run
# Get the matches (recursively)
error = false
- entry_values = parallelize(pattern_args) do |pattern|
+ entry_values = parallelize(pattern_args) { |pattern|
parallelize(Chef::ChefFS::FileSystem.list(config[:local] ? local_fs : chef_fs, pattern)) do |entry|
if entry.dir?
ui.error "#{format_path(entry)}: is a directory" if pattern.exact_path
@@ -56,7 +56,7 @@ class Chef
end
end
end
- end.flatten(1)
+ }.flatten(1)
entry_values.each do |entry, value|
if entry
output "#{format_path(entry)}:"
diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb
index 2a4334570e..164cca195f 100644
--- a/lib/chef/knife/ssh.rb
+++ b/lib/chef/knife/ssh.rb
@@ -474,13 +474,13 @@ class Chef
new_window_cmds = lambda do
if session.servers_for.size > 1
- [""] + session.servers_for[1..-1].map do |server|
+ [""] + session.servers_for[1..-1].map { |server|
if config[:tmux_split]
"split-window #{ssh_dest.call(server)}; tmux select-layout tiled"
else
"new-window -a -n '#{server.host}' #{ssh_dest.call(server)}"
end
- end
+ }
else
[]
end.join(" \\; ")
diff --git a/lib/chef/knife/status.rb b/lib/chef/knife/status.rb
index 074488e003..0aa854df56 100644
--- a/lib/chef/knife/status.rb
+++ b/lib/chef/knife/status.rb
@@ -84,13 +84,13 @@ class Chef
all_nodes << node
end
- output(all_nodes.sort do |n1, n2|
+ output(all_nodes.sort { |n1, n2|
if config[:sort_reverse] || Chef::Config[:knife][:sort_status_reverse]
(n2["ohai_time"] || 0) <=> (n1["ohai_time"] || 0)
else
(n1["ohai_time"] || 0) <=> (n2["ohai_time"] || 0)
end
- end)
+ })
end
end
diff --git a/lib/chef/knife/supermarket_list.rb b/lib/chef/knife/supermarket_list.rb
index 700d928af8..0a94e42dba 100644
--- a/lib/chef/knife/supermarket_list.rb
+++ b/lib/chef/knife/supermarket_list.rb
@@ -40,7 +40,7 @@ class Chef
def run
if config[:with_uri]
cookbooks = {}
- get_cookbook_list.each { |k, v| cookbooks[k] = v["cookbook"] }
+ get_cookbook_list.each do |k, v| cookbooks[k] = v["cookbook"] end
ui.output(format_for_display(cookbooks))
else
ui.msg(ui.list(get_cookbook_list.keys.sort, :columns_down))
diff --git a/lib/chef/mash.rb b/lib/chef/mash.rb
index 404d6d622f..5384aa327c 100644
--- a/lib/chef/mash.rb
+++ b/lib/chef/mash.rb
@@ -117,7 +117,7 @@ class Mash < Hash
#
# @return [Mash] The updated mash.
def update(other_hash)
- other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) }
+ other_hash.each_pair do |key, value| regular_writer(convert_key(key), convert_value(value)) end
self
end
@@ -183,7 +183,7 @@ class Mash < Hash
# @return [Hash] The mash as a Hash with symbolized keys.
def symbolize_keys
h = Hash.new(default)
- each { |key, val| h[key.to_sym] = val }
+ each do |key, val| h[key.to_sym] = val end
h
end
diff --git a/lib/chef/mixin/convert_to_class_name.rb b/lib/chef/mixin/convert_to_class_name.rb
index c5944c3985..6a37854e2f 100644
--- a/lib/chef/mixin/convert_to_class_name.rb
+++ b/lib/chef/mixin/convert_to_class_name.rb
@@ -43,7 +43,7 @@ class Chef
def convert_to_snake_case(str, namespace = nil)
str = str.dup
str.sub!(/^#{namespace}(\:\:)?/, "") if namespace
- str.gsub!(/[A-Z]/) { |s| "_" + s }
+ str.gsub!(/[A-Z]/) do |s| "_" + s end
str.downcase!
str.sub!(/^\_/, "")
str
@@ -109,12 +109,12 @@ class Chef
# Go down the ancestors to check if it is owned directly. The check
# stops when we reach Object or the end of ancestors tree.
- constant = constant.ancestors.inject do |const, ancestor|
+ constant = constant.ancestors.inject { |const, ancestor|
break const if ancestor == Object
break ancestor if ancestor.const_defined?(name, false)
const
- end
+ }
# owner is in Object, so raise
constant.const_get(name, false)
diff --git a/lib/chef/mixin/params_validate.rb b/lib/chef/mixin/params_validate.rb
index ad7eddb48a..5a9f1f5e11 100644
--- a/lib/chef/mixin/params_validate.rb
+++ b/lib/chef/mixin/params_validate.rb
@@ -414,7 +414,7 @@ class Chef
value = _pv_opts_lookup(opts, key)
to_be = [ to_be ].flatten(1)
errors = []
- passed = to_be.any? do |tb|
+ passed = to_be.any? { |tb|
case tb
when Proc
raise Exceptions::CannotValidateStaticallyError, "is: proc { } must be evaluated once for each resource" if self == Chef::Mixin::ParamsValidate
@@ -434,7 +434,7 @@ class Chef
else
tb === value
end
- end
+ }
if passed
true
else
diff --git a/lib/chef/mixin/powershell_type_coercions.rb b/lib/chef/mixin/powershell_type_coercions.rb
index a75022c771..c09929b7a3 100644
--- a/lib/chef/mixin/powershell_type_coercions.rb
+++ b/lib/chef/mixin/powershell_type_coercions.rb
@@ -49,16 +49,16 @@ class Chef
private
def translate_hash(x)
- translated = x.inject([]) do |memo, (k, v)|
+ translated = x.inject([]) { |memo, (k, v)|
memo << "#{k}=#{translate_type(v)}"
- end
+ }
"@{#{translated.join(";")}}"
end
def translate_array(x)
- translated = x.map do |v|
+ translated = x.map { |v|
translate_type(v)
- end
+ }
"@(#{translated.join(",")})"
end
diff --git a/lib/chef/mixin/properties.rb b/lib/chef/mixin/properties.rb
index ecb589e015..91b63072f5 100644
--- a/lib/chef/mixin/properties.rb
+++ b/lib/chef/mixin/properties.rb
@@ -20,7 +20,7 @@ class Chef
def properties(include_superclass = true)
if include_superclass
result = {}
- ancestors.reverse_each { |c| result.merge!(c.properties(false)) if c.respond_to?(:properties) }
+ ancestors.reverse_each do |c| result.merge!(c.properties(false)) if c.respond_to?(:properties) end
result
else
@properties ||= {}
diff --git a/lib/chef/mixin/versioned_api.rb b/lib/chef/mixin/versioned_api.rb
index 17c9838d29..3a62c98fe1 100644
--- a/lib/chef/mixin/versioned_api.rb
+++ b/lib/chef/mixin/versioned_api.rb
@@ -44,12 +44,12 @@ class Chef
end
def get_class_for(type)
- versioned_interfaces.select do |klass|
+ versioned_interfaces.select { |klass|
version = klass.send(:minimum_api_version)
# min and max versions will be nil if we've not made a request to the server yet,
# in which case we'll just start with the highest version and see what happens
ServerAPIVersions.instance.min_server_version.nil? || (version >= ServerAPIVersions.instance.min_server_version && version <= ServerAPIVersions.instance.send(type))
- end
+ }
.sort { |a, b| a.send(:minimum_api_version) <=> b.send(:minimum_api_version) }
.last
end
diff --git a/lib/chef/mixin/which.rb b/lib/chef/mixin/which.rb
index a51963b6c2..87946038ef 100644
--- a/lib/chef/mixin/which.rb
+++ b/lib/chef/mixin/which.rb
@@ -28,12 +28,12 @@ class Chef
# NOTE: unnecessarily duplicates function of path_sanity
extra_path ||= [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ]
paths = env_path.split(File::PATH_SEPARATOR) + Array(extra_path)
- cmds.map do |cmd|
- paths.map do |path|
+ cmds.map { |cmd|
+ paths.map { |path|
filename = Chef.path_to(File.join(path, cmd))
filename if valid_executable?(filename, &block)
- end.compact
- end.flatten
+ }.compact
+ }.flatten
end
private
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index dfd2c685e1..f0be72e68f 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -582,7 +582,7 @@ class Chef
def self.list_by_environment(environment, inflate = false)
if inflate
response = {}
- Chef::Search::Query.new.search(:node, "chef_environment:#{environment}") { |n| response[n.name] = n unless n.nil? }
+ Chef::Search::Query.new.search(:node, "chef_environment:#{environment}") do |n| response[n.name] = n unless n.nil? end
response
else
Chef::ServerAPI.new(Chef::Config[:chef_server_url]).get("environments/#{environment}/nodes")
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb
index bc4983384b..7804766301 100644
--- a/lib/chef/node/attribute.rb
+++ b/lib/chef/node/attribute.rb
@@ -487,9 +487,9 @@ class Chef
end
def inspect
- "#<#{self.class} " << (COMPONENTS + %i{@merged_attributes @properties}).map do |iv|
+ "#<#{self.class} " << (COMPONENTS + %i{@merged_attributes @properties}).map { |iv|
"#{iv}=#{instance_variable_get(iv).inspect}"
- end.join(", ") << ">"
+ }.join(", ") << ">"
end
private
@@ -546,9 +546,9 @@ class Chef
apply_path(@automatic, path),
]
- ret = components.inject(NIL) do |merged, component|
+ ret = components.inject(NIL) { |merged, component|
hash_only_merge!(merged, component)
- end
+ }
ret == NIL ? nil : ret
end
@@ -559,10 +559,10 @@ class Chef
# @param path [Array] Array of args to method chain to descend into the node object
# @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object
def merge_defaults(path)
- ret = DEFAULT_COMPONENTS.inject(NIL) do |merged, component_ivar|
+ ret = DEFAULT_COMPONENTS.inject(NIL) { |merged, component_ivar|
component_value = apply_path(instance_variable_get(component_ivar), path)
deep_merge!(merged, component_value)
- end
+ }
ret
end
@@ -573,10 +573,10 @@ class Chef
# @param path [Array] Array of args to method chain to descend into the node object
# @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object
def merge_overrides(path)
- ret = OVERRIDE_COMPONENTS.inject(NIL) do |merged, component_ivar|
+ ret = OVERRIDE_COMPONENTS.inject(NIL) { |merged, component_ivar|
component_value = apply_path(instance_variable_get(component_ivar), path)
deep_merge!(merged, component_value)
- end
+ }
ret
end
diff --git a/lib/chef/node/common_api.rb b/lib/chef/node/common_api.rb
index 1ea1067113..8fbb84b561 100644
--- a/lib/chef/node/common_api.rb
+++ b/lib/chef/node/common_api.rb
@@ -35,7 +35,7 @@ class Chef
value = block_given? ? yield : args.pop
last = args.pop
prev_memo = prev_key = nil
- chain = args.inject(self) do |memo, key|
+ chain = args.inject(self) { |memo, key|
unless valid_container?(memo, key)
prev_memo[prev_key] = {}
memo = prev_memo[prev_key]
@@ -43,7 +43,7 @@ class Chef
prev_memo = memo
prev_key = key
memo[key]
- end
+ }
unless valid_container?(chain, last)
prev_memo[prev_key] = {}
chain = prev_memo[prev_key]
@@ -57,11 +57,11 @@ class Chef
def write!(*args, &block)
value = block_given? ? yield : args.pop
last = args.pop
- obj = args.inject(self) do |memo, key|
+ obj = args.inject(self) { |memo, key|
raise Chef::Exceptions::AttributeTypeMismatch unless valid_container?(memo, key)
memo[key]
- end
+ }
raise Chef::Exceptions::AttributeTypeMismatch unless valid_container?(obj, last)
obj[last] = value
diff --git a/lib/chef/node/immutable_collections.rb b/lib/chef/node/immutable_collections.rb
index b4a7a39ba0..b75fde39d5 100644
--- a/lib/chef/node/immutable_collections.rb
+++ b/lib/chef/node/immutable_collections.rb
@@ -82,7 +82,7 @@ class Chef
end
def to_a
- Array.new(map do |v|
+ Array.new(map { |v|
case v
when ImmutableArray
v.to_a
@@ -91,7 +91,7 @@ class Chef
else
safe_dup(v)
end
- end)
+ })
end
alias_method :to_array, :to_a
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb
index dd118c26cf..47defacfe3 100644
--- a/lib/chef/node_map.rb
+++ b/lib/chef/node_map.rb
@@ -142,9 +142,9 @@ class Chef
def list(node, key, canonical: nil)
return [] unless map.key?(key)
- map[key].select do |matcher|
+ map[key].select { |matcher|
node_matches?(node, matcher) && canonical_matches?(canonical, matcher)
- end.map { |matcher| matcher[:klass] }
+ }.map { |matcher| matcher[:klass] }
end
# Remove a class from all its matchers in the node_map, will remove mappings completely if its the last matcher left
@@ -180,7 +180,7 @@ class Chef
def delete_canonical(key, klass)
remaining = map[key]
if remaining
- remaining.delete_if { |matcher| matcher[:canonical] && Array(matcher[:klass]) == Array(klass) }
+ remaining.delete_if do |matcher| matcher[:canonical] && Array(matcher[:klass]) == Array(klass) end
if remaining.empty?
map.delete(key)
remaining = nil
diff --git a/lib/chef/policy_builder/expand_node_object.rb b/lib/chef/policy_builder/expand_node_object.rb
index 4afb4d7d60..f87de2da2a 100644
--- a/lib/chef/policy_builder/expand_node_object.rb
+++ b/lib/chef/policy_builder/expand_node_object.rb
@@ -186,10 +186,10 @@ class Chef
cookbook_hash = api_service.post("environments/#{node.chef_environment}/cookbook_versions",
{ run_list: @expanded_run_list_with_versions })
- cookbook_hash = cookbook_hash.inject({}) do |memo, (key, value)|
+ cookbook_hash = cookbook_hash.inject({}) { |memo, (key, value)|
memo[key] = Chef::CookbookVersion.from_hash(value)
memo
- end
+ }
rescue Exception => e
# TODO: wrap/munge exception to provide helpful error output
events.cookbook_resolution_failed(@expanded_run_list_with_versions, e)
diff --git a/lib/chef/policy_builder/policyfile.rb b/lib/chef/policy_builder/policyfile.rb
index 70a2e44635..959c2d6746 100644
--- a/lib/chef/policy_builder/policyfile.rb
+++ b/lib/chef/policy_builder/policyfile.rb
@@ -59,9 +59,9 @@ class Chef
#
# Skipped will always be false as it can only be true when two expanded
# roles contain the same recipe.
- expanded_run_list = recipes.map do |r|
+ expanded_run_list = recipes.map { |r|
{ type: "recipe", name: r, skipped: false, version: nil }
- end
+ }
data_collector_hash = {}
data_collector_hash[:id] = "_policy_node"
data_collector_hash[:run_list] = expanded_run_list
@@ -259,10 +259,10 @@ class Chef
# a RunListExpansion object, to satisfy the API contract of
# #expand_run_list
def run_list_expansion_ish
- recipes = run_list.map do |recipe_spec|
+ recipes = run_list.map { |recipe_spec|
cookbook, recipe = parse_recipe_spec(recipe_spec)
"#{cookbook}::#{recipe}"
- end
+ }
RunListExpansionIsh.new(recipes, [])
end
@@ -341,9 +341,9 @@ class Chef
errors << "Policyfile is missing cookbook_locks element"
end
if run_list.is_a?(Array)
- run_list_errors = run_list.select do |maybe_recipe_spec|
+ run_list_errors = run_list.select { |maybe_recipe_spec|
validate_recipe_spec(maybe_recipe_spec)
- end
+ }
errors += run_list_errors
else
errors << "Policyfile run_list is malformed, must be an array of `recipe[cb_name::recipe_name]` items: #{policy["run_list"]}"
@@ -459,10 +459,10 @@ class Chef
@cookbook_to_sync ||= begin
events.cookbook_resolution_start(run_list_with_versions_for_display)
- cookbook_versions_by_name = cookbook_locks.inject({}) do |cb_map, (name, lock_data)|
+ cookbook_versions_by_name = cookbook_locks.inject({}) { |cb_map, (name, lock_data)|
cb_map[name] = manifest_for(name, lock_data)
cb_map
- end
+ }
events.cookbook_resolution_complete(cookbook_versions_by_name)
cookbook_versions_by_name
diff --git a/lib/chef/property.rb b/lib/chef/property.rb
index 6aa76a5236..8618cd98db 100644
--- a/lib/chef/property.rb
+++ b/lib/chef/property.rb
@@ -321,9 +321,9 @@ class Chef
# @return [Hash<Symbol,Object>]
#
def validation_options
- @validation_options ||= options.reject do |k, v|
+ @validation_options ||= options.reject { |k, v|
%i{declared_in name instance_variable_name desired_state identity default name_property coerce required nillable sensitive description introduced deprecated default_description skip_docs}.include?(k)
- end
+ }
end
#
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb
index 6d1985bbbb..661a4b5162 100644
--- a/lib/chef/provider.rb
+++ b/lib/chef/provider.rb
@@ -280,13 +280,13 @@ class Chef
properties_str = if new_resource.sensitive
specified_properties.join(", ")
else
- specified_properties.map do |property|
+ specified_properties.map { |property|
"#{property}=" << if new_resource.class.properties[property].sensitive?
"(suppressed sensitive property)"
else
new_resource.send(property).inspect
end
- end.join(", ")
+ }.join(", ")
end
logger.debug("Skipping update of #{new_resource}: has not changed any of the specified properties #{properties_str}.")
return false
@@ -308,7 +308,7 @@ class Chef
# The resource doesn't exist. Mark that we are *creating* this, and
# write down any properties we are setting.
property_size = properties.map(&:size).max
- created = properties.map do |property|
+ created = properties.map { |property|
default = " (default value)" unless new_resource.property_is_set?(property)
properties_str = if new_resource.sensitive || new_resource.class.properties[property].sensitive?
"(suppressed sensitive property)"
@@ -316,7 +316,7 @@ class Chef
new_resource.send(property).inspect
end
" set #{property.to_s.ljust(property_size)} to #{properties_str}#{default}"
- end
+ }
converge_by([ "create #{new_resource.identity}" ] + created, &converge_block)
end
@@ -357,8 +357,8 @@ class Chef
provider_class = self
@included_resource_dsl_module = Module.new do
extend Forwardable
- define_singleton_method(:to_s) { "forwarder module for #{provider_class}" }
- define_singleton_method(:inspect) { to_s }
+ define_singleton_method(:to_s) do "forwarder module for #{provider_class}" end
+ define_singleton_method(:inspect) do to_s end
# this magic, stated simply, is that any instance method declared directly on
# the resource we are building, will be accessible from the action_class(provider)
# instance. methods declared on Chef::Resource and properties are not inherited.
diff --git a/lib/chef/provider/apt_repository.rb b/lib/chef/provider/apt_repository.rb
index 85fac1d2da..e4dc0db99d 100644
--- a/lib/chef/provider/apt_repository.rb
+++ b/lib/chef/provider/apt_repository.rb
@@ -117,11 +117,11 @@ class Chef
# @return [Array] an array of fingerprints
def extract_fingerprints_from_cmd(*cmd)
so = shell_out(*cmd)
- so.stdout.split(/\n/).map do |t|
+ so.stdout.split(/\n/).map { |t|
if z = t.match(/^fpr:+([0-9A-F]+):/)
z[1].split.join
end
- end.compact
+ }.compact
end
# validate the key against the apt keystore to see if that version is expired
@@ -201,7 +201,7 @@ class Chef
key_name = key.gsub(/[^0-9A-Za-z\-]/, "_")
cached_keyfile = ::File.join(Chef::Config[:file_cache_path], key_name)
tmp_dir = Dir.mktmpdir(".gpg")
- at_exit { FileUtils.remove_entry(tmp_dir) }
+ at_exit do FileUtils.remove_entry(tmp_dir) end
declare_resource(key_type(key), cached_keyfile) do
source key
@@ -216,7 +216,7 @@ class Chef
default_env true
sensitive new_resource.sensitive
action :run
- not_if { no_new_keys?(cached_keyfile) }
+ not_if do no_new_keys?(cached_keyfile) end
notifies :run, "execute[apt-cache gencaches]", :immediately
end
end
@@ -252,9 +252,9 @@ class Chef
default_env true
sensitive new_resource.sensitive
not_if do
- present = extract_fingerprints_from_cmd(*LIST_APT_KEY_FINGERPRINTS).any? do |fp|
+ present = extract_fingerprints_from_cmd(*LIST_APT_KEY_FINGERPRINTS).any? { |fp|
fp.end_with? key.upcase
- end
+ }
present && key_is_valid?(key.upcase)
end
notifies :run, "execute[apt-cache gencaches]", :immediately
diff --git a/lib/chef/provider/dsc_resource.rb b/lib/chef/provider/dsc_resource.rb
index da8b17ed04..7b1c77b780 100644
--- a/lib/chef/provider/dsc_resource.rb
+++ b/lib/chef/provider/dsc_resource.rb
@@ -46,7 +46,7 @@ class Chef
def define_resource_requirements
requirements.assert(:run) do |a|
- a.assertion { supports_dsc_invoke_resource? }
+ a.assertion do supports_dsc_invoke_resource? end
err = ["You must have PowerShell version >= 5.0.10018.0 to use dsc_resource."]
a.failure_message Chef::Exceptions::ProviderNotFound,
err
@@ -54,7 +54,7 @@ class Chef
a.block_action!
end
requirements.assert(:run) do |a|
- a.assertion { supports_refresh_mode_enabled? || dsc_refresh_mode_disabled? }
+ a.assertion do supports_refresh_mode_enabled? || dsc_refresh_mode_disabled? end
err = ["The LCM must have its RefreshMode set to Disabled for" \
" PowerShell versions before 5.0.10586.0."]
a.failure_message Chef::Exceptions::ProviderNotFound, err.join(" ")
@@ -62,7 +62,7 @@ class Chef
a.block_action!
end
requirements.assert(:run) do |a|
- a.assertion { module_usage_valid? }
+ a.assertion do module_usage_valid? end
err = ["module_name must be supplied along with module_version."]
a.failure_message Chef::Exceptions::DSCModuleNameMissing,
err
diff --git a/lib/chef/provider/dsc_script.rb b/lib/chef/provider/dsc_script.rb
index 999ea9f33e..510fa2a843 100644
--- a/lib/chef/provider/dsc_script.rb
+++ b/lib/chef/provider/dsc_script.rb
@@ -52,9 +52,9 @@ class Chef
def load_current_resource
if supports_dsc?
@dsc_resources_info = run_configuration(:test)
- @resource_converged = @dsc_resources_info.all? do |resource|
+ @resource_converged = @dsc_resources_info.all? { |resource|
!resource.changes_state?
- end
+ }
end
end
@@ -65,7 +65,7 @@ class Chef
powershell_info_str,
"PowerShell 4.0 or higher was not detected on your system and is required to use the dsc_script resource.",
]
- a.assertion { supports_dsc? }
+ a.assertion do supports_dsc? end
a.failure_message Chef::Exceptions::ProviderNotFound, err.join(" ")
a.whyrun err + ["Assuming a previous resource installs PowerShell 4.0 or higher."]
a.block_action!
@@ -157,7 +157,7 @@ class Chef
def generate_description
["converge DSC configuration '#{configuration_friendly_name}'"] +
- @dsc_resources_info.map do |resource|
+ @dsc_resources_info.map { |resource|
if resource.changes_state?
# We ignore the last log message because it only contains the time it took, which looks weird
cleaned_messages = resource.change_log[0..-2].map { |c| c.sub(/^#{Regexp.escape(resource.name)}/, "").strip }
@@ -170,7 +170,7 @@ class Chef
# This is needed because a dsc script can have resources that are both converged and not
"converge DSC resource #{resource.name} by doing nothing because it is already converged"
end
- end
+ }
end
def powershell_info_str
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb
index 054b9718c3..cf297a3f8f 100644
--- a/lib/chef/provider/file.rb
+++ b/lib/chef/provider/file.rb
@@ -112,7 +112,7 @@ class Chef
# Make sure the parent directory exists, otherwise fail. For why-run assume it would have been created.
requirements.assert(:create, :create_if_missing, :touch) do |a|
parent_directory = ::File.dirname(new_resource.path)
- a.assertion { ::File.directory?(parent_directory) }
+ a.assertion do ::File.directory?(parent_directory) end
a.failure_message(Chef::Exceptions::EnclosingDirectoryDoesNotExist, "Parent directory #{parent_directory} does not exist.")
a.whyrun("Assuming directory #{parent_directory} would have been created")
end
@@ -120,14 +120,14 @@ class Chef
# Make sure the file is deletable if it exists, otherwise fail.
if ::File.exist?(new_resource.path)
requirements.assert(:delete) do |a|
- a.assertion { ::File.writable?(new_resource.path) }
+ a.assertion do ::File.writable?(new_resource.path) end
a.failure_message(Chef::Exceptions::InsufficientPermissions, "File #{new_resource.path} exists but is not writable so it cannot be deleted")
end
end
error, reason, whyrun_message = inspect_existing_fs_entry
requirements.assert(:create) do |a|
- a.assertion { error.nil? }
+ a.assertion do error.nil? end
a.failure_message(error, reason)
a.whyrun(whyrun_message)
# Subsequent attempts to read the fs entry at the path (e.g., for
diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb
index b7ca81b3f8..90cfd081eb 100644
--- a/lib/chef/provider/git.rb
+++ b/lib/chef/provider/git.rb
@@ -44,14 +44,14 @@ class Chef
# Parent directory of the target must exist.
requirements.assert(:checkout, :sync) do |a|
dirname = ::File.dirname(cwd)
- a.assertion { ::File.directory?(dirname) }
+ a.assertion do ::File.directory?(dirname) end
a.whyrun("Directory #{dirname} does not exist, this run will fail unless it has been previously created. Assuming it would have been created.")
a.failure_message(Chef::Exceptions::MissingParentDirectory,
"Cannot clone #{new_resource} to #{cwd}, the enclosing directory #{dirname} does not exist")
end
requirements.assert(:all_actions) do |a|
- a.assertion { !(new_resource.revision =~ %r{^origin/}) }
+ a.assertion do !(new_resource.revision =~ %r{^origin/}) end
a.failure_message Chef::Exceptions::InvalidRemoteGitReference,
"Deploying remote branches is not supported. " +
"Specify the remote branch as a local branch for " +
@@ -63,7 +63,7 @@ class Chef
# this can't be recovered from in why-run mode, because nothing that
# we do in the course of a run is likely to create a valid target_revision
# if we can't resolve it up front.
- a.assertion { !target_revision.nil? }
+ a.assertion do !target_revision.nil? end
a.failure_message Chef::Exceptions::UnresolvableGitReference,
"Unable to parse SHA reference for '#{new_resource.revision}' in repository '#{new_resource.repository}'. " +
"Verify your (case-sensitive) repository URL and revision.\n" +
diff --git a/lib/chef/provider/group.rb b/lib/chef/provider/group.rb
index 1c8a18c037..86ff6fdbe1 100644
--- a/lib/chef/provider/group.rb
+++ b/lib/chef/provider/group.rb
@@ -55,7 +55,7 @@ class Chef
def define_resource_requirements
requirements.assert(:modify) do |a|
- a.assertion { @group_exists }
+ a.assertion do @group_exists end
a.failure_message(Chef::Exceptions::Group, "Cannot modify #{new_resource} - group does not exist!")
a.whyrun("Group #{new_resource} does not exist. Unless it would have been created earlier in this run, this attempt to modify it would fail.")
end
@@ -65,7 +65,7 @@ class Chef
# user names in the members and exclude_members properties.
if !new_resource.members.nil? && !new_resource.excluded_members.nil?
common_members = new_resource.members & new_resource.excluded_members
- a.assertion { common_members.empty? }
+ a.assertion do common_members.empty? end
a.failure_message(Chef::Exceptions::ConflictingMembersInGroup, "Attempting to both add and remove users from a group: '#{common_members.join(", ")}'")
# No why-run alternative
end
diff --git a/lib/chef/provider/group/dscl.rb b/lib/chef/provider/group/dscl.rb
index decad69e40..d8370ff57e 100644
--- a/lib/chef/provider/group/dscl.rb
+++ b/lib/chef/provider/group/dscl.rb
@@ -30,8 +30,8 @@ class Chef
status = shell_out(shellcmd)
stdout_result = ""
stderr_result = ""
- status.stdout.each_line { |line| stdout_result << line }
- status.stderr.each_line { |line| stderr_result << line }
+ status.stdout.each_line do |line| stdout_result << line end
+ status.stderr.each_line do |line| stderr_result << line end
[shellcmd.flatten.compact.join(" "), status, stdout_result, stderr_result]
end
@@ -142,7 +142,7 @@ class Chef
def define_resource_requirements
super
requirements.assert(:all_actions) do |a|
- a.assertion { ::File.exist?("/usr/bin/dscl") }
+ a.assertion do ::File.exist?("/usr/bin/dscl") end
a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/bin/dscl for #{new_resource.name}"
# No whyrun alternative: this component should be available in the base install of any given system that uses it
end
diff --git a/lib/chef/provider/group/gpasswd.rb b/lib/chef/provider/group/gpasswd.rb
index 5d769befa4..6eaf4cc991 100644
--- a/lib/chef/provider/group/gpasswd.rb
+++ b/lib/chef/provider/group/gpasswd.rb
@@ -31,7 +31,7 @@ class Chef
def define_resource_requirements
super
requirements.assert(:all_actions) do |a|
- a.assertion { ::File.exist?("/usr/bin/gpasswd") }
+ a.assertion do ::File.exist?("/usr/bin/gpasswd") end
a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/bin/gpasswd for #{new_resource}"
# No whyrun alternative: this component should be available in the base install of any given system that uses it
end
diff --git a/lib/chef/provider/group/groupadd.rb b/lib/chef/provider/group/groupadd.rb
index eca104b565..9671ec35de 100644
--- a/lib/chef/provider/group/groupadd.rb
+++ b/lib/chef/provider/group/groupadd.rb
@@ -35,7 +35,7 @@ class Chef
super
required_binaries.each do |required_binary|
requirements.assert(:all_actions) do |a|
- a.assertion { ::File.exist?(required_binary) }
+ a.assertion do ::File.exist?(required_binary) end
a.failure_message Chef::Exceptions::Group, "Could not find binary #{required_binary} for #{new_resource}"
# No whyrun alternative: this component should be available in the base install of any given system that uses it
end
diff --git a/lib/chef/provider/group/pw.rb b/lib/chef/provider/group/pw.rb
index c018de8d4d..ecad8f44ba 100644
--- a/lib/chef/provider/group/pw.rb
+++ b/lib/chef/provider/group/pw.rb
@@ -30,7 +30,7 @@ class Chef
super
requirements.assert(:all_actions) do |a|
- a.assertion { ::File.exist?("/usr/sbin/pw") }
+ a.assertion do ::File.exist?("/usr/sbin/pw") end
a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/pw for #{new_resource}"
# No whyrun alternative: this component should be available in the base install of any given system that uses it
end
diff --git a/lib/chef/provider/group/solaris.rb b/lib/chef/provider/group/solaris.rb
index 75768297db..fe33f06917 100644
--- a/lib/chef/provider/group/solaris.rb
+++ b/lib/chef/provider/group/solaris.rb
@@ -35,7 +35,7 @@ class Chef
super
requirements.assert(:all_actions) do |a|
- a.assertion { ::File.exist?("/usr/sbin/usermod") && ::File.exist?("/usr/sbin/groupmod") }
+ a.assertion do ::File.exist?("/usr/sbin/usermod") && ::File.exist?("/usr/sbin/groupmod") end
a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/usermod or /usr/sbin/groupmod for #{new_resource}"
# No whyrun alternative: this component should be available in the base install of any given system that uses it
end
diff --git a/lib/chef/provider/group/suse.rb b/lib/chef/provider/group/suse.rb
index 7bd9700a15..76026eea51 100644
--- a/lib/chef/provider/group/suse.rb
+++ b/lib/chef/provider/group/suse.rb
@@ -32,7 +32,7 @@ class Chef
def define_resource_requirements
super
requirements.assert(:all_actions) do |a|
- a.assertion { ::File.exist?("/usr/sbin/groupmod") }
+ a.assertion do ::File.exist?("/usr/sbin/groupmod") end
a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/groupmod for #{new_resource.name}"
# No whyrun alternative: this component should be available in the base install of any given system that uses it
end
@@ -40,7 +40,7 @@ class Chef
requirements.assert(:create, :manage, :modify) do |a|
a.assertion do
begin
- to_add(new_resource.members).all? { |member| Etc.getpwnam(member) }
+ to_add(new_resource.members).all? do |member| Etc.getpwnam(member) end
rescue
false
end
diff --git a/lib/chef/provider/group/usermod.rb b/lib/chef/provider/group/usermod.rb
index b4e93580ff..9f414d7feb 100644
--- a/lib/chef/provider/group/usermod.rb
+++ b/lib/chef/provider/group/usermod.rb
@@ -33,19 +33,19 @@ class Chef
super
requirements.assert(:all_actions) do |a|
- a.assertion { ::File.exist?("/usr/sbin/usermod") }
+ a.assertion do ::File.exist?("/usr/sbin/usermod") end
a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/usermod for #{new_resource}"
# No whyrun alternative: this component should be available in the base install of any given system that uses it
end
requirements.assert(:modify, :manage) do |a|
- a.assertion { new_resource.members.empty? || new_resource.append }
+ a.assertion do new_resource.members.empty? || new_resource.append end
a.failure_message Chef::Exceptions::Group, "setting group members directly is not supported by #{self}, must set append true in group"
# No whyrun alternative - this action is simply not supported.
end
requirements.assert(:all_actions) do |a|
- a.assertion { new_resource.excluded_members.empty? }
+ a.assertion do new_resource.excluded_members.empty? end
a.failure_message Chef::Exceptions::Group, "excluded_members is not supported by #{self}"
# No whyrun alternative - this action is simply not supported.
end
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb
index 93db827e97..bf2e0f6704 100644
--- a/lib/chef/provider/ifconfig.rb
+++ b/lib/chef/provider/ifconfig.rb
@@ -152,7 +152,7 @@ class Chef
def define_resource_requirements
requirements.assert(:all_actions) do |a|
- a.assertion { @status.exitstatus == 0 }
+ a.assertion do @status.exitstatus == 0 end
a.failure_message Chef::Exceptions::Ifconfig, "ifconfig failed - #{@status.inspect}!"
# no whyrun - if the base ifconfig used in load_current_resource fails
# there's no reasonable action that could have been taken in the course of
diff --git a/lib/chef/provider/ifconfig/aix.rb b/lib/chef/provider/ifconfig/aix.rb
index 2f83336f8d..f87198594b 100644
--- a/lib/chef/provider/ifconfig/aix.rb
+++ b/lib/chef/provider/ifconfig/aix.rb
@@ -85,7 +85,7 @@ class Chef
def hex_to_dec_netmask(netmask)
# example '0xffff0000' -> '255.255.0.0'
dec = netmask[2..3].to_i(16).to_s(10)
- [4, 6, 8].each { |n| dec = dec + "." + netmask[n..n + 1].to_i(16).to_s(10) }
+ [4, 6, 8].each do |n| dec = dec + "." + netmask[n..n + 1].to_i(16).to_s(10) end
dec
end
diff --git a/lib/chef/provider/launchd.rb b/lib/chef/provider/launchd.rb
index 4f20a417a6..9974a9a786 100644
--- a/lib/chef/provider/launchd.rb
+++ b/lib/chef/provider/launchd.rb
@@ -164,7 +164,7 @@ class Chef
:create, :create_if_missing, :delete, :enable, :disable
) do |a|
type = new_resource.type
- a.assertion { %w{daemon agent}.include?(type.to_s) }
+ a.assertion do %w{daemon agent}.include?(type.to_s) end
error_msg = "type must be daemon or agent."
a.failure_message Chef::Exceptions::ValidationFailed, error_msg
end
diff --git a/lib/chef/provider/mount/solaris.rb b/lib/chef/provider/mount/solaris.rb
index 24f3a1f7ec..1a235415dd 100644
--- a/lib/chef/provider/mount/solaris.rb
+++ b/lib/chef/provider/mount/solaris.rb
@@ -53,21 +53,21 @@ class Chef
def define_resource_requirements
requirements.assert(:mount, :remount) do |a|
- a.assertion { !device_should_exist? || ::File.exist?(device) }
+ a.assertion do !device_should_exist? || ::File.exist?(device) end
a.failure_message(Chef::Exceptions::Mount, "Device #{device} does not exist")
a.whyrun("Assuming device #{device} would have been created")
end
unless fsck_device == "-"
requirements.assert(:mount, :remount) do |a|
- a.assertion { ::File.exist?(fsck_device) }
+ a.assertion do ::File.exist?(fsck_device) end
a.failure_message(Chef::Exceptions::Mount, "Device #{fsck_device} does not exist")
a.whyrun("Assuming device #{fsck_device} would have been created")
end
end
requirements.assert(:mount, :remount) do |a|
- a.assertion { ::File.exist?(mount_point) }
+ a.assertion do ::File.exist?(mount_point) end
a.failure_message(Chef::Exceptions::Mount, "Mount point #{mount_point} does not exist")
a.whyrun("Assuming mount point #{mount_point} would have been created")
end
diff --git a/lib/chef/provider/osx_profile.rb b/lib/chef/provider/osx_profile.rb
index f05cd198e3..c011bca6a3 100644
--- a/lib/chef/provider/osx_profile.rb
+++ b/lib/chef/provider/osx_profile.rb
@@ -53,9 +53,9 @@ class Chef
current_profile = nil
if all_profiles && all_profiles.key?("_computerlevel")
- current_profile = all_profiles["_computerlevel"].find do |item|
+ current_profile = all_profiles["_computerlevel"].find { |item|
item["ProfileIdentifier"] == @new_profile_identifier
- end
+ }
end
current_resource.profile(current_profile)
end
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index 5ccb264adf..c89564a337 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -67,7 +67,7 @@ class Chef
# XXX: upgrade with a specific version doesn't make a whole lot of sense, but why don't we throw this anyway if it happens?
# if not, shouldn't we raise to tell the user to use install instead of upgrade if they want to pin a version?
requirements.assert(:install) do |a|
- a.assertion { candidates_exist_for_all_forced_changes? }
+ a.assertion do candidates_exist_for_all_forced_changes? end
a.failure_message(Chef::Exceptions::Package, "No version specified, and no candidate version available for #{forced_packages_missing_candidates.join(", ")}")
a.whyrun("Assuming a repository that offers #{forced_packages_missing_candidates.join(", ")} would have been configured")
end
@@ -76,7 +76,7 @@ class Chef
# not, but as with the above comment, we don't yet enforce such a thing,
# so we'll just leave things as-is for now.
requirements.assert(:upgrade, :install) do |a|
- a.assertion { candidates_exist_for_all_uninstalled? || new_resource.source }
+ a.assertion do candidates_exist_for_all_uninstalled? || new_resource.source end
a.failure_message(Chef::Exceptions::Package, "No candidate version available for #{packages_missing_candidates.join(", ")}")
a.whyrun("Assuming a repository that offers #{packages_missing_candidates.join(", ")} would have been configured")
end
diff --git a/lib/chef/provider/package/apt.rb b/lib/chef/provider/package/apt.rb
index 744e5b2e83..8cee5cdcd7 100644
--- a/lib/chef/provider/package/apt.rb
+++ b/lib/chef/provider/package/apt.rb
@@ -45,7 +45,7 @@ class Chef
super
requirements.assert(:all_actions) do |a|
- a.assertion { !new_resource.source }
+ a.assertion do !new_resource.source end
a.failure_message(Chef::Exceptions::Package, "apt package provider cannot handle source property. Use dpkg provider instead")
end
end
@@ -89,9 +89,9 @@ class Chef
end
def install_package(name, version)
- package_name = name.zip(version).map do |n, v|
+ package_name = name.zip(version).map { |n, v|
package_data[n][:virtual] ? n : "#{n}=#{v}"
- end
+ }
dgrade = "--allow-downgrades" if supports_allow_downgrade? && allow_downgrade
run_noninteractive("apt-get", "-q", "-y", dgrade, config_file_options, default_release_options, options, "install", package_name)
end
@@ -101,16 +101,16 @@ class Chef
end
def remove_package(name, version)
- package_name = name.map do |n|
+ package_name = name.map { |n|
package_data[n][:virtual] ? resolve_virtual_package_name(n) : n
- end
+ }
run_noninteractive("apt-get", "-q", "-y", options, "remove", package_name)
end
def purge_package(name, version)
- package_name = name.map do |n|
+ package_name = name.map { |n|
package_data[n][:virtual] ? resolve_virtual_package_name(n) : n
- end
+ }
run_noninteractive("apt-get", "-q", "-y", options, "purge", package_name)
end
diff --git a/lib/chef/provider/package/bff.rb b/lib/chef/provider/package/bff.rb
index 0b358dcb46..77d5277fa2 100644
--- a/lib/chef/provider/package/bff.rb
+++ b/lib/chef/provider/package/bff.rb
@@ -33,11 +33,11 @@ class Chef
def define_resource_requirements
super
requirements.assert(:install) do |a|
- a.assertion { new_resource.source }
+ a.assertion do new_resource.source end
a.failure_message Chef::Exceptions::Package, "Source for package #{new_resource.package_name} required for action install"
end
requirements.assert(:all_actions) do |a|
- a.assertion { !new_resource.source || package_source_found? }
+ a.assertion do !new_resource.source || package_source_found? end
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found: #{new_resource.source}"
a.whyrun "would assume #{new_resource.source} would be have previously been made available"
end
diff --git a/lib/chef/provider/package/cab.rb b/lib/chef/provider/package/cab.rb
index fd099811e0..7488ec8c9b 100644
--- a/lib/chef/provider/package/cab.rb
+++ b/lib/chef/provider/package/cab.rb
@@ -51,11 +51,11 @@ class Chef
end
def source_resource
- @source_resource ||= declare_resource(:remote_file, new_resource.name) do
+ @source_resource ||= declare_resource(:remote_file, new_resource.name) {
path default_download_cache_path
source new_resource.source
backup false
- end
+ }
end
def default_download_cache_path
@@ -90,12 +90,12 @@ class Chef
package = new_cab_identity
# Search for just the package name to catch a different version being installed
logger.trace("#{new_resource} searching for installed package #{package["name"]}")
- existing_package_identities = installed_packages.map do |p|
+ existing_package_identities = installed_packages.map { |p|
split_package_identity(p["package_identity"])
- end
- found_packages = existing_package_identities.select do |existing_package_ident|
+ }
+ found_packages = existing_package_identities.select { |existing_package_ident|
existing_package_ident["name"] == package["name"]
- end
+ }
if found_packages.empty?
nil
elsif found_packages.length == 1
diff --git a/lib/chef/provider/package/chocolatey.rb b/lib/chef/provider/package/chocolatey.rb
index a09bbf55de..8bf1427200 100644
--- a/lib/chef/provider/package/chocolatey.rb
+++ b/lib/chef/provider/package/chocolatey.rb
@@ -58,7 +58,7 @@ class Chef
# and not a package specific alternate source like other providers
# so we want to assert candidates exist for the alternate source
requirements.assert(:upgrade, :install) do |a|
- a.assertion { candidates_exist_for_all_uninstalled? }
+ a.assertion do candidates_exist_for_all_uninstalled? end
a.failure_message(Chef::Exceptions::Package, "No candidate version available for #{packages_missing_candidates.join(", ")}")
a.whyrun("Assuming a repository that offers #{packages_missing_candidates.join(", ")} would have been configured")
end
diff --git a/lib/chef/provider/package/dnf.rb b/lib/chef/provider/package/dnf.rb
index d7b61e0789..fc142cc855 100644
--- a/lib/chef/provider/package/dnf.rb
+++ b/lib/chef/provider/package/dnf.rb
@@ -73,7 +73,7 @@ class Chef
def define_resource_requirements
requirements.assert(:install, :upgrade, :remove, :purge) do |a|
- a.assertion { !new_resource.source || ::File.exist?(new_resource.source) }
+ a.assertion do !new_resource.source || ::File.exist?(new_resource.source) end
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found: #{new_resource.source}"
a.whyrun "assuming #{new_resource.source} would have previously been created"
end
diff --git a/lib/chef/provider/package/dnf/python_helper.rb b/lib/chef/provider/package/dnf/python_helper.rb
index c5edbfbc3a..8039bbbe0d 100644
--- a/lib/chef/provider/package/dnf/python_helper.rb
+++ b/lib/chef/provider/package/dnf/python_helper.rb
@@ -38,9 +38,9 @@ class Chef
def dnf_command
# platform-python is used for system tools on RHEL 8 and is installed under /usr/libexec
- @dnf_command ||= which("platform-python", "python", "python3", "python2", "python2.7", extra_path: "/usr/libexec") do |f|
+ @dnf_command ||= which("platform-python", "python", "python3", "python2", "python2.7", extra_path: "/usr/libexec") { |f|
shell_out("#{f} -c 'import dnf'").exitstatus == 0
- end + " #{DNF_HELPER}"
+ } + " #{DNF_HELPER}"
end
def start
diff --git a/lib/chef/provider/package/dpkg.rb b/lib/chef/provider/package/dpkg.rb
index e6012edee8..89b6fce07a 100644
--- a/lib/chef/provider/package/dpkg.rb
+++ b/lib/chef/provider/package/dpkg.rb
@@ -38,12 +38,12 @@ class Chef
super
requirements.assert(:install, :upgrade) do |a|
- a.assertion { !resolved_source_array.compact.empty? }
+ a.assertion do !resolved_source_array.compact.empty? end
a.failure_message Chef::Exceptions::Package, "#{new_resource} the source property is required for action :install or :upgrade"
end
requirements.assert(:install, :upgrade) do |a|
- a.assertion { source_files_exist? }
+ a.assertion do source_files_exist? end
a.failure_message Chef::Exceptions::Package, "#{new_resource} source file(s) do not exist: #{missing_sources}"
a.whyrun "Assuming they would have been previously created."
end
@@ -176,11 +176,11 @@ class Chef
def name_pkginfo
@name_pkginfo ||=
begin
- pkginfos = resolved_source_array.map do |src|
+ pkginfos = resolved_source_array.map { |src|
logger.trace("#{new_resource} checking #{src} dpkg status")
status = shell_out!("dpkg-deb", "-W", src)
status.stdout
- end
+ }
Hash[*package_name_array.zip(pkginfos).flatten]
end
end
diff --git a/lib/chef/provider/package/ips.rb b/lib/chef/provider/package/ips.rb
index 686ffe96ee..fb96c0af40 100644
--- a/lib/chef/provider/package/ips.rb
+++ b/lib/chef/provider/package/ips.rb
@@ -35,7 +35,7 @@ class Chef
super
requirements.assert(:all_actions) do |a|
- a.assertion { !@candidate_version.nil? }
+ a.assertion do !@candidate_version.nil? end
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found"
a.whyrun "Assuming package #{new_resource.package_name} would have been made available."
end
diff --git a/lib/chef/provider/package/msu.rb b/lib/chef/provider/package/msu.rb
index a00b3f3471..9f5c5abe30 100644
--- a/lib/chef/provider/package/msu.rb
+++ b/lib/chef/provider/package/msu.rb
@@ -89,12 +89,12 @@ class Chef
end
def source_resource
- @source_resource ||= declare_resource(:remote_file, new_resource.name) do
+ @source_resource ||= declare_resource(:remote_file, new_resource.name) {
path default_download_cache_path
source new_resource.source
checksum new_resource.checksum
backup false
- end
+ }
end
def default_download_cache_path
diff --git a/lib/chef/provider/package/openbsd.rb b/lib/chef/provider/package/openbsd.rb
index 38ff84f105..62b4ea6d4a 100644
--- a/lib/chef/provider/package/openbsd.rb
+++ b/lib/chef/provider/package/openbsd.rb
@@ -52,7 +52,7 @@ class Chef
# Below are incomplete/missing features for this package provider
requirements.assert(:all_actions) do |a|
- a.assertion { !new_resource.source }
+ a.assertion do !new_resource.source end
a.failure_message(Chef::Exceptions::Package, "The openbsd package provider does not support the source property")
end
requirements.assert(:all_actions) do |a|
diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb
index 889d262d1e..2c9c629615 100644
--- a/lib/chef/provider/package/portage.rb
+++ b/lib/chef/provider/package/portage.rb
@@ -39,11 +39,11 @@ class Chef
globsafe_category = category ? Chef::Util::PathHelper.escape_glob_dir(category) : nil
globsafe_pkg = Chef::Util::PathHelper.escape_glob_dir(pkg)
possibilities = Dir["/var/db/pkg/#{globsafe_category || "*"}/#{globsafe_pkg}-*"].map { |d| d.sub(%r{/var/db/pkg/}, "") }
- versions = possibilities.map do |entry|
+ versions = possibilities.map { |entry|
if entry =~ %r{[^/]+/#{Regexp.escape(pkg)}\-(\d[\.\d]*[a-z]?((_(alpha|beta|pre|rc|p)\d*)*)?(-r\d+)?)}
[$&, $1]
end
- end.compact
+ }.compact
if versions.size > 1
atoms = versions.map(&:first).sort
diff --git a/lib/chef/provider/package/powershell.rb b/lib/chef/provider/package/powershell.rb
index a27f7fa6c8..26f8206f10 100644
--- a/lib/chef/provider/package/powershell.rb
+++ b/lib/chef/provider/package/powershell.rb
@@ -41,7 +41,7 @@ class Chef
end
requirements.assert(:install) do |a|
- a.assertion { candidates_exist_for_all_uninstalled? }
+ a.assertion do candidates_exist_for_all_uninstalled? end
a.failure_message(Chef::Exceptions::Package, "No candidate version available for #{packages_missing_candidates.join(", ")}")
a.whyrun("Assuming a repository that offers #{packages_missing_candidates.join(", ")} would have been configured")
end
diff --git a/lib/chef/provider/package/rpm.rb b/lib/chef/provider/package/rpm.rb
index 75b41a26e4..1f62aa84c4 100644
--- a/lib/chef/provider/package/rpm.rb
+++ b/lib/chef/provider/package/rpm.rb
@@ -32,12 +32,12 @@ class Chef
super
requirements.assert(:all_actions) do |a|
- a.assertion { @package_source_exists }
+ a.assertion do @package_source_exists end
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found: #{new_resource.source}"
a.whyrun "Assuming package #{new_resource.package_name} would have been made available."
end
requirements.assert(:all_actions) do |a|
- a.assertion { !@rpm_status.nil? && (@rpm_status.exitstatus == 0 || @rpm_status.exitstatus == 1) }
+ a.assertion do !@rpm_status.nil? && (@rpm_status.exitstatus == 0 || @rpm_status.exitstatus == 1) end
a.failure_message Chef::Exceptions::Package, "Unable to determine current version due to RPM failure. Detail: #{@rpm_status.inspect}"
a.whyrun "Assuming current version would have been determined for package #{new_resource.package_name}."
end
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
index 876a90392c..031c49c0eb 100644
--- a/lib/chef/provider/package/rubygems.rb
+++ b/lib/chef/provider/package/rubygems.rb
@@ -100,7 +100,7 @@ class Chef
# Filter down to only to only stubs we actually want. The name
# filter is needed in case of things like `foo-*.gemspec` also
# matching a gem named `foo-bar`.
- stubs.select! { |stub| stub.name == gem_dep.name && gem_dep.requirement.satisfied_by?(stub.version) }
+ stubs.select! do |stub| stub.name == gem_dep.name && gem_dep.requirement.satisfied_by?(stub.version) end
# This isn't sorting before returning beacuse the only code that
# uses this method calls `max_by` so it doesn't need to be sorted.
stubs
@@ -151,11 +151,11 @@ class Chef
def candidate_version_from_file(gem_dependency, source)
spec = spec_from_file(source)
if spec.satisfies_requirement?(gem_dependency)
- logger.trace { "found candidate gem version #{spec.version} from local gem package #{source}" }
+ logger.trace do "found candidate gem version #{spec.version} from local gem package #{source}" end
spec.version
else
# This is probably going to end badly...
- logger.warn { "gem package #{source} does not satisfy the requirements #{gem_dependency}" }
+ logger.warn do "gem package #{source} does not satisfy the requirements #{gem_dependency}" end
nil
end
end
@@ -196,11 +196,11 @@ class Chef
version = spec && spec.version
if version
- logger.trace { "found gem #{spec.name} version #{version} for platform #{spec.platform} from #{source}" }
+ logger.trace do "found gem #{spec.name} version #{version} for platform #{spec.platform} from #{source}" end
version
else
source_list = sources.compact.empty? ? "[#{Gem.sources.to_a.join(", ")}]" : "[#{sources.join(", ")}]"
- logger.warn { "failed to find gem #{gem_dependency} from #{source_list}" }
+ logger.warn do "failed to find gem #{gem_dependency} from #{source_list}" end
nil
end
end
@@ -459,16 +459,16 @@ class Chef
# is the current version
if !matching_installed_versions.empty?
gemspec = matching_installed_versions.max_by(&:version)
- logger.trace { "#{new_resource} found installed gem #{gemspec.name} version #{gemspec.version} matching #{gem_dependency}" }
+ logger.trace do "#{new_resource} found installed gem #{gemspec.name} version #{gemspec.version} matching #{gem_dependency}" end
gemspec
# If no version matching the requirements exists, the latest installed
# version is the current version.
elsif !all_installed_versions.empty?
gemspec = all_installed_versions.max_by(&:version)
- logger.trace { "#{new_resource} newest installed version of gem #{gemspec.name} is #{gemspec.version}" }
+ logger.trace do "#{new_resource} newest installed version of gem #{gemspec.name} is #{gemspec.version}" end
gemspec
else
- logger.trace { "#{new_resource} no installed version found for #{gem_dependency}" }
+ logger.trace do "#{new_resource} no installed version found for #{gem_dependency}" end
nil
end
end
@@ -500,7 +500,7 @@ class Chef
def cleanup_after_converge
if @cleanup_gem_env
- logger.trace { "#{new_resource} resetting gem environment to default" }
+ logger.trace do "#{new_resource} resetting gem environment to default" end
Gem.clear_paths
end
end
diff --git a/lib/chef/provider/package/snap.rb b/lib/chef/provider/package/snap.rb
index cb639ff77f..7be0266afe 100644
--- a/lib/chef/provider/package/snap.rb
+++ b/lib/chef/provider/package/snap.rb
@@ -42,7 +42,7 @@ class Chef
def define_resource_requirements
requirements.assert(:install, :upgrade, :remove, :purge) do |a|
- a.assertion { !new_resource.source || ::File.exist?(new_resource.source) }
+ a.assertion do !new_resource.source || ::File.exist?(new_resource.source) end
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found: #{new_resource.source}"
a.whyrun "assuming #{new_resource.source} would have previously been created"
end
@@ -238,14 +238,14 @@ class Chef
# @param path [String] Path to the package on disk
# @param content_length [Integer] byte size of the snap file
def generate_multipart_form_data(snap_name, action, options, path, content_length)
- snap_options = options.map do |k, v|
+ snap_options = options.map { |k, v|
<<~SNAP_OPTION
Content-Disposition: form-data; name="#{k}"
#{v}
--#{snap_name}
SNAP_OPTION
- end
+ }
multipart_form_data = <<~SNAP_S
Host:
diff --git a/lib/chef/provider/package/solaris.rb b/lib/chef/provider/package/solaris.rb
index fb0e88ecdb..28c33f4299 100644
--- a/lib/chef/provider/package/solaris.rb
+++ b/lib/chef/provider/package/solaris.rb
@@ -37,11 +37,11 @@ class Chef
def define_resource_requirements
super
requirements.assert(:install) do |a|
- a.assertion { new_resource.source }
+ a.assertion do new_resource.source end
a.failure_message Chef::Exceptions::Package, "Source for package #{new_resource.package_name} required for action install"
end
requirements.assert(:all_actions) do |a|
- a.assertion { !new_resource.source || @package_source_found }
+ a.assertion do !new_resource.source || @package_source_found end
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found: #{new_resource.source}"
a.whyrun "would assume #{new_resource.source} would be have previously been made available"
end
diff --git a/lib/chef/provider/package/windows.rb b/lib/chef/provider/package/windows.rb
index d21c6576b6..8bde66fad3 100644
--- a/lib/chef/provider/package/windows.rb
+++ b/lib/chef/provider/package/windows.rb
@@ -36,13 +36,13 @@ class Chef
def define_resource_requirements
requirements.assert(:install) do |a|
- a.assertion { new_resource.source || msi? }
+ a.assertion do new_resource.source || msi? end
a.failure_message Chef::Exceptions::NoWindowsPackageSource, "Source for package #{new_resource.package_name} must be specified in the resource's source property for package to be installed because the package_name property is used to test for the package installation state for this package type."
end
unless uri_scheme?(new_resource.source)
requirements.assert(:install) do |a|
- a.assertion { ::File.exist?(new_resource.source) }
+ a.assertion do ::File.exist?(new_resource.source) end
a.failure_message Chef::Exceptions::Package, "Source for package #{new_resource.package_name} does not exist"
a.whyrun "Assuming source file #{new_resource.source} would have been created."
end
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb
index e32457cc0c..ad528f9463 100644
--- a/lib/chef/provider/package/yum.rb
+++ b/lib/chef/provider/package/yum.rb
@@ -66,7 +66,7 @@ class Chef
def define_resource_requirements
requirements.assert(:install, :upgrade, :remove, :purge) do |a|
- a.assertion { !new_resource.source || ::File.exist?(new_resource.source) }
+ a.assertion do !new_resource.source || ::File.exist?(new_resource.source) end
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found: #{new_resource.source}"
a.whyrun "assuming #{new_resource.source} would have previously been created"
end
diff --git a/lib/chef/provider/package/yum/python_helper.rb b/lib/chef/provider/package/yum/python_helper.rb
index f99b17bcce..bc1124818d 100644
--- a/lib/chef/provider/package/yum/python_helper.rb
+++ b/lib/chef/provider/package/yum/python_helper.rb
@@ -40,9 +40,9 @@ class Chef
YUM_HELPER = ::File.expand_path(::File.join(::File.dirname(__FILE__), "yum_helper.py")).freeze
def yum_command
- @yum_command ||= which("platform-python", "python", "python2", "python2.7", extra_path: "/usr/libexec") do |f|
+ @yum_command ||= which("platform-python", "python", "python2", "python2.7", extra_path: "/usr/libexec") { |f|
shell_out("#{f} -c 'import yum'").exitstatus == 0
- end + " #{YUM_HELPER}"
+ } + " #{YUM_HELPER}"
end
def start
diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb
index a828da1c6c..286bc04c62 100644
--- a/lib/chef/provider/package/zypper.rb
+++ b/lib/chef/provider/package/zypper.rb
@@ -56,9 +56,9 @@ class Chef
def versions
@versions ||=
begin
- raw_versions = package_name_array.map do |package_name|
+ raw_versions = package_name_array.map { |package_name|
get_versions(package_name)
- end
+ }
Hash[*package_name_array.zip(raw_versions).flatten]
end
end
diff --git a/lib/chef/provider/registry_key.rb b/lib/chef/provider/registry_key.rb
index 5dcb9f1959..359d171748 100644
--- a/lib/chef/provider/registry_key.rb
+++ b/lib/chef/provider/registry_key.rb
@@ -75,39 +75,39 @@ class Chef
def define_resource_requirements
requirements.assert(:create, :create_if_missing, :delete, :delete_key) do |a|
- a.assertion { registry.hive_exists?(new_resource.key) }
+ a.assertion do registry.hive_exists?(new_resource.key) end
a.failure_message(Chef::Exceptions::Win32RegHiveMissing, "Hive #{new_resource.key.split('\\').shift} does not exist")
end
requirements.assert(:create) do |a|
- a.assertion { registry.key_exists?(new_resource.key) }
+ a.assertion do registry.key_exists?(new_resource.key) end
a.whyrun("Key #{new_resource.key} does not exist. Unless it would have been created before, attempt to modify its values would fail.")
end
requirements.assert(:create, :create_if_missing) do |a|
# If keys missing in the path and recursive == false
- a.assertion { !registry.keys_missing?(current_resource.key) || new_resource.recursive }
+ a.assertion do !registry.keys_missing?(current_resource.key) || new_resource.recursive end
a.failure_message(Chef::Exceptions::Win32RegNoRecursive, "Intermediate keys missing but recursive is set to false")
a.whyrun("Intermediate keys in #{new_resource.key} do not exist. Unless they would have been created earlier, attempt to modify them would fail.")
end
requirements.assert(:delete_key) do |a|
# If key to be deleted has subkeys but recurssive == false
- a.assertion { !registry.key_exists?(new_resource.key) || !registry.has_subkeys?(new_resource.key) || new_resource.recursive }
+ a.assertion do !registry.key_exists?(new_resource.key) || !registry.has_subkeys?(new_resource.key) || new_resource.recursive end
a.failure_message(Chef::Exceptions::Win32RegNoRecursive, "#{new_resource.key} has subkeys but recursive is set to false.")
a.whyrun("#{current_resource.key} has subkeys, but recursive is set to false. attempt to delete would fails unless subkeys were deleted prior to this action.")
end
requirements.assert(:create, :create_if_missing) do |a|
# If type key missing in the RegistryKey values hash
- a.assertion { !key_missing?(new_resource.values, :type) }
+ a.assertion do !key_missing?(new_resource.values, :type) end
a.failure_message(Chef::Exceptions::RegKeyValuesTypeMissing, "Missing type key in RegistryKey values hash")
a.whyrun("Type key does not exist. Attempt would fail unless the complete values hash containing all the keys does not exist for registry_key resource's create action.")
end
requirements.assert(:create, :create_if_missing) do |a|
# If data key missing in the RegistryKey values hash
- a.assertion { !key_missing?(new_resource.values, :data) }
+ a.assertion do !key_missing?(new_resource.values, :data) end
a.failure_message(Chef::Exceptions::RegKeyValuesDataMissing, "Missing data key in RegistryKey values hash")
a.whyrun("Data key does not exist. Attempt would fail unless the complete values hash containing all the keys does not exist for registry_key resource's create action.")
end
diff --git a/lib/chef/provider/remote_file/http.rb b/lib/chef/provider/remote_file/http.rb
index 86c7b84858..d94c84fa20 100644
--- a/lib/chef/provider/remote_file/http.rb
+++ b/lib/chef/provider/remote_file/http.rb
@@ -65,9 +65,9 @@ class Chef
http = Chef::HTTP::Simple.new(uri, http_client_opts)
orig_tempfile = Chef::FileContentManagement::Tempfile.new(@new_resource).tempfile
if want_progress?
- tempfile = http.streaming_request_with_progress(uri, headers, orig_tempfile) do |size, total|
+ tempfile = http.streaming_request_with_progress(uri, headers, orig_tempfile) { |size, total|
events.resource_update_progress(new_resource, size, total, progress_interval)
- end
+ }
else
tempfile = http.streaming_request(uri, headers, orig_tempfile)
end
diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb
index af96e08b20..0d83d725dd 100644
--- a/lib/chef/provider/service.rb
+++ b/lib/chef/provider/service.rb
@@ -58,7 +58,7 @@ class Chef
# subclasses should override this if they do implement user services
def user_services_requirements
requirements.assert(:all_actions) do |a|
- a.assertion { new_resource.user.nil? }
+ a.assertion do new_resource.user.nil? end
a.failure_message Chef::Exceptions::UnsupportedAction, "#{self} does not support user services"
end
end
@@ -69,7 +69,7 @@ class Chef
def define_resource_requirements
requirements.assert(:reload) do |a|
- a.assertion { supports[:reload] || new_resource.reload_command }
+ a.assertion do supports[:reload] || new_resource.reload_command end
a.failure_message Chef::Exceptions::UnsupportedAction, "#{self} does not support :reload"
# if a service is not declared to support reload, that won't
# typically change during the course of a run - so no whyrun
diff --git a/lib/chef/provider/service/aix.rb b/lib/chef/provider/service/aix.rb
index 77e3b69d35..6e787bd99c 100644
--- a/lib/chef/provider/service/aix.rb
+++ b/lib/chef/provider/service/aix.rb
@@ -75,7 +75,7 @@ class Chef
def shared_resource_requirements
super
requirements.assert(:all_actions) do |a|
- a.assertion { @status_load_success }
+ a.assertion do @status_load_success end
a.whyrun ["Service status not available. Assuming a prior action would have installed the service.", "Assuming status of not running."]
end
end
diff --git a/lib/chef/provider/service/aixinit.rb b/lib/chef/provider/service/aixinit.rb
index 05cdc2befe..9875aa1e07 100644
--- a/lib/chef/provider/service/aixinit.rb
+++ b/lib/chef/provider/service/aixinit.rb
@@ -57,7 +57,7 @@ class Chef
end
def enable_service
- Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each { |f| ::File.delete(f) }
+ Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each do |f| ::File.delete(f) end
if @new_resource.priority.is_a? Integer
create_symlink(2, "S", @new_resource.priority)
@@ -72,7 +72,7 @@ class Chef
end
def disable_service
- Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each { |f| ::File.delete(f) }
+ Dir.glob(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).each do |f| ::File.delete(f) end
if @new_resource.priority.is_a? Integer
create_symlink(2, "K", 100 - @new_resource.priority)
diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb
index 9f48504d5e..2039151d99 100644
--- a/lib/chef/provider/service/debian.rb
+++ b/lib/chef/provider/service/debian.rb
@@ -45,14 +45,14 @@ class Chef
shared_resource_requirements
requirements.assert(:all_actions) do |a|
update_rcd = "/usr/sbin/update-rc.d"
- a.assertion { ::File.exists? update_rcd }
+ a.assertion do ::File.exists? update_rcd end
a.failure_message Chef::Exceptions::Service, "#{update_rcd} does not exist!"
# no whyrun recovery - this is a base system component of debian
# distros and must be present
end
requirements.assert(:all_actions) do |a|
- a.assertion { @got_priority == true }
+ a.assertion do @got_priority == true end
a.failure_message Chef::Exceptions::Service, "Unable to determine priority for service"
# This can happen if the service is not yet installed,so we'll fake it.
a.whyrun ["Unable to determine priority of service, assuming service would have been correctly installed earlier in the run.",
diff --git a/lib/chef/provider/service/freebsd.rb b/lib/chef/provider/service/freebsd.rb
index 7733831945..98e539ae98 100644
--- a/lib/chef/provider/service/freebsd.rb
+++ b/lib/chef/provider/service/freebsd.rb
@@ -60,20 +60,20 @@ class Chef
shared_resource_requirements
requirements.assert(:start, :enable, :reload, :restart) do |a|
- a.assertion { init_command }
+ a.assertion do init_command end
a.failure_message Chef::Exceptions::Service, "#{new_resource}: unable to locate the rc.d script"
a.whyrun("Assuming rc.d script will be installed by a previous action.")
end
requirements.assert(:all_actions) do |a|
- a.assertion { enabled_state_found }
+ a.assertion do enabled_state_found end
# for consistentcy with original behavior, this will not fail in non-whyrun mode;
# rather it will silently set enabled state=>false
a.whyrun "Unable to determine enabled/disabled state, assuming this will be correct for an actual run. Assuming disabled."
end
requirements.assert(:start, :enable, :reload, :restart) do |a|
- a.assertion { !service_enable_variable_name.nil? }
+ a.assertion do !service_enable_variable_name.nil? end
a.failure_message Chef::Exceptions::Service, "Could not find the service name in #{init_command} and rcvar"
# No recovery in whyrun mode - the init file is present but not correct.
end
@@ -179,7 +179,7 @@ class Chef
def set_service_enable(value)
lines = read_rc_conf
# Remove line that set the old value
- lines.delete_if { |line| line =~ /^\#?\s*#{Regexp.escape(service_enable_variable_name)}=/ }
+ lines.delete_if do |line| line =~ /^\#?\s*#{Regexp.escape(service_enable_variable_name)}=/ end
# And append the line that sets the new value at the end
lines << "#{service_enable_variable_name}=\"#{value}\""
write_rc_conf(lines)
diff --git a/lib/chef/provider/service/gentoo.rb b/lib/chef/provider/service/gentoo.rb
index 88616c4947..da0fc8fed2 100644
--- a/lib/chef/provider/service/gentoo.rb
+++ b/lib/chef/provider/service/gentoo.rb
@@ -32,13 +32,13 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
super
@current_resource.enabled(
- Dir.glob("/etc/runlevels/**/#{Chef::Util::PathHelper.escape_glob_dir(@current_resource.service_name)}").any? do |file|
+ Dir.glob("/etc/runlevels/**/#{Chef::Util::PathHelper.escape_glob_dir(@current_resource.service_name)}").any? { |file|
@found_script = true
exists = ::File.exists? file
readable = ::File.readable? file
logger.trace "#{@new_resource} exists: #{exists}, readable: #{readable}"
exists && readable
- end
+ }
)
logger.trace "#{@new_resource} enabled: #{@current_resource.enabled}"
@@ -47,14 +47,14 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
def define_resource_requirements
requirements.assert(:all_actions) do |a|
- a.assertion { ::File.exists?("/sbin/rc-update") }
+ a.assertion do ::File.exists?("/sbin/rc-update") end
a.failure_message Chef::Exceptions::Service, "/sbin/rc-update does not exist"
# no whyrun recovery -t his is a core component whose presence is
# unlikely to be affected by what we do in the course of a chef run
end
requirements.assert(:all_actions) do |a|
- a.assertion { @found_script }
+ a.assertion do @found_script end
# No failure, just informational output from whyrun
a.whyrun "Could not find service #{@new_resource.service_name} under any runlevel"
end
diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb
index 746581df73..38165bd06c 100644
--- a/lib/chef/provider/service/macosx.rb
+++ b/lib/chef/provider/service/macosx.rb
@@ -36,7 +36,7 @@ class Chef
/Library/LaunchDaemons
/System/Library/LaunchAgents
/System/Library/LaunchDaemons }
- Chef::Util::PathHelper.home("Library", "LaunchAgents") { |p| locations << p }
+ Chef::Util::PathHelper.home("Library", "LaunchAgents") do |p| locations << p end
locations
end
@@ -79,24 +79,24 @@ class Chef
end
requirements.assert(:all_actions) do |a|
- a.assertion { @plist_size < 2 }
+ a.assertion do @plist_size < 2 end
a.failure_message Chef::Exceptions::Service, "Several plist files match service name. Please use full service name."
end
requirements.assert(:all_actions) do |a|
- a.assertion { ::File.exists?(@plist.to_s) }
+ a.assertion do ::File.exists?(@plist.to_s) end
a.failure_message Chef::Exceptions::Service,
"Could not find plist for #{@new_resource}"
end
requirements.assert(:enable, :disable) do |a|
- a.assertion { !@service_label.to_s.empty? }
+ a.assertion do !@service_label.to_s.empty? end
a.failure_message Chef::Exceptions::Service,
"Could not find service's label in plist file '#{@plist}'!"
end
requirements.assert(:all_actions) do |a|
- a.assertion { @plist_size > 0 }
+ a.assertion do @plist_size > 0 end
# No failure here in original code - so we also will not
# fail. Instead warn that the service is potentially missing
a.whyrun "Assuming that the service would have been previously installed and is currently disabled." do
@@ -235,13 +235,13 @@ class Chef
end
def find_service_plist
- plists = PLIST_DIRS.inject([]) do |results, dir|
+ plists = PLIST_DIRS.inject([]) { |results, dir|
edir = ::File.expand_path(dir)
entries = Dir.glob(
"#{edir}/*#{Chef::Util::PathHelper.escape_glob_dir(@current_resource.service_name)}*.plist"
)
entries.any? ? results << entries : results
- end
+ }
plists.flatten!
@plist_size = plists.size
plists.first
diff --git a/lib/chef/provider/service/openbsd.rb b/lib/chef/provider/service/openbsd.rb
index c368815418..47f0a7989e 100644
--- a/lib/chef/provider/service/openbsd.rb
+++ b/lib/chef/provider/service/openbsd.rb
@@ -59,19 +59,19 @@ class Chef
shared_resource_requirements
requirements.assert(:start, :enable, :reload, :restart) do |a|
- a.assertion { init_command }
+ a.assertion do init_command end
a.failure_message Chef::Exceptions::Service, "#{new_resource}: unable to locate the rc.d script"
end
requirements.assert(:all_actions) do |a|
- a.assertion { enabled_state_found }
+ a.assertion do enabled_state_found end
# for consistency with original behavior, this will not fail in non-whyrun mode;
# rather it will silently set enabled state=>false
a.whyrun "Unable to determine enabled/disabled state, assuming this will be correct for an actual run. Assuming disabled."
end
requirements.assert(:start, :enable, :reload, :restart) do |a|
- a.assertion { init_command && !builtin_service_enable_variable_name.nil? }
+ a.assertion do init_command && !builtin_service_enable_variable_name.nil? end
a.failure_message Chef::Exceptions::Service, "Could not find the service name in #{init_command} and rcvar"
# No recovery in whyrun mode - the init file is present but not correct.
end
diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb
index 8751090d44..e25e53fbfb 100644
--- a/lib/chef/provider/service/redhat.rb
+++ b/lib/chef/provider/service/redhat.rb
@@ -56,12 +56,12 @@ class Chef
requirements.assert(:all_actions) do |a|
chkconfig_file = "/sbin/chkconfig"
- a.assertion { ::File.exists? chkconfig_file }
+ a.assertion do ::File.exists? chkconfig_file end
a.failure_message Chef::Exceptions::Service, "#{chkconfig_file} does not exist!"
end
requirements.assert(:enable) do |a|
- a.assertion { !@service_missing }
+ a.assertion do !@service_missing end
a.failure_message Chef::Exceptions::Service, "#{new_resource}: Service is not known to chkconfig."
a.whyrun "Assuming service would be enabled. The init script is not presently installed."
end
diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb
index 754437b4a0..a76c656764 100644
--- a/lib/chef/provider/service/simple.rb
+++ b/lib/chef/provider/service/simple.rb
@@ -43,7 +43,7 @@ class Chef
def shared_resource_requirements
super
requirements.assert(:all_actions) do |a|
- a.assertion { @status_load_success }
+ a.assertion do @status_load_success end
a.whyrun ["Service status not available. Assuming a prior action would have installed the service.", "Assuming status of not running."]
end
end
@@ -52,21 +52,21 @@ class Chef
# FIXME? need reload from service.rb
shared_resource_requirements
requirements.assert(:start) do |a|
- a.assertion { @new_resource.start_command }
+ a.assertion do @new_resource.start_command end
a.failure_message Chef::Exceptions::Service, "#{self} requires that start_command be set"
end
requirements.assert(:stop) do |a|
- a.assertion { @new_resource.stop_command }
+ a.assertion do @new_resource.stop_command end
a.failure_message Chef::Exceptions::Service, "#{self} requires that stop_command be set"
end
requirements.assert(:restart) do |a|
- a.assertion { @new_resource.restart_command || ( @new_resource.start_command && @new_resource.stop_command ) }
+ a.assertion do @new_resource.restart_command || ( @new_resource.start_command && @new_resource.stop_command ) end
a.failure_message Chef::Exceptions::Service, "#{self} requires a restart_command or both start_command and stop_command be set in order to perform a restart"
end
requirements.assert(:reload) do |a|
- a.assertion { @new_resource.reload_command }
+ a.assertion do @new_resource.reload_command end
a.failure_message Chef::Exceptions::UnsupportedAction, "#{self} requires a reload_command be set in order to perform a reload"
end
@@ -78,7 +78,7 @@ class Chef
a.failure_message Chef::Exceptions::Service, "#{@new_resource} could not determine how to inspect the process table, please set this node's 'command.ps' attribute"
end
requirements.assert(:all_actions) do |a|
- a.assertion { !@ps_command_failed }
+ a.assertion do !@ps_command_failed end
a.failure_message Chef::Exceptions::Service, "Command #{ps_cmd} failed to execute, cannot determine service current status"
end
end
diff --git a/lib/chef/provider/service/systemd.rb b/lib/chef/provider/service/systemd.rb
index 565668c081..abcb7eab53 100644
--- a/lib/chef/provider/service/systemd.rb
+++ b/lib/chef/provider/service/systemd.rb
@@ -67,7 +67,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
def define_resource_requirements
shared_resource_requirements
requirements.assert(:all_actions) do |a|
- a.assertion { status_check_success }
+ a.assertion do status_check_success end
# We won't stop in any case, but in whyrun warn and tell what we're doing.
a.whyrun ["Failed to determine status of #{new_resource}, using command #{new_resource.status_command}.",
"Assuming service would have been installed and is disabled"]
diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb
index 8b2db84f35..983389f807 100644
--- a/lib/chef/provider/service/upstart.rb
+++ b/lib/chef/provider/service/upstart.rb
@@ -90,13 +90,13 @@ class Chef
"Could not determine upstart state for service"
end
end
- a.assertion { @command_success }
+ a.assertion do @command_success end
# no failure here, just document the assumptions made.
a.whyrun "#{whyrun_msg} Assuming service installed and not running."
end
requirements.assert(:all_actions) do |a|
- a.assertion { @config_file_found }
+ a.assertion do @config_file_found end
# no failure here, just document the assumptions made.
a.whyrun "Could not find #{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}. Assuming service is disabled."
end
diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb
index dd3ece4786..7e929c45dc 100644
--- a/lib/chef/provider/subversion.rb
+++ b/lib/chef/provider/subversion.rb
@@ -48,7 +48,7 @@ class Chef
# Make sure the parent dir exists, or else fail.
# for why run, print a message explaining the potential error.
parent_directory = ::File.dirname(new_resource.destination)
- a.assertion { ::File.directory?(parent_directory) }
+ a.assertion do ::File.directory?(parent_directory) end
a.failure_message(Chef::Exceptions::MissingParentDirectory,
"Cannot clone #{new_resource} to #{new_resource.destination}, the enclosing directory #{parent_directory} does not exist")
a.whyrun("Directory #{parent_directory} does not exist, assuming it would have been created")
@@ -166,13 +166,13 @@ class Chef
end
def extract_revision_info(svn_info)
- repo_attrs = svn_info.lines.inject({}) do |attrs, line|
+ repo_attrs = svn_info.lines.inject({}) { |attrs, line|
if line =~ SVN_INFO_PATTERN
property, value = $1, $2
attrs[property] = value
end
attrs
- end
+ }
rev = (repo_attrs["Last Changed Rev"] || repo_attrs["Revision"])
rev.strip! if rev
raise "Could not parse `svn info` data: #{svn_info}" if repo_attrs.empty?
diff --git a/lib/chef/provider/systemd_unit.rb b/lib/chef/provider/systemd_unit.rb
index 81a56d959a..1e4fdab46e 100644
--- a/lib/chef/provider/systemd_unit.rb
+++ b/lib/chef/provider/systemd_unit.rb
@@ -51,7 +51,7 @@ class Chef
super
requirements.assert(:create) do |a|
- a.assertion { IniParse.parse(new_resource.to_ini) }
+ a.assertion do IniParse.parse(new_resource.to_ini) end
a.failure_message "Unit content is not valid INI text"
end
end
diff --git a/lib/chef/provider/template.rb b/lib/chef/provider/template.rb
index f506462268..9b527d7413 100644
--- a/lib/chef/provider/template.rb
+++ b/lib/chef/provider/template.rb
@@ -39,7 +39,7 @@ class Chef
super
requirements.assert(:create, :create_if_missing) do |a|
- a.assertion { ::File.exists?(content.template_location) }
+ a.assertion do ::File.exists?(content.template_location) end
a.failure_message "Template source #{content.template_location} could not be found."
a.whyrun "Template source #{content.template_location} does not exist. Assuming it would have been created."
a.block_action!
diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb
index 38fe233d76..44cfbb000e 100644
--- a/lib/chef/provider/user.rb
+++ b/lib/chef/provider/user.rb
@@ -84,18 +84,18 @@ class Chef
def define_resource_requirements
requirements.assert(:create, :modify, :manage, :lock, :unlock) do |a|
- a.assertion { @group_name_resolved }
+ a.assertion do @group_name_resolved end
a.failure_message Chef::Exceptions::User, "Couldn't lookup integer GID for group name #{new_resource.gid}"
a.whyrun "group name #{new_resource.gid} does not exist. This will cause group assignment to fail. Assuming this group will have been created previously."
end
requirements.assert(:all_actions) do |a|
- a.assertion { @shadow_lib_ok }
+ a.assertion do @shadow_lib_ok end
a.failure_message Chef::Exceptions::MissingLibrary, "You must have ruby-shadow installed for password support!"
a.whyrun "ruby-shadow is not installed. Attempts to set user password will cause failure. Assuming that this gem will have been previously installed." \
"Note that user update converge may report false-positive on the basis of mismatched password. "
end
requirements.assert(:modify, :lock, :unlock) do |a|
- a.assertion { @user_exists }
+ a.assertion do @user_exists end
a.failure_message(Chef::Exceptions::User, "Cannot modify user #{new_resource.username} - does not exist!")
a.whyrun("Assuming user #{new_resource.username} would have been created")
end
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index b8f85618da..4bed747bd3 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -61,12 +61,12 @@ class Chef
super
requirements.assert(:all_actions) do |a|
- a.assertion { ::File.exist?("/usr/bin/dscl") }
+ a.assertion do ::File.exist?("/usr/bin/dscl") end
a.failure_message(Chef::Exceptions::User, "Cannot find binary '/usr/bin/dscl' on the system for #{new_resource}!")
end
requirements.assert(:all_actions) do |a|
- a.assertion { ::File.exist?("/usr/bin/plutil") }
+ a.assertion do ::File.exist?("/usr/bin/plutil") end
a.failure_message(Chef::Exceptions::User, "Cannot find binary '/usr/bin/plutil' on the system for #{new_resource}!")
end
diff --git a/lib/chef/provider/windows_env.rb b/lib/chef/provider/windows_env.rb
index 3fd4b18cfa..35c010be20 100644
--- a/lib/chef/provider/windows_env.rb
+++ b/lib/chef/provider/windows_env.rb
@@ -107,9 +107,9 @@ class Chef
return true # do not delete the key
else
new_value =
- current_values.select do |item|
+ current_values.select { |item|
not new_values.include?(item)
- end.join(new_resource.delim)
+ }.join(new_resource.delim)
if new_value.empty?
return false # nothing left here, delete the key
diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb
index b94b6b875c..feba79a711 100644
--- a/lib/chef/provider/windows_task.rb
+++ b/lib/chef/provider/windows_task.rb
@@ -308,13 +308,13 @@ class Chef
def frequency_modifier_contains_last_week?(frequency_modifier)
frequency_modifier = frequency_modifier.to_s.split(",")
- frequency_modifier.map! { |value| value.strip.upcase }
+ frequency_modifier.map! do |value| value.strip.upcase end
frequency_modifier.include?("LAST")
end
def day_includes_last_or_lastday?(day)
day = day.to_s.split(",")
- day.map! { |value| value.strip.upcase }
+ day.map! do |value| value.strip.upcase end
day.include?("LAST") || day.include?("LASTDAY")
end
@@ -435,7 +435,7 @@ class Chef
weeks_of_month = []
if new_resource.frequency_modifier
weeks = new_resource.frequency_modifier.split(",")
- weeks.map! { |week| week.to_s.strip.upcase }
+ weeks.map! do |week| week.to_s.strip.upcase end
weeks.delete("LAST") if weeks.include?("LAST")
weeks_of_month = get_binary_values_from_constants(weeks, WEEKS_OF_MONTH)
end
@@ -447,7 +447,7 @@ class Chef
days_of_month = []
if new_resource.day
days = new_resource.day.to_s.split(",")
- days.map! { |day| day.to_s.strip.upcase }
+ days.map! do |day| day.to_s.strip.upcase end
days.delete("LAST") if days.include?("LAST")
days.delete("LASTDAY") if days.include?("LASTDAY")
if days - (1..31).to_a
@@ -467,7 +467,7 @@ class Chef
# this line of code is just to support backward compatibility of wild card *
new_resource.day = "mon, tue, wed, thu, fri, sat, sun" if new_resource.day == "*" && new_resource.frequency == :weekly
days = new_resource.day.to_s.split(",")
- days.map! { |day| day.to_s.strip.upcase }
+ days.map! do |day| day.to_s.strip.upcase end
weeks_days = get_binary_values_from_constants(days, DAYS_OF_WEEK)
else
# following condition will make the frequency :weekly idempotent if start_day is not provided by user setting day as the current_resource day
@@ -490,7 +490,7 @@ class Chef
# this line of code is just to support backward compatibility of wild card *
new_resource.months = "jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec" if new_resource.months == "*" && new_resource.frequency == :monthly
months = new_resource.months.split(",")
- months.map! { |month| month.to_s.strip.upcase }
+ months.map! do |month| month.to_s.strip.upcase end
months_of_year = get_binary_values_from_constants(months, MONTHS)
else
MONTHS.each do |key, value|
diff --git a/lib/chef/provider/zypper_repository.rb b/lib/chef/provider/zypper_repository.rb
index 764979cb3a..0985be11f9 100644
--- a/lib/chef/provider/zypper_repository.rb
+++ b/lib/chef/provider/zypper_repository.rb
@@ -158,7 +158,7 @@ class Chef
declare_resource(:execute, "import gpg key from #{new_resource.gpgkey}") do
command "/bin/rpm --import #{cached_keyfile}"
- not_if { key_installed?(cached_keyfile) }
+ not_if do key_installed?(cached_keyfile) end
action :run
end
end
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 7f0895d6c9..b43c31ad3c 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -666,9 +666,9 @@ class Chef
def inspect
ivars = instance_variables.map(&:to_sym) - FORBIDDEN_IVARS
- ivars.inject("<#{self}") do |str, ivar|
+ ivars.inject("<#{self}") { |str, ivar|
str << " #{ivar}: #{instance_variable_get(ivar).inspect}"
- end << ">"
+ } << ">"
end
# as_json does most of the to_json heavy lifted. It exists here in case activesupport
diff --git a/lib/chef/resource/apt_preference.rb b/lib/chef/resource/apt_preference.rb
index 810a8dcad8..1980eedc6a 100644
--- a/lib/chef/resource/apt_preference.rb
+++ b/lib/chef/resource/apt_preference.rb
@@ -23,7 +23,7 @@ class Chef
# @since 13.3
class AptPreference < Chef::Resource
resource_name :apt_preference
- provides(:apt_preference) { true }
+ provides(:apt_preference) do true end
description "The apt_preference resource allows for the creation of APT preference files. Preference files are used to control which package versions and sources are prioritized during installation."
introduced "13.3"
diff --git a/lib/chef/resource/apt_repository.rb b/lib/chef/resource/apt_repository.rb
index dff8139647..845aaaca41 100644
--- a/lib/chef/resource/apt_repository.rb
+++ b/lib/chef/resource/apt_repository.rb
@@ -22,7 +22,7 @@ class Chef
class Resource
class AptRepository < Chef::Resource
resource_name :apt_repository
- provides(:apt_repository) { true }
+ provides(:apt_repository) do true end
description "Use the apt_repository resource to specify additional APT repositories. Adding a new repository will update the APT package cache immediately."
introduced "12.9"
diff --git a/lib/chef/resource/apt_update.rb b/lib/chef/resource/apt_update.rb
index e11d35664f..d4c2f0d799 100644
--- a/lib/chef/resource/apt_update.rb
+++ b/lib/chef/resource/apt_update.rb
@@ -22,7 +22,7 @@ class Chef
class Resource
class AptUpdate < Chef::Resource
resource_name :apt_update
- provides(:apt_update) { true }
+ provides(:apt_update) do true end
description "Use the apt_update resource to manage APT repository updates on Debian and Ubuntu platforms."
introduced "12.7"
diff --git a/lib/chef/resource/build_essential.rb b/lib/chef/resource/build_essential.rb
index b38ec6b24a..9b3e54bc11 100644
--- a/lib/chef/resource/build_essential.rb
+++ b/lib/chef/resource/build_essential.rb
@@ -20,7 +20,7 @@ class Chef
class Resource
class BuildEssential < Chef::Resource
resource_name :build_essential
- provides(:build_essential) { true }
+ provides(:build_essential) do true end
description "Use the build_essential resource to install packages required for compiling C software from source."
introduced "14.0"
diff --git a/lib/chef/resource/chef_handler.rb b/lib/chef/resource/chef_handler.rb
index 2fa5173401..3585f3e302 100644
--- a/lib/chef/resource/chef_handler.rb
+++ b/lib/chef/resource/chef_handler.rb
@@ -22,7 +22,7 @@ class Chef
class Resource
class ChefHandler < Chef::Resource
resource_name :chef_handler
- provides(:chef_handler) { true }
+ provides(:chef_handler) do true end
description "Use the chef_handler resource to install or uninstall reporting/exception handlers."
introduced "14.0"
diff --git a/lib/chef/resource/dmg_package.rb b/lib/chef/resource/dmg_package.rb
index 403716cad7..d5516671e3 100644
--- a/lib/chef/resource/dmg_package.rb
+++ b/lib/chef/resource/dmg_package.rb
@@ -21,7 +21,7 @@ class Chef
class Resource
class DmgPackage < Chef::Resource
resource_name :dmg_package
- provides(:dmg_package) { true }
+ provides(:dmg_package) do true end
description "Use the dmg_package resource to install a dmg 'package'. The resource will retrieve the dmg file from a remote URL, mount it using OS X's hdidutil, copy the application (.app directory) to the specified destination (/Applications), and detach the image using hdiutil. The dmg file will be stored in the Chef::Config[:file_cache_path]."
introduced "14.0"
diff --git a/lib/chef/resource/dsc_resource.rb b/lib/chef/resource/dsc_resource.rb
index fe47d7fd1a..a5bad94100 100644
--- a/lib/chef/resource/dsc_resource.rb
+++ b/lib/chef/resource/dsc_resource.rb
@@ -34,14 +34,14 @@ class Chef
# to dump the actual ivars
class ToTextHash < Hash
def to_text
- descriptions = map do |(property, obj)|
+ descriptions = map { |(property, obj)|
obj_text = if obj.respond_to?(:to_text)
obj.to_text
else
obj.inspect
end
"#{property}=>#{obj_text}"
- end
+ }
"{#{descriptions.join(", ")}}"
end
end
diff --git a/lib/chef/resource/homebrew_cask.rb b/lib/chef/resource/homebrew_cask.rb
index 70e1d7c6bb..db224dbf15 100644
--- a/lib/chef/resource/homebrew_cask.rb
+++ b/lib/chef/resource/homebrew_cask.rb
@@ -24,7 +24,7 @@ class Chef
class Resource
class HomebrewCask < Chef::Resource
resource_name :homebrew_cask
- provides(:homebrew_cask) { true }
+ provides(:homebrew_cask) do true end
description "Use the homebrew_cask resource to install binaries distributed via the Homebrew package manager."
introduced "14.0"
diff --git a/lib/chef/resource/homebrew_tap.rb b/lib/chef/resource/homebrew_tap.rb
index 23738d6e51..f373e626da 100644
--- a/lib/chef/resource/homebrew_tap.rb
+++ b/lib/chef/resource/homebrew_tap.rb
@@ -24,7 +24,7 @@ class Chef
class Resource
class HomebrewTap < Chef::Resource
resource_name :homebrew_tap
- provides(:homebrew_tap) { true }
+ provides(:homebrew_tap) do true end
description "Use the homebrew_tap resource to add additional formula repositories to the Homebrew package manager."
introduced "14.0"
diff --git a/lib/chef/resource/hostname.rb b/lib/chef/resource/hostname.rb
index dab599c272..a141e56d2d 100644
--- a/lib/chef/resource/hostname.rb
+++ b/lib/chef/resource/hostname.rb
@@ -49,7 +49,7 @@ class Chef
action_class do
def append_replacing_matching_lines(path, regex, string)
text = IO.read(path).split("\n")
- text.reject! { |s| s =~ regex }
+ text.reject! do |s| s =~ regex end
text += [ string ]
file path do
content text.join("\n") + "\n"
@@ -91,7 +91,7 @@ class Chef
# set the hostname via /bin/hostname
declare_resource(:execute, "set hostname to #{new_resource.hostname}") do
command "/bin/hostname #{new_resource.hostname}"
- not_if { shell_out!("hostname").stdout.chomp == new_resource.hostname }
+ not_if do shell_out!("hostname").stdout.chomp == new_resource.hostname end
notifies :reload, "ohai[reload hostname]"
end
@@ -111,18 +111,18 @@ class Chef
# darwin
declare_resource(:execute, "set HostName via scutil") do
command "/usr/sbin/scutil --set HostName #{new_resource.hostname}"
- not_if { shell_out!("/usr/sbin/scutil --get HostName").stdout.chomp == new_resource.hostname }
+ not_if do shell_out!("/usr/sbin/scutil --get HostName").stdout.chomp == new_resource.hostname end
notifies :reload, "ohai[reload hostname]"
end
declare_resource(:execute, "set ComputerName via scutil") do
command "/usr/sbin/scutil --set ComputerName #{new_resource.hostname}"
- not_if { shell_out!("/usr/sbin/scutil --get ComputerName").stdout.chomp == new_resource.hostname }
+ not_if do shell_out!("/usr/sbin/scutil --get ComputerName").stdout.chomp == new_resource.hostname end
notifies :reload, "ohai[reload hostname]"
end
shortname = new_resource.hostname[/[^\.]*/]
declare_resource(:execute, "set LocalHostName via scutil") do
command "/usr/sbin/scutil --set LocalHostName #{shortname}"
- not_if { shell_out!("/usr/sbin/scutil --get LocalHostName").stdout.chomp == shortname }
+ not_if do shell_out!("/usr/sbin/scutil --get LocalHostName").stdout.chomp == shortname end
notifies :reload, "ohai[reload hostname]"
end
when node["os"] == "linux"
diff --git a/lib/chef/resource/locale.rb b/lib/chef/resource/locale.rb
index 8edb278e48..a29fae018a 100644
--- a/lib/chef/resource/locale.rb
+++ b/lib/chef/resource/locale.rb
@@ -81,13 +81,13 @@ class Chef
#
def define_resource_requirements
requirements.assert(:all_actions) do |a|
- a.assertion { LOCALE_PLATFORM_FAMILIES.include?(node[:platform_family]) }
+ a.assertion do LOCALE_PLATFORM_FAMILIES.include?(node[:platform_family]) end
a.failure_message(Chef::Exceptions::ProviderNotFound, "The locale resource is not supported on platform family: #{node[:platform_family]}")
end
requirements.assert(:all_actions) do |a|
# RHEL/CentOS type platforms don't have locale-gen
- a.assertion { shell_out("locale-gen") }
+ a.assertion do shell_out("locale-gen") end
a.failure_message(Chef::Exceptions::ProviderNotFound, "The locale resource requires the locale-gen tool")
end
end
diff --git a/lib/chef/resource/macos_userdefaults.rb b/lib/chef/resource/macos_userdefaults.rb
index 02d65baee4..c55c39b1d8 100644
--- a/lib/chef/resource/macos_userdefaults.rb
+++ b/lib/chef/resource/macos_userdefaults.rb
@@ -22,8 +22,8 @@ class Chef
class MacosUserDefaults < Chef::Resource
# align with apple's marketing department
resource_name :macos_userdefaults
- provides(:mac_os_x_userdefaults) { true }
- provides(:macos_userdefaults) { true }
+ provides(:mac_os_x_userdefaults) do true end
+ provides(:macos_userdefaults) do true end
description "Use the macos_userdefaults resource to manage the macOS user defaults system. The properties of this resource are passed to the defaults command, and the parameters follow the convention of that command. See the defaults(1) man page for details on how the tool works."
introduced "14.0"
diff --git a/lib/chef/resource/ohai_hint.rb b/lib/chef/resource/ohai_hint.rb
index 30d7a3bd0c..227ea46ace 100644
--- a/lib/chef/resource/ohai_hint.rb
+++ b/lib/chef/resource/ohai_hint.rb
@@ -21,7 +21,7 @@ class Chef
class Resource
class OhaiHint < Chef::Resource
resource_name :ohai_hint
- provides(:ohai_hint) { true }
+ provides(:ohai_hint) do true end
description "Use the ohai_hint resource to aid in configuration detection by passing hint data to Ohai."
introduced "14.0"
diff --git a/lib/chef/resource/openssl_dhparam.rb b/lib/chef/resource/openssl_dhparam.rb
index 254a840a48..a9fe069bb8 100644
--- a/lib/chef/resource/openssl_dhparam.rb
+++ b/lib/chef/resource/openssl_dhparam.rb
@@ -24,7 +24,7 @@ class Chef
include Chef::Mixin::OpenSSLHelper
resource_name :openssl_dhparam
- provides(:openssl_dhparam) { true }
+ provides(:openssl_dhparam) do true end
description "Use the openssl_dhparam resource to generate dhparam.pem files. If a valid dhparam.pem file is found at the specified location, no new file will be created. If a file is found at the specified location but it is not a valid dhparam file, it will be overwritten."
introduced "14.0"
diff --git a/lib/chef/resource/openssl_rsa_private_key.rb b/lib/chef/resource/openssl_rsa_private_key.rb
index 38ffa2c394..1170a56a71 100644
--- a/lib/chef/resource/openssl_rsa_private_key.rb
+++ b/lib/chef/resource/openssl_rsa_private_key.rb
@@ -24,8 +24,8 @@ class Chef
include Chef::Mixin::OpenSSLHelper
resource_name :openssl_rsa_private_key
- provides(:openssl_rsa_private_key) { true }
- provides(:openssl_rsa_key) { true } # legacy cookbook resource name
+ provides(:openssl_rsa_private_key) do true end
+ provides(:openssl_rsa_key) do true end # legacy cookbook resource name
description "Use the openssl_rsa_private_key resource to generate RSA private key files. If a valid RSA key file can be opened at the specified location, no new file will be created. If the RSA key file cannot be opened, either because it does not exist or because the password to the RSA key file does not match the password in the recipe, it will be overwritten."
introduced "14.0"
diff --git a/lib/chef/resource/openssl_rsa_public_key.rb b/lib/chef/resource/openssl_rsa_public_key.rb
index c7c125fb9e..f3c47794cd 100644
--- a/lib/chef/resource/openssl_rsa_public_key.rb
+++ b/lib/chef/resource/openssl_rsa_public_key.rb
@@ -24,7 +24,7 @@ class Chef
include Chef::Mixin::OpenSSLHelper
resource_name :openssl_rsa_public_key
- provides(:openssl_rsa_public_key) { true }
+ provides(:openssl_rsa_public_key) do true end
description "Use the openssl_rsa_public_key resource to generate RSA public key files for a given RSA private key."
introduced "14.0"
diff --git a/lib/chef/resource/openssl_x509_certificate.rb b/lib/chef/resource/openssl_x509_certificate.rb
index 20cf998239..edb045ae52 100644
--- a/lib/chef/resource/openssl_x509_certificate.rb
+++ b/lib/chef/resource/openssl_x509_certificate.rb
@@ -25,7 +25,7 @@ class Chef
include Chef::Mixin::OpenSSLHelper
resource_name :openssl_x509_certificate
- provides(:openssl_x509) { true } # legacy cookbook name.
+ provides(:openssl_x509) do true end # legacy cookbook name.
description "Use the openssl_x509_certificate resource to generate signed or self-signed, PEM-formatted x509 certificates. If no existing key is specified, the resource will automatically generate a passwordless key with the certificate. If a CA private key and certificate are provided, the certificate will be signed with them. Note: This resource was renamed from openssl_x509 to openssl_x509_certificate. The legacy name will continue to function, but cookbook code should be updated for the new resource name."
introduced "14.4"
diff --git a/lib/chef/resource/registry_key.rb b/lib/chef/resource/registry_key.rb
index a5c99313bf..552fbd05bb 100644
--- a/lib/chef/resource/registry_key.rb
+++ b/lib/chef/resource/registry_key.rb
@@ -23,7 +23,7 @@ class Chef
class Resource
class RegistryKey < Chef::Resource
resource_name :registry_key
- provides(:registry_key) { true }
+ provides(:registry_key) do true end
description "Use the registry_key resource to create and delete registry keys in Microsoft Windows."
introduced "11.0"
diff --git a/lib/chef/resource/rhsm_errata.rb b/lib/chef/resource/rhsm_errata.rb
index 7442bf99f2..9b637f197c 100644
--- a/lib/chef/resource/rhsm_errata.rb
+++ b/lib/chef/resource/rhsm_errata.rb
@@ -21,7 +21,7 @@ class Chef
class Resource
class RhsmErrata < Chef::Resource
resource_name :rhsm_errata
- provides(:rhsm_errata) { true }
+ provides(:rhsm_errata) do true end
description "Use the rhsm_errata resource to install packages associated with a given Red"\
" Hat Subscription Manager Errata ID. This is helpful if packages"\
diff --git a/lib/chef/resource/rhsm_errata_level.rb b/lib/chef/resource/rhsm_errata_level.rb
index 2bb0006a38..e95f669e8e 100644
--- a/lib/chef/resource/rhsm_errata_level.rb
+++ b/lib/chef/resource/rhsm_errata_level.rb
@@ -21,7 +21,7 @@ class Chef
class Resource
class RhsmErrataLevel < Chef::Resource
resource_name :rhsm_errata_level
- provides(:rhsm_errata_level) { true }
+ provides(:rhsm_errata_level) do true end
description "Use the rhsm_errata_level resource to install all packages of a specified errata level from the Red Hat Subscription Manager. For example, you can ensure that all packages associated with errata marked at a 'Critical' security level are installed."
introduced "14.0"
diff --git a/lib/chef/resource/rhsm_register.rb b/lib/chef/resource/rhsm_register.rb
index cfaa55124c..f3b9776bb2 100644
--- a/lib/chef/resource/rhsm_register.rb
+++ b/lib/chef/resource/rhsm_register.rb
@@ -22,7 +22,7 @@ class Chef
class Resource
class RhsmRegister < Chef::Resource
resource_name :rhsm_register
- provides(:rhsm_register) { true }
+ provides(:rhsm_register) do true end
description "Use the rhsm_register resource to register a node with the Red Hat Subscription Manager"\
" or a local Red Hat Satellite server."
@@ -105,7 +105,7 @@ class Chef
command "subscription-manager unregister"
default_env true
action :run
- only_if { registered_with_rhsm? }
+ only_if do registered_with_rhsm? end
notifies :run, "execute[Clean RHSM Config]", :immediately
end
diff --git a/lib/chef/resource/rhsm_repo.rb b/lib/chef/resource/rhsm_repo.rb
index feb2aa0802..5e4068a7a7 100644
--- a/lib/chef/resource/rhsm_repo.rb
+++ b/lib/chef/resource/rhsm_repo.rb
@@ -21,7 +21,7 @@ class Chef
class Resource
class RhsmRepo < Chef::Resource
resource_name :rhsm_repo
- provides(:rhsm_repo) { true }
+ provides(:rhsm_repo) do true end
description "Use the rhsm_repo resource to enable or disable Red Hat Subscription Manager"\
" repositories that are made available via attached subscriptions."
diff --git a/lib/chef/resource/rhsm_subscription.rb b/lib/chef/resource/rhsm_subscription.rb
index 7bbf53f07d..d5a16adfe7 100644
--- a/lib/chef/resource/rhsm_subscription.rb
+++ b/lib/chef/resource/rhsm_subscription.rb
@@ -21,7 +21,7 @@ class Chef
class Resource
class RhsmSubscription < Chef::Resource
resource_name :rhsm_subscription
- provides(:rhsm_subscription) { true }
+ provides(:rhsm_subscription) do true end
description "Use the rhsm_subscription resource to add or remove Red Hat Subscription Manager"\
" subscriptions from your host. This can be used when a host's activation_key"\
diff --git a/lib/chef/resource/sudo.rb b/lib/chef/resource/sudo.rb
index eb89687411..e1fbcd18b2 100644
--- a/lib/chef/resource/sudo.rb
+++ b/lib/chef/resource/sudo.rb
@@ -25,7 +25,7 @@ class Chef
class Resource
class Sudo < Chef::Resource
resource_name :sudo
- provides(:sudo) { true }
+ provides(:sudo) do true end
description "Use the sudo resource to add or remove individual sudo entries using sudoers.d files."\
" Sudo version 1.7.2 or newer is required to use the sudo resource, as it relies on the"\
@@ -148,10 +148,10 @@ class Chef
validate_properties
if docker? # don't even put this into resource collection unless we're in docker
- declare_resource(:package, "sudo") do
+ declare_resource(:package, "sudo") {
action :nothing
not_if "which sudo"
- end.run_action(:install)
+ }.run_action(:install)
end
target = "#{new_resource.config_prefix}/sudoers.d/"
diff --git a/lib/chef/resource/swap_file.rb b/lib/chef/resource/swap_file.rb
index 2efe040c47..6c2fde50df 100644
--- a/lib/chef/resource/swap_file.rb
+++ b/lib/chef/resource/swap_file.rb
@@ -21,7 +21,7 @@ class Chef
class Resource
class SwapFile < Chef::Resource
resource_name :swap_file
- provides(:swap_file) { true }
+ provides(:swap_file) do true end
description "Use the swap_file resource to create or delete swap files on Linux systems, and optionally to manage the swappiness configuration for a host."
introduced "14.0"
diff --git a/lib/chef/resource/sysctl.rb b/lib/chef/resource/sysctl.rb
index a6c316c5bc..81faad0210 100644
--- a/lib/chef/resource/sysctl.rb
+++ b/lib/chef/resource/sysctl.rb
@@ -21,8 +21,8 @@ class Chef
class Resource
class Sysctl < Chef::Resource
resource_name :sysctl
- provides(:sysctl) { true }
- provides(:sysctl_param) { true }
+ provides(:sysctl) do true end
+ provides(:sysctl_param) do true end
description "Use the sysctl resource to set or remove kernel parameters using the sysctl"\
" command line tool and configuration files in the system's sysctl.d directory. "\
diff --git a/lib/chef/resource/systemd_unit.rb b/lib/chef/resource/systemd_unit.rb
index 973fdf9491..4ee8d2e5cd 100644
--- a/lib/chef/resource/systemd_unit.rb
+++ b/lib/chef/resource/systemd_unit.rb
@@ -23,7 +23,7 @@ require "iniparse"
class Chef
class Resource
class SystemdUnit < Chef::Resource
- resource_name(:systemd_unit) { true }
+ resource_name(:systemd_unit) do true end
description "Use the systemd_unit resource to create, manage, and run systemd units."
introduced "12.11"
@@ -67,7 +67,7 @@ class Chef
def to_ini
case content
when Hash
- IniParse.gen do |doc|
+ IniParse.gen { |doc|
content.each_pair do |sect, opts|
doc.section(sect) do |section|
opts.each_pair do |opt, val|
@@ -77,7 +77,7 @@ class Chef
end
end
end
- end.to_s
+ }.to_s
else
content.to_s
end
diff --git a/lib/chef/resource/timezone.rb b/lib/chef/resource/timezone.rb
index 16a7f1031e..e8227853d3 100644
--- a/lib/chef/resource/timezone.rb
+++ b/lib/chef/resource/timezone.rb
@@ -68,7 +68,7 @@ class Chef
execute "tzdata-update" do
command "/usr/sbin/tzdata-update"
action :nothing
- only_if { ::File.executable?("/usr/sbin/tzdata-update") }
+ only_if do ::File.executable?("/usr/sbin/tzdata-update") end
subscribes :run, "file[/etc/sysconfig/clock]", :immediately
end
diff --git a/lib/chef/resource/windows_auto_run.rb b/lib/chef/resource/windows_auto_run.rb
index c0d0910e5f..c5b4164068 100644
--- a/lib/chef/resource/windows_auto_run.rb
+++ b/lib/chef/resource/windows_auto_run.rb
@@ -22,7 +22,7 @@ class Chef
class Resource
class WindowsAutorun < Chef::Resource
resource_name :windows_auto_run
- provides(:windows_auto_run) { true }
+ provides(:windows_auto_run) do true end
description "Use the windows_auto_run resource to set applications to run at login."
introduced "14.0"
diff --git a/lib/chef/resource/windows_feature.rb b/lib/chef/resource/windows_feature.rb
index cc80284019..6b5c3fe68b 100644
--- a/lib/chef/resource/windows_feature.rb
+++ b/lib/chef/resource/windows_feature.rb
@@ -22,7 +22,7 @@ class Chef
class Resource
class WindowsFeature < Chef::Resource
resource_name :windows_feature
- provides(:windows_feature) { true }
+ provides(:windows_feature) do true end
description "Use the windows_feature resource to add, remove or entirely delete Windows features and roles. This resource calls the 'windows_feature_dism' or 'windows_feature_powershell' resources depending on the specified installation method and defaults to dism, which is available on both Workstation and Server editions of Windows."
introduced "14.0"
diff --git a/lib/chef/resource/windows_feature_dism.rb b/lib/chef/resource/windows_feature_dism.rb
index faeb0b0762..0d365dae2b 100644
--- a/lib/chef/resource/windows_feature_dism.rb
+++ b/lib/chef/resource/windows_feature_dism.rb
@@ -23,7 +23,7 @@ class Chef
class Resource
class WindowsFeatureDism < Chef::Resource
resource_name :windows_feature_dism
- provides(:windows_feature_dism) { true }
+ provides(:windows_feature_dism) do true end
description "Use the windows_feature_dism resource to add, remove, or entirely delete Windows features and roles using DISM."
introduced "14.0"
diff --git a/lib/chef/resource/windows_feature_powershell.rb b/lib/chef/resource/windows_feature_powershell.rb
index 5cdbe1f74c..15ae4183ad 100644
--- a/lib/chef/resource/windows_feature_powershell.rb
+++ b/lib/chef/resource/windows_feature_powershell.rb
@@ -25,7 +25,7 @@ class Chef
class Resource
class WindowsFeaturePowershell < Chef::Resource
resource_name :windows_feature_powershell
- provides(:windows_feature_powershell) { true }
+ provides(:windows_feature_powershell) do true end
description "Use the windows_feature_powershell resource to add, remove, or entirely delete Windows features and roles using PowerShell. This resource offers significant speed benefits over the windows_feature_dism resource, but requires installing the Remote Server Administration Tools on non-server releases of Windows."
introduced "14.0"
diff --git a/lib/chef/resource/windows_font.rb b/lib/chef/resource/windows_font.rb
index 64644a815f..5a976644e0 100644
--- a/lib/chef/resource/windows_font.rb
+++ b/lib/chef/resource/windows_font.rb
@@ -23,7 +23,7 @@ class Chef
require_relative "../util/path_helper"
resource_name :windows_font
- provides(:windows_font) { true }
+ provides(:windows_font) do true end
description "Use the windows_font resource to install font files on Windows. By default, the font is sourced from the cookbook using the resource, but a URI source can be specified as well."
introduced "14.0"
@@ -53,17 +53,17 @@ class Chef
def retrieve_cookbook_font
font_file = new_resource.font_name
if new_resource.source
- declare_resource(:remote_file, font_file) do
+ declare_resource(:remote_file, font_file) {
action :nothing
source source_uri
path Chef::Util::PathHelper.join(ENV["TEMP"], font_file)
- end.run_action(:create)
+ }.run_action(:create)
else
- declare_resource(:cookbook_file, font_file) do
+ declare_resource(:cookbook_file, font_file) {
action :nothing
cookbook cookbook_name.to_s unless cookbook_name.nil?
path Chef::Util::PathHelper.join(ENV["TEMP"], font_file)
- end.run_action(:create)
+ }.run_action(:create)
end
end
diff --git a/lib/chef/resource/windows_package.rb b/lib/chef/resource/windows_package.rb
index 5592e537b4..ec49510b1d 100644
--- a/lib/chef/resource/windows_package.rb
+++ b/lib/chef/resource/windows_package.rb
@@ -27,7 +27,7 @@ class Chef
include Chef::Mixin::Uris
resource_name :windows_package
- provides(:windows_package) { true }
+ provides(:windows_package) do true end
provides :package, os: "windows"
description "Use the windows_package resource to manage Microsoft Installer Package (MSI) packages for the Microsoft Windows platform."
diff --git a/lib/chef/resource/windows_pagefile.rb b/lib/chef/resource/windows_pagefile.rb
index 03a7511f47..5a69e21eff 100644
--- a/lib/chef/resource/windows_pagefile.rb
+++ b/lib/chef/resource/windows_pagefile.rb
@@ -21,7 +21,7 @@ class Chef
class Resource
class WindowsPagefile < Chef::Resource
resource_name :windows_pagefile
- provides(:windows_pagefile) { true }
+ provides(:windows_pagefile) do true end
description "Use the windows_pagefile resource to configure pagefile settings on Windows."
introduced "14.0"
diff --git a/lib/chef/resource/windows_path.rb b/lib/chef/resource/windows_path.rb
index 0067de5baf..f649f9a1e1 100644
--- a/lib/chef/resource/windows_path.rb
+++ b/lib/chef/resource/windows_path.rb
@@ -22,7 +22,7 @@ class Chef
class Resource
class WindowsPath < Chef::Resource
resource_name :windows_path
- provides(:windows_path) { true }
+ provides(:windows_path) do true end
description "Use the windows_path resource to manage the path environment variable on Microsoft Windows."
introduced "13.4"
diff --git a/lib/chef/resource/windows_printer.rb b/lib/chef/resource/windows_printer.rb
index d782c1b360..cd301d07d7 100644
--- a/lib/chef/resource/windows_printer.rb
+++ b/lib/chef/resource/windows_printer.rb
@@ -25,7 +25,7 @@ class Chef
require "resolv"
resource_name :windows_printer
- provides(:windows_printer) { true }
+ provides(:windows_printer) do true end
description "Use the windows_printer resource to setup Windows printers. Note that this doesn't currently install a printer driver. You must already have the driver installed on the system."
introduced "14.0"
diff --git a/lib/chef/resource/windows_printer_port.rb b/lib/chef/resource/windows_printer_port.rb
index cd1a5f55c2..28d81fbbd7 100644
--- a/lib/chef/resource/windows_printer_port.rb
+++ b/lib/chef/resource/windows_printer_port.rb
@@ -25,7 +25,7 @@ class Chef
require "resolv"
resource_name :windows_printer_port
- provides(:windows_printer_port) { true }
+ provides(:windows_printer_port) do true end
description "Use the windows_printer_port resource to create and delete TCP/IPv4 printer ports on Windows."
introduced "14.0"
diff --git a/lib/chef/resource/windows_service.rb b/lib/chef/resource/windows_service.rb
index b8ee4edf9c..3832fe4b7c 100644
--- a/lib/chef/resource/windows_service.rb
+++ b/lib/chef/resource/windows_service.rb
@@ -33,7 +33,7 @@ class Chef
# Until #1773 is resolved, you need to manually specify the windows_service resource
# to use action :configure_startup and properties startup_type
- provides(:windows_service) { true }
+ provides(:windows_service) do true end
provides :service, os: "windows"
description "Use the windows_service resource to create, delete, or manage a service on the Microsoft Windows platform."
diff --git a/lib/chef/resource/windows_shortcut.rb b/lib/chef/resource/windows_shortcut.rb
index 0c6dc63e6e..1fbeb428ea 100644
--- a/lib/chef/resource/windows_shortcut.rb
+++ b/lib/chef/resource/windows_shortcut.rb
@@ -22,7 +22,7 @@ class Chef
class Resource
class WindowsShortcut < Chef::Resource
resource_name :windows_shortcut
- provides(:windows_shortcut) { true }
+ provides(:windows_shortcut) do true end
description "Use the windows_shortcut resource to create shortcut files on Windows."
introduced "14.0"
diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb
index 95de6b37c2..920d3e300f 100644
--- a/lib/chef/resource/windows_task.rb
+++ b/lib/chef/resource/windows_task.rb
@@ -23,7 +23,7 @@ class Chef
class Resource
class WindowsTask < Chef::Resource
resource_name :windows_task
- provides(:windows_task) { true }
+ provides(:windows_task) do true end
description "Use the windows_task resource to create, delete or run a Windows scheduled task. Requires Windows Server 2008 or later due to API usage."
introduced "13.0"
@@ -196,7 +196,7 @@ class Chef
# returns true if frequency_modifer has values First, second, third, fourth, last, lastday
def frequency_modifier_includes_days_of_weeks?(frequency_modifier)
frequency_modifier = frequency_modifier.to_s.split(",")
- frequency_modifier.map! { |value| value.strip.upcase }
+ frequency_modifier.map! do |value| value.strip.upcase end
(frequency_modifier - VALID_WEEKS).empty?
end
@@ -300,7 +300,7 @@ class Chef
# Following error will be raise if day is set as 1-31 and frequency is selected as :weekly since those values are valid with only frequency :monthly
raise ArgumentError, "day values 1-31 or last is only valid with frequency :monthly" if frequency == :weekly
else
- days.map! { |day| day.to_s.strip.downcase }
+ days.map! do |day| day.to_s.strip.downcase end
unless (days - VALID_WEEK_DAYS).empty?
raise ArgumentError, "day property invalid. Only valid values are: #{VALID_WEEK_DAYS.map(&:upcase).join(", ")}. Multiple values must be separated by a comma."
end
@@ -313,7 +313,7 @@ class Chef
if months.is_a?(String)
months = months.split(",")
- months.map! { |month| month.strip.upcase }
+ months.map! do |month| month.strip.upcase end
unless (months - VALID_MONTHS).empty?
raise ArgumentError, "months property invalid. Only valid values are: #{VALID_MONTHS.join(", ")}. Multiple values must be separated by a comma."
end
@@ -322,7 +322,7 @@ class Chef
# This method returns true if day has values from 1-31 which is a days of moths and used with frequency :monthly
def days_includes_days_of_months?(days)
- days.map! { |day| day.to_s.strip.downcase }
+ days.map! do |day| day.to_s.strip.downcase end
(days - VALID_DAYS_OF_MONTH).empty?
end
diff --git a/lib/chef/resource/yum_repository.rb b/lib/chef/resource/yum_repository.rb
index 05639842af..de6e51cc7c 100644
--- a/lib/chef/resource/yum_repository.rb
+++ b/lib/chef/resource/yum_repository.rb
@@ -22,7 +22,7 @@ class Chef
class Resource
class YumRepository < Chef::Resource
resource_name :yum_repository
- provides(:yum_repository) { true }
+ provides(:yum_repository) do true end
description "Use the yum_repository resource to manage a Yum repository configuration"\
" file located at /etc/yum.repos.d/repositoryid.repo on the local machine."\
diff --git a/lib/chef/resource/zypper_repository.rb b/lib/chef/resource/zypper_repository.rb
index 447660e9ac..8c35065b58 100644
--- a/lib/chef/resource/zypper_repository.rb
+++ b/lib/chef/resource/zypper_repository.rb
@@ -22,8 +22,8 @@ class Chef
class Resource
class ZypperRepository < Chef::Resource
resource_name :zypper_repository
- provides(:zypper_repository) { true }
- provides(:zypper_repo) { true }
+ provides(:zypper_repository) do true end
+ provides(:zypper_repo) do true end
description "Use the zypper_repository resource to create Zypper package repositories on SUSE Enterprise Linux and openSUSE systems. This resource maintains full compatibility with the zypper_repository resource in the existing zypper cookbook."
introduced "13.3"
diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb
index bbb4fa2e83..1979448b13 100644
--- a/lib/chef/resource_reporter.rb
+++ b/lib/chef/resource_reporter.rb
@@ -193,9 +193,9 @@ class Chef
def prepare_run_data
run_data = {}
run_data["action"] = "end"
- run_data["resources"] = updated_resources.map do |action_record|
+ run_data["resources"] = updated_resources.map { |action_record|
for_json(action_record)
- end
+ }
run_data["status"] = @status
run_data["run_list"] = Chef::JSONCompat.to_json(@run_status.node.run_list)
run_data["total_res_count"] = total_res_count.to_s
diff --git a/lib/chef/run_list.rb b/lib/chef/run_list.rb
index 1108b5d2c1..f2949579c3 100644
--- a/lib/chef/run_list.rb
+++ b/lib/chef/run_list.rb
@@ -77,7 +77,7 @@ class Chef
other_run_list_items = other.dup
- other_run_list_items.map! { |item| coerce_to_run_list_item(item) }
+ other_run_list_items.map! do |item| coerce_to_run_list_item(item) end
other_run_list_items == @run_list_items
end
end
@@ -133,7 +133,7 @@ class Chef
end
def remove(item)
- @run_list_items.delete_if { |i| i == item }
+ @run_list_items.delete_if do |i| i == item end
self
end
alias :delete :remove
diff --git a/lib/chef/run_list/versioned_recipe_list.rb b/lib/chef/run_list/versioned_recipe_list.rb
index 6083dae953..cf222bf710 100644
--- a/lib/chef/run_list/versioned_recipe_list.rb
+++ b/lib/chef/run_list/versioned_recipe_list.rb
@@ -89,7 +89,7 @@ class Chef
#
# @return [Array] Array of strings with fully-qualified and unexpanded recipe names
def with_duplicate_names
- map do |recipe_name|
+ map { |recipe_name|
if recipe_name.end_with?("::default")
[ recipe_name.sub(/::default$/, ""), recipe_name ]
elsif recipe_name.include?("::")
@@ -97,7 +97,7 @@ class Chef
else
[ recipe_name, "#{recipe_name}::default" ]
end
- end.flatten
+ }.flatten
end
end
end
diff --git a/lib/chef/runner.rb b/lib/chef/runner.rb
index a0ae61fe4c..d31f3ca0f1 100644
--- a/lib/chef/runner.rb
+++ b/lib/chef/runner.rb
@@ -94,7 +94,7 @@ class Chef
# Execute each resource.
run_context.resource_collection.execute_each_resource do |resource|
begin
- Array(resource.action).each { |action| run_action(resource, action) }
+ Array(resource.action).each do |action| run_action(resource, action) end
ensure
resource.executed_by_runner = true
end
diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb
index 5a9c1f6d41..a97e2cb799 100644
--- a/lib/chef/search/query.rb
+++ b/lib/chef/search/query.rb
@@ -78,7 +78,7 @@ class Chef
response = call_rest_service(type, query: query, **args_h)
if block
- response["rows"].each { |row| yield(row) if row }
+ response["rows"].each do |row| yield(row) if row end
#
# args_h[:rows] and args_h[:start] are the page size and
# start position requested of the search index backing the
diff --git a/lib/chef/shell/ext.rb b/lib/chef/shell/ext.rb
index 843126b4f2..c1210e52a6 100644
--- a/lib/chef/shell/ext.rb
+++ b/lib/chef/shell/ext.rb
@@ -329,13 +329,13 @@ module Shell
filename += object.id
end
- edited_data = Tempfile.open([filename, ".js"]) do |tempfile|
+ edited_data = Tempfile.open([filename, ".js"]) { |tempfile|
tempfile.sync = true
tempfile.puts Chef::JSONCompat.to_json(object)
system("#{Shell.editor} #{tempfile.path}")
tempfile.rewind
tempfile.read
- end
+ }
Chef::JSONCompat.from_json(edited_data)
end
diff --git a/lib/chef/util/backup.rb b/lib/chef/util/backup.rb
index 08da52e3b2..5c2201a8f4 100644
--- a/lib/chef/util/backup.rb
+++ b/lib/chef/util/backup.rb
@@ -81,9 +81,9 @@ class Chef
def unsorted_backup_files
# If you replace this with Dir[], you will probably break Windows.
fn = Regexp.escape(::File.basename(path))
- Dir.entries(::File.dirname(backup_path)).select do |f|
+ Dir.entries(::File.dirname(backup_path)).select { |f|
!!(f =~ /\A#{fn}.chef-[0-9.]*\B/)
- end.map { |f| ::File.join(::File.dirname(backup_path), f) }
+ }.map { |f| ::File.join(::File.dirname(backup_path), f) }
end
def sorted_backup_files
diff --git a/lib/chef/util/dsc/resource_store.rb b/lib/chef/util/dsc/resource_store.rb
index d064a397c3..723695f3de 100644
--- a/lib/chef/util/dsc/resource_store.rb
+++ b/lib/chef/util/dsc/resource_store.rb
@@ -52,9 +52,9 @@ class Chef
private
def add_resource(new_r)
- count = resources.count do |r|
+ count = resources.count { |r|
r["ResourceType"].casecmp(new_r["ResourceType"]) == 0
- end
+ }
if count == 0
resources << new_r
end
@@ -71,14 +71,14 @@ class Chef
end
def find_resources(name, module_name, rs)
- found = rs.find_all do |r|
+ found = rs.find_all { |r|
name_matches = r["Name"].casecmp(name) == 0
if name_matches
module_name.nil? || (r["Module"] && r["Module"]["Name"].casecmp(module_name) == 0)
else
false
end
- end
+ }
end
# Returns a list of dsc resources
diff --git a/lib/chef/util/powershell/cmdlet.rb b/lib/chef/util/powershell/cmdlet.rb
index 75cf489e9e..21eea7ca2f 100644
--- a/lib/chef/util/powershell/cmdlet.rb
+++ b/lib/chef/util/powershell/cmdlet.rb
@@ -115,7 +115,7 @@ class Chef
end
def command_switches_string(switches)
- command_switches = switches.map do |switch_name, switch_value|
+ command_switches = switches.map { |switch_name, switch_value|
if switch_name.class != Symbol
raise ArgumentError, "Invalid type `#{switch_name} `for PowerShell switch '#{switch_name}'. The switch must be specified as a Symbol'"
end
@@ -140,7 +140,7 @@ class Chef
end
switch_present ? ["-#{switch_name.to_s.downcase}", switch_argument].join(" ").strip : ""
- end
+ }
command_switches.join(" ")
end
diff --git a/lib/chef/util/threaded_job_queue.rb b/lib/chef/util/threaded_job_queue.rb
index 6b13bf99a3..ed3cbe4788 100644
--- a/lib/chef/util/threaded_job_queue.rb
+++ b/lib/chef/util/threaded_job_queue.rb
@@ -45,15 +45,15 @@ class Chef
end
def process(concurrency = 10)
- workers = (1..concurrency).map do
+ workers = (1..concurrency).map {
Thread.new do
loop do
fn = @queue.pop
fn.arity == 1 ? fn.call(@lock) : fn.call
end
end
- end
- workers.each { |worker| self << Thread.method(:exit) }
+ }
+ workers.each do |worker| self << Thread.method(:exit) end
workers.each(&:join)
end
end
diff --git a/lib/chef/win32/registry.rb b/lib/chef/win32/registry.rb
index 90bc35143a..1efcd19021 100644
--- a/lib/chef/win32/registry.rb
+++ b/lib/chef/win32/registry.rb
@@ -55,9 +55,9 @@ class Chef
def get_values(key_path)
hive, key = get_hive_and_key(key_path)
key_exists!(key_path)
- values = hive.open(key, ::Win32::Registry::KEY_READ | registry_system_architecture) do |reg|
+ values = hive.open(key, ::Win32::Registry::KEY_READ | registry_system_architecture) { |reg|
reg.map { |name, type, data| { name: name, type: get_name_from_type(type), data: data } }
- end
+ }
end
def set_value(key_path, value)
diff --git a/lib/chef/win32/security/acl.rb b/lib/chef/win32/security/acl.rb
index ec963fb522..957cc6738b 100644
--- a/lib/chef/win32/security/acl.rb
+++ b/lib/chef/win32/security/acl.rb
@@ -37,7 +37,7 @@ class Chef
aces_size = aces.inject(0) { |sum, ace| sum + ace.size }
acl_size = align_dword(Chef::ReservedNames::Win32::API::Security::ACLStruct.size + aces_size) # What the heck is 94???
acl = Chef::ReservedNames::Win32::Security.initialize_acl(acl_size)
- aces.each { |ace| Chef::ReservedNames::Win32::Security.add_ace(acl, ace) }
+ aces.each do |ace| Chef::ReservedNames::Win32::Security.add_ace(acl, ace) end
acl
end
diff --git a/lib/chef/win32/security/sid.rb b/lib/chef/win32/security/sid.rb
index 9643a80c67..73bb35d2fd 100644
--- a/lib/chef/win32/security/sid.rb
+++ b/lib/chef/win32/security/sid.rb
@@ -248,16 +248,16 @@ class Chef
SERVICE_ACCOUNT_USERS = [self.LocalSystem,
self.NtLocal,
- self.NtNetwork].flat_map do |user_type|
+ self.NtNetwork].flat_map { |user_type|
[user_type.account_simple_name.upcase,
user_type.account_name.upcase]
- end.freeze
+ }.freeze
BUILT_IN_GROUPS = [self.BuiltinAdministrators,
- self.BuiltinUsers, self.Guests].flat_map do |user_type|
+ self.BuiltinUsers, self.Guests].flat_map { |user_type|
[user_type.account_simple_name.upcase,
user_type.account_name.upcase]
- end.freeze
+ }.freeze
SYSTEM_USER = SERVICE_ACCOUNT_USERS + BUILT_IN_GROUPS