summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-08-17 12:15:26 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-08-17 13:25:02 -0700
commita0c32511bc6634538374ca4b433032b8acd05f96 (patch)
tree15c7cfbd0d773488ab814e7c24f0c58505c9134b /lib/chef
parent3d0379a2ad531a0b3db5ed2827bf30ef07b26100 (diff)
downloadchef-a0c32511bc6634538374ca4b433032b8acd05f96.tar.gz
fix Style/BlockDelimiters, Style/MultilineBlockLayout and 0.42.0 engine upgrade
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/application/client.rb8
-rw-r--r--lib/chef/application/solo.rb4
-rw-r--r--lib/chef/chef_fs/data_handler/data_handler_base.rb4
-rw-r--r--lib/chef/cookbook/synchronizer.rb4
-rw-r--r--lib/chef/cookbook_version.rb4
-rw-r--r--lib/chef/http.rb2
-rw-r--r--lib/chef/http/socketless_chef_zero_client.rb4
-rw-r--r--lib/chef/knife.rb4
-rw-r--r--lib/chef/knife/client_delete.rb4
-rw-r--r--lib/chef/knife/core/gem_glob_loader.rb4
-rw-r--r--lib/chef/knife/status.rb4
-rw-r--r--lib/chef/mixin/command/unix.rb4
-rw-r--r--lib/chef/mixin/powershell_type_coercions.rb2
-rw-r--r--lib/chef/mixin/securable.rb4
-rw-r--r--lib/chef/monkey_patches/webrick-utils.rb4
-rw-r--r--lib/chef/node/attribute.rb4
-rw-r--r--lib/chef/property.rb4
-rw-r--r--lib/chef/provider/dsc_script.rb8
-rw-r--r--lib/chef/provider/osx_profile.rb16
-rw-r--r--lib/chef/provider/package/yum/yum_cache.rb2
-rw-r--r--lib/chef/provider/remote_file/ftp.rb4
-rw-r--r--lib/chef/provider/remote_file/sftp.rb4
-rw-r--r--lib/chef/provider/service/debian.rb4
-rw-r--r--lib/chef/provider/service/simple.rb5
-rw-r--r--lib/chef/resource.rb14
-rw-r--r--lib/chef/resource_builder.rb2
-rw-r--r--lib/chef/search/query.rb4
27 files changed, 62 insertions, 69 deletions
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 71bb300971..cbaa494b71 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -204,9 +204,9 @@ class Chef::Application::Client < Chef::Application
:description => "Replace current run list with specified items for a single run",
:proc => lambda {|items|
items = items.split(",")
- items.compact.map {|item|
+ items.compact.map do |item|
Chef::RunList::RunListItem.new(item)
- }
+ end
}
option :runlist,
@@ -215,9 +215,9 @@ class Chef::Application::Client < Chef::Application
:description => "Permanently replace current run list with specified items",
:proc => lambda {|items|
items = items.split(",")
- items.compact.map {|item|
+ items.compact.map do |item|
Chef::RunList::RunListItem.new(item)
- }
+ end
}
option :why_run,
:short => "-W",
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 8bf381a975..446a0f007d 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -168,9 +168,9 @@ class Chef::Application::Solo < Chef::Application
:description => "Replace current run list with specified items",
:proc => lambda {|items|
items = items.split(",")
- items.compact.map {|item|
+ items.compact.map do |item|
Chef::RunList::RunListItem.new(item)
- }
+ end
}
option :client_fork,
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 b34aff4b98..3668f77dd5 100644
--- a/lib/chef/chef_fs/data_handler/data_handler_base.rb
+++ b/lib/chef/chef_fs/data_handler/data_handler_base.rb
@@ -93,7 +93,7 @@ class Chef
# name to recipe[name]. Then calls uniq on the result.
#
def normalize_run_list(run_list)
- run_list.map {|item|
+ run_list.map do |item|
case item.to_s
when /^recipe\[.*\]$/
item # explicit recipe
@@ -102,7 +102,7 @@ class Chef
else
"recipe[#{item}]"
end
- }.uniq
+ end.uniq
end
#
diff --git a/lib/chef/cookbook/synchronizer.rb b/lib/chef/cookbook/synchronizer.rb
index 01f6155bf3..bb44bc3d5c 100644
--- a/lib/chef/cookbook/synchronizer.rb
+++ b/lib/chef/cookbook/synchronizer.rb
@@ -152,11 +152,11 @@ class Chef
queue << lambda do |lock|
full_file_path = sync_file(file)
- lock.synchronize {
+ lock.synchronize do
# Save the full_path of the downloaded file to be restored in the manifest later
save_full_file_path(file, full_file_path)
mark_file_synced(file)
- }
+ end
end
end
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index bf9e755f3f..8de9cb26dd 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -316,13 +316,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 { |path|
+ pretty_existing_files = existing_files.map do |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?
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index 0def3378be..94885b11c2 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -248,8 +248,6 @@ class Chef
end
end
- private
-
def build_http_client(base_url)
if chef_zero_uri?(base_url)
# PERFORMANCE CRITICAL: *MUST* lazy require here otherwise we load up webrick
diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb
index 1acac5e758..d2f1f45b1d 100644
--- a/lib/chef/http/socketless_chef_zero_client.rb
+++ b/lib/chef/http/socketless_chef_zero_client.rb
@@ -197,9 +197,9 @@ class Chef
private
def headers_extracted_from_options
- options.reject { |name, _| KNOWN_OPTIONS.include?(name) }.map { |name, value|
+ options.reject { |name, _| KNOWN_OPTIONS.include?(name) }.map do |name, value|
[name.to_s.split("_").map { |segment| segment.capitalize }.join("-"), value]
- }
+ end
end
end
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index 356bf47fd4..dde6fd74a6 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -233,8 +233,6 @@ class Chef
end
end
- private
-
OFFICIAL_PLUGINS = %w{ec2 rackspace windows openstack terremark bluebox}
def self.path_from_caller(caller_line)
@@ -286,8 +284,6 @@ class Chef
reset_config_path!
- public
-
# Create a new instance of the current class configured for the given
# arguments and options
def initialize(argv = [])
diff --git a/lib/chef/knife/client_delete.rb b/lib/chef/knife/client_delete.rb
index e1b2365361..08cdf6c7dd 100644
--- a/lib/chef/knife/client_delete.rb
+++ b/lib/chef/knife/client_delete.rb
@@ -43,7 +43,7 @@ class Chef
exit 1
end
- delete_object(Chef::ApiClientV1, @client_name, "client") {
+ delete_object(Chef::ApiClientV1, @client_name, "client") do
object = Chef::ApiClientV1.load(@client_name)
if object.validator
unless config[:delete_validators]
@@ -52,7 +52,7 @@ class Chef
end
end
object.destroy
- }
+ end
end
end
diff --git a/lib/chef/knife/core/gem_glob_loader.rb b/lib/chef/knife/core/gem_glob_loader.rb
index bb129a652d..34c5c53d75 100644
--- a/lib/chef/knife/core/gem_glob_loader.rb
+++ b/lib/chef/knife/core/gem_glob_loader.rb
@@ -81,9 +81,9 @@ class Chef
files = []
if check_load_path
- files = $LOAD_PATH.map { |load_path|
+ files = $LOAD_PATH.map do |load_path|
Dir["#{File.expand_path glob, Chef::Util::PathHelper.escape_glob_dir(load_path)}#{Gem.suffix_pattern}"]
- }.flatten.select { |file| File.file? file.untaint }
+ end.flatten.select { |file| File.file? file.untaint }
end
gem_files = latest_gem_specs.map do |spec|
diff --git a/lib/chef/knife/status.rb b/lib/chef/knife/status.rb
index 551d5addfc..0e3cd7e7d6 100644
--- a/lib/chef/knife/status.rb
+++ b/lib/chef/knife/status.rb
@@ -96,13 +96,13 @@ class Chef
all_nodes << node
end
- output(all_nodes.sort { |n1, n2|
+ output(all_nodes.sort do |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/mixin/command/unix.rb b/lib/chef/mixin/command/unix.rb
index bfd507979f..aa541c3637 100644
--- a/lib/chef/mixin/command/unix.rb
+++ b/lib/chef/mixin/command/unix.rb
@@ -64,7 +64,7 @@ class Chef
$VERBOSE = nil
ps.last.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
- cid = fork {
+ cid = fork do
pw.last.close
STDIN.reopen pw.first
pw.first.close
@@ -111,7 +111,7 @@ class Chef
end
ps.last.close unless ps.last.closed?
exit!
- }
+ end
ensure
$VERBOSE = verbose
end
diff --git a/lib/chef/mixin/powershell_type_coercions.rb b/lib/chef/mixin/powershell_type_coercions.rb
index 381cbed637..6159c87948 100644
--- a/lib/chef/mixin/powershell_type_coercions.rb
+++ b/lib/chef/mixin/powershell_type_coercions.rb
@@ -63,7 +63,7 @@ class Chef
end
def unsafe?(s)
- ["'", '#', "`", '"'].any? do |x|
+ ["'", "#", "`", '"'].any? do |x|
s.include? x
end
end
diff --git a/lib/chef/mixin/securable.rb b/lib/chef/mixin/securable.rb
index a88d534b37..55b4e0a6d1 100644
--- a/lib/chef/mixin/securable.rb
+++ b/lib/chef/mixin/securable.rb
@@ -43,7 +43,7 @@ class Chef
:mode,
arg,
:callbacks => {
- "not in valid numeric range" => lambda { |m|
+ "not in valid numeric range" => lambda do |m|
if m.kind_of?(String)
m =~ /^0/ || m = "0#{m}"
end
@@ -54,7 +54,7 @@ class Chef
else
Integer(m) <= 07777 && Integer(m) >= 0
end
- },
+ end,
}
)
end
diff --git a/lib/chef/monkey_patches/webrick-utils.rb b/lib/chef/monkey_patches/webrick-utils.rb
index 7880adb202..ccca5825e2 100644
--- a/lib/chef/monkey_patches/webrick-utils.rb
+++ b/lib/chef/monkey_patches/webrick-utils.rb
@@ -31,7 +31,7 @@ module WEBrick
Socket::AI_PASSIVE) # flag
last_error = nil
sockets = []
- res.each {|ai|
+ res.each do |ai|
begin
logger.debug("TCPServer.new(#{ai[3]}, #{port})") if logger
sock = TCPServer.new(ai[3], port)
@@ -42,7 +42,7 @@ module WEBrick
logger.warn("TCPServer Error: #{ex}") if logger
last_error = ex
end
- }
+ end
raise last_error if sockets.empty?
return sockets
end
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb
index e4035dd22f..95b3b09f7e 100644
--- a/lib/chef/node/attribute.rb
+++ b/lib/chef/node/attribute.rb
@@ -537,9 +537,9 @@ class Chef
end
def inspect
- "#<#{self.class} " << (COMPONENTS + [:@merged_attributes, :@properties]).map {|iv|
+ "#<#{self.class} " << (COMPONENTS + [:@merged_attributes, :@properties]).map do |iv|
"#{iv}=#{instance_variable_get(iv).inspect}"
- }.join(", ") << ">"
+ end.join(", ") << ">"
end
private
diff --git a/lib/chef/property.rb b/lib/chef/property.rb
index 0589cb4c54..3cb235b612 100644
--- a/lib/chef/property.rb
+++ b/lib/chef/property.rb
@@ -235,9 +235,9 @@ class Chef
# @return [Hash<Symbol,Object>]
#
def validation_options
- @validation_options ||= options.reject { |k, v|
+ @validation_options ||= options.reject do |k, v|
[:declared_in, :name, :instance_variable_name, :desired_state, :identity, :default, :name_property, :coerce, :required, :nillable].include?(k)
- }
+ end
end
#
diff --git a/lib/chef/provider/dsc_script.rb b/lib/chef/provider/dsc_script.rb
index 79769d9773..66783ceb0f 100644
--- a/lib/chef/provider/dsc_script.rb
+++ b/lib/chef/provider/dsc_script.rb
@@ -32,12 +32,12 @@ class Chef
@dsc_resource = dsc_resource
@resource_converged = false
@operations = {
- :set => Proc.new { |config_manager, document, shellout_flags|
+ :set => Proc.new do |config_manager, document, shellout_flags|
config_manager.set_configuration(document, shellout_flags)
- },
- :test => Proc.new { |config_manager, document, shellout_flags|
+ end,
+ :test => Proc.new do |config_manager, document, shellout_flags|
config_manager.test_configuration(document, shellout_flags)
- } }
+ end }
end
def action_run
diff --git a/lib/chef/provider/osx_profile.rb b/lib/chef/provider/osx_profile.rb
index f2e71a6621..f5535f5c37 100644
--- a/lib/chef/provider/osx_profile.rb
+++ b/lib/chef/provider/osx_profile.rb
@@ -66,33 +66,33 @@ class Chef
def define_resource_requirements
requirements.assert(:remove) do |a|
if @new_profile_identifier
- a.assertion {
+ a.assertion do
!@new_profile_identifier.nil? &&
!@new_profile_identifier.end_with?(".mobileconfig") &&
/^\w+(?:\.\w+)+$/.match(@new_profile_identifier)
- }
+ end
a.failure_message RuntimeError, "when removing using the identifier attribute, it must match the profile identifier"
else
new_profile_name = @new_resource.profile_name
- a.assertion {
+ a.assertion do
!new_profile_name.end_with?(".mobileconfig") &&
/^\w+(?:\.\w+)+$/.match(new_profile_name)
- }
+ end
a.failure_message RuntimeError, "When removing by resource name, it must match the profile identifier "
end
end
requirements.assert(:install) do |a|
if @new_profile_hash.is_a?(Hash)
- a.assertion {
+ a.assertion do
@new_profile_hash.include?("PayloadIdentifier")
- }
+ end
a.failure_message RuntimeError, "The specified profile does not seem to be valid"
end
if @new_profile_hash.is_a?(String)
- a.assertion {
+ a.assertion do
@new_profile_hash.end_with?(".mobileconfig")
- }
+ end
a.failure_message RuntimeError, "#{new_profile_hash}' is not a valid profile"
end
end
diff --git a/lib/chef/provider/package/yum/yum_cache.rb b/lib/chef/provider/package/yum/yum_cache.rb
index fb25a91c8c..7462529113 100644
--- a/lib/chef/provider/package/yum/yum_cache.rb
+++ b/lib/chef/provider/package/yum/yum_cache.rb
@@ -197,7 +197,7 @@ class Chef
def shabang?(file)
::File.open(file, "r") do |f|
- f.read(2) == '#!'
+ f.read(2) == "#!"
end
rescue Errno::ENOENT
false
diff --git a/lib/chef/provider/remote_file/ftp.rb b/lib/chef/provider/remote_file/ftp.rb
index 5935e83301..b382c20c31 100644
--- a/lib/chef/provider/remote_file/ftp.rb
+++ b/lib/chef/provider/remote_file/ftp.rb
@@ -153,9 +153,9 @@ class Chef
def parse_path
path = uri.path.sub(%r{\A/}, "%2F") # re-encode the beginning slash because uri library decodes it.
directories = path.split(%r{/}, -1)
- directories.each {|d|
+ directories.each do |d|
d.gsub!(/%([0-9A-Fa-f][0-9A-Fa-f])/) { [$1].pack("H2") }
- }
+ end
unless filename = directories.pop
raise ArgumentError, "no filename: #{path.inspect}"
end
diff --git a/lib/chef/provider/remote_file/sftp.rb b/lib/chef/provider/remote_file/sftp.rb
index 530977e3c8..21c5c4ca04 100644
--- a/lib/chef/provider/remote_file/sftp.rb
+++ b/lib/chef/provider/remote_file/sftp.rb
@@ -68,9 +68,9 @@ class Chef
def validate_path!
path = uri.path.sub(%r{\A/}, "%2F") # re-encode the beginning slash because uri library decodes it.
directories = path.split(%r{/}, -1)
- directories.each {|d|
+ directories.each do |d|
d.gsub!(/%([0-9A-Fa-f][0-9A-Fa-f])/) { [$1].pack("H2") }
- }
+ end
unless filename = directories.pop
raise ArgumentError, "no filename: #{path.inspect}"
end
diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb
index 67b71953f7..9d11032055 100644
--- a/lib/chef/provider/service/debian.rb
+++ b/lib/chef/provider/service/debian.rb
@@ -106,13 +106,13 @@ class Chef
def service_currently_enabled?(priority)
enabled = false
- priority.each { |runlevel, arguments|
+ priority.each do |runlevel, arguments|
Chef::Log.debug("#{new_resource} runlevel #{runlevel}, action #{arguments[0]}, priority #{arguments[1]}")
# if we are in a update-rc.d default startup runlevel && we start in this runlevel
if %w{ 1 2 3 4 5 S }.include?(runlevel) && arguments[0] == :start
enabled = true
end
- }
+ end
enabled
end
diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb
index 6369a3a9a0..d75e85989f 100644
--- a/lib/chef/provider/service/simple.rb
+++ b/lib/chef/provider/service/simple.rb
@@ -76,8 +76,9 @@ class Chef
end
requirements.assert(:all_actions) do |a|
- a.assertion { @new_resource.status_command || supports[:status] ||
- (!ps_cmd.nil? && !ps_cmd.empty?) }
+ a.assertion do
+ @new_resource.status_command || supports[:status] ||
+ (!ps_cmd.nil? && !ps_cmd.empty?) end
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|
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 479eb0a7e2..0de5c89475 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -1276,15 +1276,15 @@ class Chef
# resolve_resource_reference on each in turn, causing them to
# resolve lazy/forward references.
def resolve_notification_references
- run_context.before_notifications(self).each { |n|
+ run_context.before_notifications(self).each do |n|
n.resolve_resource_reference(run_context.resource_collection)
- }
- run_context.immediate_notifications(self).each { |n|
+ end
+ run_context.immediate_notifications(self).each do |n|
n.resolve_resource_reference(run_context.resource_collection)
- }
- run_context.delayed_notifications(self).each {|n|
+ end
+ run_context.delayed_notifications(self).each do |n|
n.resolve_resource_reference(run_context.resource_collection)
- }
+ end
end
# Helper for #notifies
@@ -1575,8 +1575,6 @@ class Chef
end
end
- private
-
def self.remove_canonical_dsl
if @resource_name
remaining = Chef.resource_handler_map.delete_canonical(@resource_name, self)
diff --git a/lib/chef/resource_builder.rb b/lib/chef/resource_builder.rb
index 1641fe60f2..57c57dd8c3 100644
--- a/lib/chef/resource_builder.rb
+++ b/lib/chef/resource_builder.rb
@@ -31,7 +31,7 @@ class Chef
attr_reader :resource
# FIXME (ruby-2.1 syntax): most of these are mandatory
- def initialize(type:nil, name:nil, created_at: nil, params: nil, run_context: nil, cookbook_name: nil, recipe_name: nil, enclosing_provider: nil)
+ def initialize(type: nil, name: nil, created_at: nil, params: nil, run_context: nil, cookbook_name: nil, recipe_name: nil, enclosing_provider: nil)
@type = type
@name = name
@created_at = created_at
diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb
index ebf13bec36..024ec38a16 100644
--- a/lib/chef/search/query.rb
+++ b/lib/chef/search/query.rb
@@ -29,7 +29,7 @@ class Chef
attr_accessor :rest
attr_reader :config
- def initialize(url = nil, config:Chef::Config)
+ def initialize(url = nil, config: Chef::Config)
@config = config
@url = url
end
@@ -146,7 +146,7 @@ WARNDEP
qstr
end
- def call_rest_service(type, query:"*:*", rows:nil, start:0, sort:"X_CHEF_id_CHEF_X asc", filter_result:nil)
+ def call_rest_service(type, query: "*:*", rows: nil, start: 0, sort: "X_CHEF_id_CHEF_X asc", filter_result: nil)
query_string = create_query_string(type, query, rows, start, sort)
if filter_result