summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-01-12 09:56:40 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-01-12 09:56:40 -0800
commit6610ebd39d19c3b8776d69a56a39c3b496b8b29f (patch)
treea5c282b16f71e3f8be0f3ed99310c82cc41ecd6d
parent812101f11a6c33e49f401ad72598ca6ffb38adc4 (diff)
downloadchef-6610ebd39d19c3b8776d69a56a39c3b496b8b29f.tar.gz
really fix copslcg/really-fix-cops
-rw-r--r--chef-config/spec/unit/path_helper_spec.rb8
-rw-r--r--lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb52
-rw-r--r--lib/chef/client.rb8
-rw-r--r--lib/chef/cookbook_site_streaming_uploader.rb8
-rw-r--r--lib/chef/cookbook_version.rb102
-rw-r--r--lib/chef/http/http_request.rb28
-rw-r--r--lib/chef/knife/cookbook_site_download.rb22
-rw-r--r--lib/chef/knife/core/bootstrap_context.rb32
-rw-r--r--lib/chef/knife/core/generic_presenter.rb40
-rw-r--r--lib/chef/knife/core/text_formatter.rb19
-rw-r--r--lib/chef/knife/data_bag_create.rb5
-rw-r--r--lib/chef/knife/data_bag_show.rb50
-rw-r--r--lib/chef/mixin/file_class.rb14
-rw-r--r--lib/chef/platform/rebooter.rb12
-rw-r--r--lib/chef/policy_builder/expand_node_object.rb8
-rw-r--r--lib/chef/provider.rb34
-rw-r--r--lib/chef/provider/env.rb20
-rw-r--r--lib/chef/provider/mount/aix.rb16
-rw-r--r--lib/chef/provider/mount/mount.rb22
-rw-r--r--lib/chef/provider/mount/solaris.rb10
-rw-r--r--lib/chef/provider/package/rubygems.rb48
-rw-r--r--lib/chef/provider/remote_file/content.rb10
-rw-r--r--lib/chef/provider/service/macosx.rb4
-rw-r--r--lib/chef/provider/user/dscl.rb16
-rw-r--r--lib/chef/resource.rb32
-rw-r--r--lib/chef/run_list/versioned_recipe_list.rb10
-rw-r--r--lib/chef/scan_access_control.rb12
-rw-r--r--lib/chef/shell/ext.rb68
-rw-r--r--lib/chef/user.rb12
-rw-r--r--lib/chef/win32/api/net.rb214
-rw-r--r--lib/chef/win32/net.rb48
-rw-r--r--spec/functional/application_spec.rb8
-rw-r--r--spec/functional/mixin/shell_out_spec.rb16
-rw-r--r--spec/functional/resource/file_spec.rb12
-rw-r--r--spec/support/shared/context/win32.rb12
-rw-r--r--spec/unit/application/knife_spec.rb10
-rw-r--r--spec/unit/knife/cookbook_site_install_spec.rb14
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb16
38 files changed, 536 insertions, 536 deletions
diff --git a/chef-config/spec/unit/path_helper_spec.rb b/chef-config/spec/unit/path_helper_spec.rb
index 3e6213597a..3e2a0fd129 100644
--- a/chef-config/spec/unit/path_helper_spec.rb
+++ b/chef-config/spec/unit/path_helper_spec.rb
@@ -256,10 +256,10 @@ RSpec.describe ChefConfig::PathHelper do
it "joins, cleanpaths, and escapes characters reserved by glob" do
args = ["this/*path", "[needs]", "escaping?"]
escaped_path = if ChefConfig.windows?
- "this\\\\\\*path\\\\\\[needs\\]\\\\escaping\\?"
- else
- "this/\\*path/\\[needs\\]/escaping\\?"
- end
+ "this\\\\\\*path\\\\\\[needs\\]\\\\escaping\\?"
+ else
+ "this/\\*path/\\[needs\\]/escaping\\?"
+ end
expect(path_helper).to receive(:join).with(*args).and_call_original
expect(path_helper).to receive(:cleanpath).and_call_original
expect(path_helper.escape_glob(*args)).to eq(escaped_path)
diff --git a/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb b/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb
index 6a59ccff85..b0bd08fc39 100644
--- a/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb
@@ -1,6 +1,6 @@
#
# Author:: John Keiser (<jkeiser@opscode.com>)
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -73,10 +73,10 @@ class Chef
def children
@children ||= begin
- result = child_paths.keys.sort.map { |name| make_child_entry(name) }
- result += CHILDREN.map { |name| make_child_entry(name) }
- result.select { |c| c && c.exists? }.sort_by { |c| c.name }
- end
+ result = child_paths.keys.sort.map { |name| make_child_entry(name) }
+ result += CHILDREN.map { |name| make_child_entry(name) }
+ result.select { |c| c && c.exists? }.sort_by { |c| c.name }
+ end
end
def can_have_child?(name, is_dir)
@@ -168,27 +168,27 @@ class Chef
dirs = paths.map { |path| ChefRepositoryFileSystemAclsDir.new(name, self, path) }
else
data_handler = case name
- when 'clients'
- Chef::ChefFS::DataHandler::ClientDataHandler.new
- when 'environments'
- Chef::ChefFS::DataHandler::EnvironmentDataHandler.new
- when 'nodes'
- Chef::ChefFS::DataHandler::NodeDataHandler.new
- when 'policies'
- Chef::ChefFS::DataHandler::PolicyDataHandler.new
- when 'policy_groups'
- Chef::ChefFS::DataHandler::PolicyGroupDataHandler.new
- when 'roles'
- Chef::ChefFS::DataHandler::RoleDataHandler.new
- when 'users'
- Chef::ChefFS::DataHandler::UserDataHandler.new
- when 'groups'
- Chef::ChefFS::DataHandler::GroupDataHandler.new
- when 'containers'
- Chef::ChefFS::DataHandler::ContainerDataHandler.new
- else
- raise "Unknown top level path #{name}"
- end
+ when 'clients'
+ Chef::ChefFS::DataHandler::ClientDataHandler.new
+ when 'environments'
+ Chef::ChefFS::DataHandler::EnvironmentDataHandler.new
+ when 'nodes'
+ Chef::ChefFS::DataHandler::NodeDataHandler.new
+ when 'policies'
+ Chef::ChefFS::DataHandler::PolicyDataHandler.new
+ when 'policy_groups'
+ Chef::ChefFS::DataHandler::PolicyGroupDataHandler.new
+ when 'roles'
+ Chef::ChefFS::DataHandler::RoleDataHandler.new
+ when 'users'
+ Chef::ChefFS::DataHandler::UserDataHandler.new
+ when 'groups'
+ Chef::ChefFS::DataHandler::GroupDataHandler.new
+ when 'containers'
+ Chef::ChefFS::DataHandler::ContainerDataHandler.new
+ else
+ raise "Unknown top level path #{name}"
+ end
dirs = paths.map { |path| ChefRepositoryFileSystemEntry.new(name, self, path, data_handler) }
end
MultiplexedDir.new(dirs)
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index ead804879f..9d9909bac2 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -317,10 +317,10 @@ class Chef
run_error || converge_error
else
e = if run_error == converge_error
- Chef::Exceptions::RunFailedWrappingError.new(converge_error, audit_error)
- else
- Chef::Exceptions::RunFailedWrappingError.new(run_error, converge_error, audit_error)
- end
+ Chef::Exceptions::RunFailedWrappingError.new(converge_error, audit_error)
+ else
+ Chef::Exceptions::RunFailedWrappingError.new(run_error, converge_error, audit_error)
+ end
e.fill_backtrace
e
end
diff --git a/lib/chef/cookbook_site_streaming_uploader.rb b/lib/chef/cookbook_site_streaming_uploader.rb
index 2be189e942..345f6b0106 100644
--- a/lib/chef/cookbook_site_streaming_uploader.rb
+++ b/lib/chef/cookbook_site_streaming_uploader.rb
@@ -2,7 +2,7 @@
# Author:: Stanislav Vitvitskiy
# Author:: Nuo Yan (nuo@opscode.com)
# Author:: Christopher Walters (<cw@opscode.com>)
-# Copyright:: Copyright (c) 2009, 2010 Opscode, Inc.
+# Copyright:: Copyright (c) 2009, 2010-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -229,9 +229,9 @@ class Chef
next_part = read(how_much_next_part)
result = current_part + if next_part
next_part
- else
- ''
- end
+ else
+ ''
+ end
else
@part_offset += how_much_current_part
result = current_part
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index 4eb118d3bc..97edb12689 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -300,15 +300,15 @@ class Chef
if segment == :files || segment == :templates
error_message = "Cookbook '#{name}' (#{version}) does not contain a file at any of these locations:\n"
error_locations = if filename.is_a?(Array)
- filename.map{|name| " #{File.join(segment.to_s, name)}"}
- else
- [
- " #{segment}/#{node[:platform]}-#{node[:platform_version]}/#{filename}",
- " #{segment}/#{node[:platform]}/#{filename}",
- " #{segment}/default/#{filename}",
- " #{segment}/#{filename}",
- ]
- end
+ filename.map{|name| " #{File.join(segment.to_s, name)}"}
+ else
+ [
+ " #{segment}/#{node[:platform]}-#{node[:platform_version]}/#{filename}",
+ " #{segment}/#{node[:platform]}/#{filename}",
+ " #{segment}/default/#{filename}",
+ " #{segment}/#{filename}",
+ ]
+ end
error_message << error_locations.join("\n")
existing_files = segment_filenames(segment)
# Strip the root_dir prefix off all files for readability
@@ -354,7 +354,7 @@ class Chef
# cookbook find them by filespecificity again. but it's the shortest
# path to "success" for now.
if manifest_record_path =~ /(#{Regexp.escape(segment.to_s)}\/[^\/]+\/#{Regexp.escape(dirname)})\/.+$/
- specificity_dirname = $1
+ specificity_dirname = $1
non_specific_path = manifest_record_path[/#{Regexp.escape(segment.to_s)}\/[^\/]+\/#{Regexp.escape(dirname)}\/(.+)$/, 1]
# Record the specificity_dirname only if it's in the list of
# valid preferences
@@ -385,11 +385,11 @@ class Chef
# extract the preference part from the path.
if manifest_record_path =~ /(#{Regexp.escape(segment.to_s)}\/[^\/]+\/#{Regexp.escape(dirname)})\/.+$/
- # Note the specificy_dirname includes the segment and
- # dirname argument as above, which is what
- # preferences_for_path returns. It could be
- # "files/ubuntu-9.10/dirname", for example.
- specificity_dirname = $1
+ # Note the specificy_dirname includes the segment and
+ # dirname argument as above, which is what
+ # preferences_for_path returns. It could be
+ # "files/ubuntu-9.10/dirname", for example.
+ specificity_dirname = $1
# Record the specificity_dirname only if it's in the list of
# valid preferences
@@ -413,42 +413,42 @@ class Chef
# only files and templates can be platform-specific
if segment.to_sym == :files || segment.to_sym == :templates
relative_search_path = if path.is_a?(Array)
- path
- else
- begin
- platform, version = Chef::Platform.find_platform_and_version(node)
- rescue ArgumentError => e
- # Skip platform/version if they were not found by find_platform_and_version
- if e.message =~ /Cannot find a (?:platform|version)/
- platform = "/unknown_platform/"
- version = "/unknown_platform_version/"
- else
- raise
- end
- end
-
- fqdn = node[:fqdn]
-
- # Break version into components, eg: "5.7.1" => [ "5.7.1", "5.7", "5" ]
- search_versions = []
- parts = version.to_s.split('.')
-
- parts.size.times do
- search_versions << parts.join('.')
- parts.pop
- end
-
- # Most specific to least specific places to find the path
- search_path = [ File.join("host-#{fqdn}", path) ]
- search_versions.each do |v|
- search_path << File.join("#{platform}-#{v}", path)
- end
- search_path << File.join(platform.to_s, path)
- search_path << File.join("default", path)
- search_path << path
-
- search_path
- end
+ path
+ else
+ begin
+ platform, version = Chef::Platform.find_platform_and_version(node)
+ rescue ArgumentError => e
+ # Skip platform/version if they were not found by find_platform_and_version
+ if e.message =~ /Cannot find a (?:platform|version)/
+ platform = "/unknown_platform/"
+ version = "/unknown_platform_version/"
+ else
+ raise
+ end
+ end
+
+ fqdn = node[:fqdn]
+
+ # Break version into components, eg: "5.7.1" => [ "5.7.1", "5.7", "5" ]
+ search_versions = []
+ parts = version.to_s.split('.')
+
+ parts.size.times do
+ search_versions << parts.join('.')
+ parts.pop
+ end
+
+ # Most specific to least specific places to find the path
+ search_path = [ File.join("host-#{fqdn}", path) ]
+ search_versions.each do |v|
+ search_path << File.join("#{platform}-#{v}", path)
+ end
+ search_path << File.join(platform.to_s, path)
+ search_path << File.join("default", path)
+ search_path << path
+
+ search_path
+ end
relative_search_path.map {|relative_path| File.join(segment.to_s, relative_path)}
else
if segment.to_sym == :root_files
diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb
index 24cd99375d..9e48f6e5e9 100644
--- a/lib/chef/http/http_request.rb
+++ b/lib/chef/http/http_request.rb
@@ -5,7 +5,7 @@
# Author:: Christopher Brown (<cb@opscode.com>)
# Author:: Christopher Walters (<cw@opscode.com>)
# Author:: Daniel DeLeo (<dan@opscode.com>)
-# Copyright:: Copyright (c) 2009, 2010 Opscode, Inc.
+# Copyright:: Copyright (c) 2009, 2010-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -156,19 +156,19 @@ class Chef
req_path << "?#{query}" if query
@http_request = case method.to_s.downcase
- when GET
- Net::HTTP::Get.new(req_path, headers)
- when POST
- Net::HTTP::Post.new(req_path, headers)
- when PUT
- Net::HTTP::Put.new(req_path, headers)
- when DELETE
- Net::HTTP::Delete.new(req_path, headers)
- when HEAD
- Net::HTTP::Head.new(req_path, headers)
- else
- raise ArgumentError, "You must provide :GET, :PUT, :POST, :DELETE or :HEAD as the method"
- end
+ when GET
+ Net::HTTP::Get.new(req_path, headers)
+ when POST
+ Net::HTTP::Post.new(req_path, headers)
+ when PUT
+ Net::HTTP::Put.new(req_path, headers)
+ when DELETE
+ Net::HTTP::Delete.new(req_path, headers)
+ when HEAD
+ Net::HTTP::Head.new(req_path, headers)
+ else
+ raise ArgumentError, "You must provide :GET, :PUT, :POST, :DELETE or :HEAD as the method"
+ end
@http_request.body = request_body if (request_body && @http_request.request_body_permitted?)
# Optionally handle HTTP Basic Authentication
diff --git a/lib/chef/knife/cookbook_site_download.rb b/lib/chef/knife/cookbook_site_download.rb
index 72608f3a30..3aedd21ffa 100644
--- a/lib/chef/knife/cookbook_site_download.rb
+++ b/lib/chef/knife/cookbook_site_download.rb
@@ -1,5 +1,5 @@
# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2009 Opscode, Inc.
+# Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -63,8 +63,8 @@ class Chef
def current_cookbook_data
@current_cookbook_data ||= begin
- noauth_rest.get "#{cookbooks_api_url}/#{@name_args[0]}"
- end
+ noauth_rest.get "#{cookbooks_api_url}/#{@name_args[0]}"
+ end
end
def current_cookbook_deprecated?
@@ -73,14 +73,14 @@ class Chef
def desired_cookbook_data
@desired_cookbook_data ||= begin
- uri = if @name_args.length == 1
- current_cookbook_data['latest_version']
- else
- specific_cookbook_version_url
- end
-
- noauth_rest.get uri
- end
+ uri = if @name_args.length == 1
+ current_cookbook_data['latest_version']
+ else
+ specific_cookbook_version_url
+ end
+
+ noauth_rest.get uri
+ end
end
def download_cookbook
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb
index fca3b0a90e..c39ae6837d 100644
--- a/lib/chef/knife/core/bootstrap_context.rb
+++ b/lib/chef/knife/core/bootstrap_context.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@opscode.com>)
-# Copyright:: Copyright (c) 2011 Opscode, Inc.
+# Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -66,7 +66,7 @@ class Chef
log_location STDOUT
chef_server_url "#{@chef_config[:chef_server_url]}"
validation_client_name "#{@chef_config[:validation_client_name]}"
-CONFIG
+ CONFIG
if @config[:chef_node_name]
client_rb << %Q{node_name "#{@config[:chef_node_name]}"\n}
else
@@ -84,15 +84,15 @@ CONFIG
# or when specified in the knife config.
if @config[:node_ssl_verify_mode] || knife_config.has_key?(:ssl_verify_mode)
value = case @config[:node_ssl_verify_mode]
- when "peer"
- :verify_peer
- when "none"
- :verify_none
- when nil
- knife_config[:ssl_verify_mode]
- else
- nil
- end
+ when "peer"
+ :verify_peer
+ when "none"
+ :verify_none
+ when nil
+ knife_config[:ssl_verify_mode]
+ else
+ nil
+ end
if value
client_rb << %Q{ssl_verify_mode :#{value}\n}
@@ -147,10 +147,10 @@ CONFIG
installer_version_string = ["-p"]
else
chef_version_string = if knife_config[:bootstrap_version]
- knife_config[:bootstrap_version]
- else
- Chef::VERSION.split(".").first
- end
+ knife_config[:bootstrap_version]
+ else
+ Chef::VERSION.split(".").first
+ end
installer_version_string = ["-v", chef_version_string]
@@ -184,7 +184,7 @@ CONFIG
if @chef_config[:trusted_certs_dir]
Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(@chef_config[:trusted_certs_dir]), "*.{crt,pem}")).each do |cert|
content << "cat > /etc/chef/trusted_certs/#{File.basename(cert)} <<'EOP'\n" +
- IO.read(File.expand_path(cert)) + "\nEOP\n"
+ IO.read(File.expand_path(cert)) + "\nEOP\n"
end
end
content
diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb
index 2df9603faa..1b26becfa1 100644
--- a/lib/chef/knife/core/generic_presenter.rb
+++ b/lib/chef/knife/core/generic_presenter.rb
@@ -1,6 +1,6 @@
#--
# Author:: Daniel DeLeo (<dan@opscode.com>)
-# Copyright:: Copyright (c) 2011 Opscode, Inc.
+# Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -150,18 +150,18 @@ class Chef
def format_data_subset_for_display(data)
subset = if config[:attribute]
- result = {}
- Array(config[:attribute]).each do |nested_value_spec|
- nested_value = extract_nested_value(data, nested_value_spec)
- result[nested_value_spec] = nested_value
- end
- result
- elsif config[:run_list]
- run_list = data.run_list.run_list
- { "run_list" => run_list }
- else
- raise ArgumentError, "format_data_subset_for_display requires attribute, run_list, or id_only config option to be set"
- end
+ result = {}
+ Array(config[:attribute]).each do |nested_value_spec|
+ nested_value = extract_nested_value(data, nested_value_spec)
+ result[nested_value_spec] = nested_value
+ end
+ result
+ elsif config[:run_list]
+ run_list = data.run_list.run_list
+ { "run_list" => run_list }
+ else
+ raise ArgumentError, "format_data_subset_for_display requires attribute, run_list, or id_only config option to be set"
+ end
{name_or_id_for(data) => subset }
end
@@ -178,19 +178,19 @@ class Chef
nested_value_spec.split(".").each do |attr|
if data.nil?
nil # don't get no method error on nil
- # Must check :[] before attr because spec can include
- # `keys` - want the key named `keys`, not a list of
- # available keys.
+ # Must check :[] before attr because spec can include
+ # `keys` - want the key named `keys`, not a list of
+ # available keys.
elsif data.respond_to?(:[]) && data.has_key?(attr)
data = data[attr]
elsif data.respond_to?(attr.to_sym)
data = data.send(attr.to_sym)
else
data = begin
- data.send(attr.to_sym)
- rescue NoMethodError
- nil
- end
+ data.send(attr.to_sym)
+ rescue NoMethodError
+ nil
+ end
end
end
( !data.kind_of?(Array) && data.respond_to?(:to_hash) ) ? data.to_hash : data
diff --git a/lib/chef/knife/core/text_formatter.rb b/lib/chef/knife/core/text_formatter.rb
index 60328488b2..5afdb6aaa9 100644
--- a/lib/chef/knife/core/text_formatter.rb
+++ b/lib/chef/knife/core/text_formatter.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@opscode.com>)
-# Copyright:: Copyright (c) 2011 Opscode, Inc.
+# Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,14 +27,14 @@ class Chef
def initialize(data, ui)
@ui = ui
@data = if data.respond_to?(:display_hash)
- data.display_hash
- elsif data.kind_of?(Array)
- data
- elsif data.respond_to?(:to_hash)
- data.to_hash
- else
- data
- end
+ data.display_hash
+ elsif data.kind_of?(Array)
+ data
+ elsif data.respond_to?(:to_hash)
+ data.to_hash
+ else
+ data
+ end
end
def formatted_data
@@ -83,4 +83,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/data_bag_create.rb b/lib/chef/knife/data_bag_create.rb
index 1becad88b9..0aa3002b23 100644
--- a/lib/chef/knife/data_bag_create.rb
+++ b/lib/chef/knife/data_bag_create.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
# Author:: Seth Falcon (<seth@opscode.com>)
-# Copyright:: Copyright (c) 2009-2010 Opscode, Inc.
+# Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -66,7 +66,8 @@ class Chef
Chef::EncryptedDataBagItem.encrypt_data_bag_item(output, read_secret)
else
output
- end)
+ end
+ )
item.data_bag(@data_bag_name)
rest.post("data/#{@data_bag_name}", item)
end
diff --git a/lib/chef/knife/data_bag_show.rb b/lib/chef/knife/data_bag_show.rb
index 36715286e8..2adafbde79 100644
--- a/lib/chef/knife/data_bag_show.rb
+++ b/lib/chef/knife/data_bag_show.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
# Author:: Seth Falcon (<seth@opscode.com>)
-# Copyright:: Copyright (c) 2009-2010 Opscode, Inc.
+# Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,32 +35,32 @@ class Chef
def run
display = case @name_args.length
- when 2 # Bag and Item names provided
- secret = encryption_secret_provided_ignore_encrypt_flag? ? read_secret : nil
- raw_data = Chef::DataBagItem.load(@name_args[0], @name_args[1]).raw_data
- encrypted = encrypted?(raw_data)
+ when 2 # Bag and Item names provided
+ secret = encryption_secret_provided_ignore_encrypt_flag? ? read_secret : nil
+ raw_data = Chef::DataBagItem.load(@name_args[0], @name_args[1]).raw_data
+ encrypted = encrypted?(raw_data)
- if encrypted && secret
- # Users do not need to pass --encrypt to read data, we simply try to use the provided secret
- ui.info("Encrypted data bag detected, decrypting with provided secret.")
- raw = Chef::EncryptedDataBagItem.load(@name_args[0],
- @name_args[1],
- secret)
- format_for_display(raw.to_hash)
- elsif encrypted && !secret
- ui.warn("Encrypted data bag detected, but no secret provided for decoding. Displaying encrypted data.")
- format_for_display(raw_data)
- else
- ui.info("Unencrypted data bag detected, ignoring any provided secret options.")
- format_for_display(raw_data)
- end
+ if encrypted && secret
+ # Users do not need to pass --encrypt to read data, we simply try to use the provided secret
+ ui.info("Encrypted data bag detected, decrypting with provided secret.")
+ raw = Chef::EncryptedDataBagItem.load(@name_args[0],
+ @name_args[1],
+ secret)
+ format_for_display(raw.to_hash)
+ elsif encrypted && !secret
+ ui.warn("Encrypted data bag detected, but no secret provided for decoding. Displaying encrypted data.")
+ format_for_display(raw_data)
+ else
+ ui.info("Unencrypted data bag detected, ignoring any provided secret options.")
+ format_for_display(raw_data)
+ end
- when 1 # Only Bag name provided
- format_list_for_display(Chef::DataBag.load(@name_args[0]))
- else
- stdout.puts opt_parser
- exit(1)
- end
+ when 1 # Only Bag name provided
+ format_list_for_display(Chef::DataBag.load(@name_args[0]))
+ else
+ stdout.puts opt_parser
+ exit(1)
+ end
output(display)
end
diff --git a/lib/chef/mixin/file_class.rb b/lib/chef/mixin/file_class.rb
index f6a663daed..347ef45ba9 100644
--- a/lib/chef/mixin/file_class.rb
+++ b/lib/chef/mixin/file_class.rb
@@ -2,7 +2,7 @@
# Author:: Mark Mzyk <mmzyk@opscode.com>
# Author:: Seth Chisamore <schisamo@opscode.com>
# Author:: Bryan McLellan <btm@opscode.com>
-# Copyright:: Copyright (c) 2011-2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,14 +24,12 @@ class Chef
def file_class
@host_os_file ||= if Chef::Platform.windows?
- require 'chef/win32/file'
- Chef::ReservedNames::Win32::File
- else
- ::File
- end
+ require 'chef/win32/file'
+ Chef::ReservedNames::Win32::File
+ else
+ ::File
+ end
end
end
end
end
-
-
diff --git a/lib/chef/platform/rebooter.rb b/lib/chef/platform/rebooter.rb
index b78ac38f0c..ce357bf993 100644
--- a/lib/chef/platform/rebooter.rb
+++ b/lib/chef/platform/rebooter.rb
@@ -31,12 +31,12 @@ class Chef
reboot_info = node.run_context.reboot_info
cmd = if Chef::Platform.windows?
- # should this do /f as well? do we then need a minimum delay to let apps quit?
- "shutdown /r /t #{reboot_info[:delay_mins]*60} /c \"#{reboot_info[:reason]}\""
- else
- # probably Linux-only.
- "shutdown -r +#{reboot_info[:delay_mins]} \"#{reboot_info[:reason]}\""
- end
+ # should this do /f as well? do we then need a minimum delay to let apps quit?
+ "shutdown /r /t #{reboot_info[:delay_mins]*60} /c \"#{reboot_info[:reason]}\""
+ else
+ # probably Linux-only.
+ "shutdown -r +#{reboot_info[:delay_mins]} \"#{reboot_info[:reason]}\""
+ end
Chef::Log.warn "Rebooting server at a recipe's request. Details: #{reboot_info.inspect}"
shell_out!(cmd)
diff --git a/lib/chef/policy_builder/expand_node_object.rb b/lib/chef/policy_builder/expand_node_object.rb
index 870351b6fb..7b56074e5a 100644
--- a/lib/chef/policy_builder/expand_node_object.rb
+++ b/lib/chef/policy_builder/expand_node_object.rb
@@ -164,10 +164,10 @@ class Chef
# Expands the node's run list. Stores the run_list_expansion object for later use.
def expand_run_list
@run_list_expansion = if Chef::Config[:solo]
- node.expand!('disk')
- else
- node.expand!('server')
- end
+ node.expand!('disk')
+ else
+ node.expand!('server')
+ end
# @run_list_expansion is a RunListExpansion.
#
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb
index c53f4a6991..99e02844ac 100644
--- a/lib/chef/provider.rb
+++ b/lib/chef/provider.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
# Author:: Christopher Walters (<cw@opscode.com>)
-# Copyright:: Copyright (c) 2008, 2009 Opscode, Inc.
+# Copyright:: Copyright (c) 2008, 2009-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -205,10 +205,10 @@ class Chef
modified = specified_properties.select { |p| new_resource.send(p) != current_resource.send(p) }
if modified.empty?
properties_str = if sensitive
- specified_properties.join(", ")
- else
- specified_properties.map { |p| "#{p}=#{new_resource.send(p).inspect}" }.join(", ")
- end
+ specified_properties.join(", ")
+ else
+ specified_properties.map { |p| "#{p}=#{new_resource.send(p).inspect}" }.join(", ")
+ end
Chef::Log.debug("Skipping update of #{new_resource}: has not changed any of the specified properties #{properties_str}.")
return false
end
@@ -217,10 +217,10 @@ class Chef
property_size = modified.map { |p| p.size }.max
modified.map! do |p|
properties_str = if sensitive
- '(suppressed sensitive property)'
- else
- "#{new_resource.send(p).inspect} (was #{current_resource.send(p).inspect})"
- end
+ '(suppressed sensitive property)'
+ else
+ "#{new_resource.send(p).inspect} (was #{current_resource.send(p).inspect})"
+ end
" set #{p.to_s.ljust(property_size)} to #{properties_str}"
end
converge_by([ "update #{current_resource.identity}" ] + modified, &converge_block)
@@ -232,10 +232,10 @@ class Chef
created = properties.map do |property|
default = ' (default value)' unless new_resource.property_is_set?(property)
properties_str = if sensitive
- '(suppressed sensitive property)'
- else
- new_resource.send(property).inspect
- end
+ '(suppressed sensitive property)'
+ else
+ new_resource.send(property).inspect
+ end
" set #{property.to_s.ljust(property_size)} to #{properties_str}#{default}"
end
@@ -299,10 +299,10 @@ class Chef
EOM
end
dsl_methods =
- resource.class.public_instance_methods +
- resource.class.protected_instance_methods -
- provider_class.instance_methods -
- resource.class.properties.keys
+ resource.class.public_instance_methods +
+ resource.class.protected_instance_methods -
+ provider_class.instance_methods -
+ resource.class.properties.keys
def_delegators(:new_resource, *dsl_methods)
end
include @included_resource_dsl_module
diff --git a/lib/chef/provider/env.rb b/lib/chef/provider/env.rb
index 8bd7b3e6ca..654ecf9d6a 100644
--- a/lib/chef/provider/env.rb
+++ b/lib/chef/provider/env.rb
@@ -108,15 +108,15 @@ class Chef
not new_values.include?(item)
end.join(@new_resource.delim)
- if new_value.empty?
- return false #nothing left here, delete the key
- else
- old_value = @new_resource.value(new_value)
- create_env
- Chef::Log.debug("#{@new_resource} deleted #{old_value} element")
- @new_resource.updated_by_last_action(true)
- return true #we removed the element and updated; do not delete the key
- end
+ if new_value.empty?
+ return false #nothing left here, delete the key
+ else
+ old_value = @new_resource.value(new_value)
+ create_env
+ Chef::Log.debug("#{@new_resource} deleted #{old_value} element")
+ @new_resource.updated_by_last_action(true)
+ return true #we removed the element and updated; do not delete the key
+ end
end
end
@@ -164,6 +164,6 @@ class Chef
def new_values
@new_values ||= @new_resource.value.split(@new_resource.delim)
end
- end
+ end
end
end
diff --git a/lib/chef/provider/mount/aix.rb b/lib/chef/provider/mount/aix.rb
index 510dfde46d..41a2ae1176 100644
--- a/lib/chef/provider/mount/aix.rb
+++ b/lib/chef/provider/mount/aix.rb
@@ -99,13 +99,13 @@ class Chef
end
command << case @new_resource.device_type
- when :device
- " #{device_real}"
- when :label
- " -L #{@new_resource.device}"
- when :uuid
- " -U #{@new_resource.device}"
- end
+ when :device
+ " #{device_real}"
+ when :label
+ " -L #{@new_resource.device}"
+ when :uuid
+ " -U #{@new_resource.device}"
+ end
command << " #{@new_resource.mount_point}"
shell_out!(command)
Chef::Log.debug("#{@new_resource} is mounted at #{@new_resource.mount_point}")
@@ -174,7 +174,7 @@ class Chef
end
end
+ end
end
- end
end
end
diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb
index ef074166a9..9ffdf3a557 100644
--- a/lib/chef/provider/mount/mount.rb
+++ b/lib/chef/provider/mount/mount.rb
@@ -104,13 +104,13 @@ class Chef
command = "mount -t #{@new_resource.fstype}"
command << " -o #{@new_resource.options.join(',')}" unless @new_resource.options.nil? || @new_resource.options.empty?
command << case @new_resource.device_type
- when :device
- " #{device_real}"
- when :label
- " -L #{@new_resource.device}"
- when :uuid
- " -U #{@new_resource.device}"
- end
+ when :device
+ " #{device_real}"
+ when :label
+ " -L #{@new_resource.device}"
+ when :uuid
+ " -U #{@new_resource.device}"
+ end
command << " #{@new_resource.mount_point}"
shell_out!(command)
Chef::Log.debug("#{@new_resource} is mounted at #{@new_resource.mount_point}")
@@ -170,7 +170,7 @@ class Chef
found = false
::File.readlines("/etc/fstab").reverse_each do |line|
if !found && line =~ /^#{device_fstab_regex}\s+#{Regexp.escape(@new_resource.mount_point)}\s/
- found = true
+ found = true
Chef::Log.debug("#{@new_resource} is removed from fstab")
next
else
@@ -259,9 +259,9 @@ class Chef
def mount_options_unchanged?
@current_resource.fstype == @new_resource.fstype and
- @current_resource.options == @new_resource.options and
- @current_resource.dump == @new_resource.dump and
- @current_resource.pass == @new_resource.pass
+ @current_resource.options == @new_resource.options and
+ @current_resource.dump == @new_resource.dump and
+ @current_resource.pass == @new_resource.pass
end
end
diff --git a/lib/chef/provider/mount/solaris.rb b/lib/chef/provider/mount/solaris.rb
index deb04d4d7b..062696ac53 100644
--- a/lib/chef/provider/mount/solaris.rb
+++ b/lib/chef/provider/mount/solaris.rb
@@ -221,10 +221,10 @@ class Chef
def vfstab_entry
actual_options = unless options.nil?
- tempops = options.dup
- tempops.delete('noauto')
- tempops
- end
+ tempops = options.dup
+ tempops.delete('noauto')
+ tempops
+ end
autostr = mount_at_boot? ? 'yes' : 'no'
passstr = pass == 0 ? '-' : pass
optstr = (actual_options.nil? || actual_options.empty?) ? '-' : actual_options.join(',')
@@ -236,7 +236,7 @@ class Chef
found = false
::File.readlines(VFSTAB).reverse_each do |line|
if !found && line =~ /^#{device_regex}\s+\S+\s+#{Regexp.escape(mount_point)}/
- found = true
+ found = true
Chef::Log.debug("#{new_resource} is removed from vfstab")
next
end
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
index 0ea739e8d1..3272624f62 100644
--- a/lib/chef/provider/package/rubygems.rb
+++ b/lib/chef/provider/package/rubygems.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
# Author:: Daniel DeLeo (<dan@opscode.com>)
-# Copyright:: Copyright (c) 2008, 2010 Opscode, Inc.
+# Copyright:: Copyright (c) 2008, 2010-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -161,17 +161,17 @@ class Chef
def find_newest_remote_version(gem_dependency, *sources)
available_gems = dependency_installer.find_gems_with_sources(gem_dependency)
spec, source = if available_gems.respond_to?(:last)
- # DependencyInstaller sorts the results such that the last one is
- # always the one it considers best.
- spec_with_source = available_gems.last
- spec_with_source && spec_with_source
- else
- # Rubygems 2.0 returns a Gem::Available set, which is a
- # collection of AvailableSet::Tuple structs
- available_gems.pick_best!
- best_gem = available_gems.set.first
- best_gem && [best_gem.spec, best_gem.source]
- end
+ # DependencyInstaller sorts the results such that the last one is
+ # always the one it considers best.
+ spec_with_source = available_gems.last
+ spec_with_source && spec_with_source
+ else
+ # Rubygems 2.0 returns a Gem::Available set, which is a
+ # collection of AvailableSet::Tuple structs
+ available_gems.pick_best!
+ best_gem = available_gems.set.first
+ best_gem && [best_gem.spec, best_gem.source]
+ end
version = spec && spec.version
if version
@@ -438,8 +438,8 @@ class Chef
gemspec = matching_installed_versions.last
logger.debug { "#{@new_resource} found installed gem #{gemspec.name} version #{gemspec.version} matching #{gem_dependency}"}
gemspec
- # If no version matching the requirements exists, the latest installed
- # version is the current version.
+ # If no version matching the requirements exists, the latest installed
+ # version is the current version.
elsif !all_installed_versions.empty?
gemspec = all_installed_versions.last
logger.debug { "#{@new_resource} newest installed version of gem #{gemspec.name} is #{gemspec.version}" }
@@ -456,8 +456,8 @@ class Chef
def all_installed_versions
@all_installed_versions ||= begin
- @gem_env.installed_versions(Gem::Dependency.new(gem_dependency.name, '>= 0'))
- end
+ @gem_env.installed_versions(Gem::Dependency.new(gem_dependency.name, '>= 0'))
+ end
end
def gem_sources
@@ -482,14 +482,14 @@ class Chef
def candidate_version
@candidate_version ||= begin
- if target_version_already_installed?(@current_resource.version, @new_resource.version)
- nil
- elsif source_is_remote?
- @gem_env.candidate_version_from_remote(gem_dependency, *gem_sources).to_s
- else
- @gem_env.candidate_version_from_file(gem_dependency, @new_resource.source).to_s
- end
- end
+ if target_version_already_installed?(@current_resource.version, @new_resource.version)
+ nil
+ elsif source_is_remote?
+ @gem_env.candidate_version_from_remote(gem_dependency, *gem_sources).to_s
+ else
+ @gem_env.candidate_version_from_file(gem_dependency, @new_resource.source).to_s
+ end
+ end
end
def target_version_already_installed?(current_version, new_version)
diff --git a/lib/chef/provider/remote_file/content.rb b/lib/chef/provider/remote_file/content.rb
index 01193907a1..e9d85b4087 100644
--- a/lib/chef/provider/remote_file/content.rb
+++ b/lib/chef/provider/remote_file/content.rb
@@ -1,7 +1,7 @@
#
# Author:: Jesse Campbell (<hikeit@gmail.com>)
# Author:: Lamont Granquist (<lamont@opscode.com>)
-# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,10 +49,10 @@ class Chef
source = sources.shift
begin
uri = if Chef::Provider::RemoteFile::Fetcher.network_share?(source)
- source
- else
- as_uri(source)
- end
+ source
+ else
+ as_uri(source)
+ end
raw_file = grab_file_from_uri(uri)
rescue SocketError, Errno::ECONNREFUSED, Errno::ENOENT, Errno::EACCES, Timeout::Error, Net::HTTPServerException, Net::HTTPFatalError, Net::FTPError => e
Chef::Log.warn("#{@new_resource} cannot be downloaded from #{source}: #{e}")
diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb
index 9c733da493..47c74f9425 100644
--- a/lib/chef/provider/service/macosx.rb
+++ b/lib/chef/provider/service/macosx.rb
@@ -160,7 +160,7 @@ class Chef
end
end
- def load_service
+ def load_service
session = @session_type ? "-S #{@session_type} " : ''
cmd = 'launchctl load -w ' + session + @plist
shell_out_as_user(cmd)
@@ -206,7 +206,7 @@ class Chef
end
end
- private
+ private
def find_service_label
# CHEF-5223 "you can't glob for a file that hasn't been converged
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index 1faf2438ac..5b506daf81 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -363,7 +363,7 @@ user password using shadow hash.")
# Shadow info is saved as binary plist. Convert the info to binary plist.
shadow_info_binary = StringIO.new
command = Mixlib::ShellOut.new("plutil -convert binary1 -o - -",
- :input => shadow_info.to_plist, :live_stream => shadow_info_binary)
+ :input => shadow_info.to_plist, :live_stream => shadow_info_binary)
command.run_command
if user_info.nil?
@@ -391,13 +391,13 @@ user password using shadow hash.")
if mac_osx_version_10_7?
hash_value = if salted_sha512?(new_resource.password)
- new_resource.password
- else
- # Create a random 4 byte salt
- salt = OpenSSL::Random.random_bytes(4)
- encoded_password = OpenSSL::Digest::SHA512.hexdigest(salt + new_resource.password)
- hash_value = salt.unpack('H*').first + encoded_password
- end
+ new_resource.password
+ else
+ # Create a random 4 byte salt
+ salt = OpenSSL::Random.random_bytes(4)
+ encoded_password = OpenSSL::Digest::SHA512.hexdigest(salt + new_resource.password)
+ hash_value = salt.unpack('H*').first + encoded_password
+ end
shadow_info["SALTED-SHA512"] = StringIO.new
shadow_info["SALTED-SHA512"].string = convert_to_binary(hash_value)
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 6b56a0107a..42d91a056a 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -257,7 +257,7 @@ class Chef
notifies_before(action, resource)
else
raise ArgumentError, "invalid timing: #{timing} for notifies(#{action}, #{resources.inspect}, #{timing}) resource #{self} "\
- "Valid timings are: :delayed, :immediate, :immediately, :before"
+ "Valid timings are: :delayed, :immediate, :immediately, :before"
end
end
@@ -732,10 +732,10 @@ class Chef
#
def provider(arg=nil)
klass = if arg.kind_of?(String) || arg.kind_of?(Symbol)
- lookup_provider_constant(arg)
- else
- arg
- end
+ lookup_provider_constant(arg)
+ else
+ arg
+ end
set_or_return(:provider, klass, kind_of: [ Class ]) ||
self.class.action_class
end
@@ -1198,17 +1198,17 @@ class Chef
# @api private
def self.declare_action_class(&block)
@action_class ||= begin
- if superclass.respond_to?(:action_class)
- base_provider = superclass.action_class
- end
- base_provider ||= Chef::Provider
-
- resource_class = self
- Class.new(base_provider) do
- include ActionClass
- self.resource_class = resource_class
- end
- end
+ if superclass.respond_to?(:action_class)
+ base_provider = superclass.action_class
+ end
+ base_provider ||= Chef::Provider
+
+ resource_class = self
+ Class.new(base_provider) do
+ include ActionClass
+ self.resource_class = resource_class
+ end
+ end
@action_class.class_eval(&block) if block
@action_class
end
diff --git a/lib/chef/run_list/versioned_recipe_list.rb b/lib/chef/run_list/versioned_recipe_list.rb
index 803156aef9..514685b72d 100644
--- a/lib/chef/run_list/versioned_recipe_list.rb
+++ b/lib/chef/run_list/versioned_recipe_list.rb
@@ -1,7 +1,7 @@
#
# Author:: Stephen Delano (<stephen@opscode.com>)
# Author:: Seth Falcon (<seth@opscode.com>)
-# Copyright:: Copyright 2010 Opscode, Inc.
+# Copyright:: Copyright 2010-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -71,10 +71,10 @@ class Chef
def with_fully_qualified_names_and_version_constraints
self.map do |recipe_name|
qualified_recipe = if recipe_name.include?('::')
- recipe_name
- else
- "#{recipe_name}::default"
- end
+ recipe_name
+ else
+ "#{recipe_name}::default"
+ end
version = @versions[recipe_name]
qualified_recipe = "#{qualified_recipe}@#{version}" if version
diff --git a/lib/chef/scan_access_control.rb b/lib/chef/scan_access_control.rb
index 01630a7254..591324277c 100644
--- a/lib/chef/scan_access_control.rb
+++ b/lib/chef/scan_access_control.rb
@@ -1,6 +1,6 @@
#--
# Author:: Daniel DeLeo (<dan@opscode.com>)
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -128,11 +128,11 @@ class Chef
def stat
@stat ||= if @new_resource.instance_of?(Chef::Resource::Link)
- ::File.lstat(@new_resource.path)
- else
- realpath = ::File.realpath(@new_resource.path)
- ::File.stat(realpath)
- end
+ ::File.lstat(@new_resource.path)
+ else
+ realpath = ::File.realpath(@new_resource.path)
+ ::File.stat(realpath)
+ end
end
end
end
diff --git a/lib/chef/shell/ext.rb b/lib/chef/shell/ext.rb
index ae013de76b..dd1d0195c7 100644
--- a/lib/chef/shell/ext.rb
+++ b/lib/chef/shell/ext.rb
@@ -47,10 +47,10 @@ module Shell
unless jobs.respond_to?(:session_select)
def jobs.select_shell_session(target_context)
session = if target_context.kind_of?(Class)
- select_session_by_context { |main| main.kind_of?(target_context) }
- else
- select_session_by_context { |main| main.equal?(target_context) }
- end
+ select_session_by_context { |main| main.kind_of?(target_context) }
+ else
+ select_session_by_context { |main| main.equal?(target_context) }
+ end
Array(session.first)[1]
end
end
@@ -196,7 +196,7 @@ module Shell
chef-shell commands. When called with an argument COMMAND, +help+
prints a detailed explanation of the command if available, or the
description if no explanation is available.
-E
+ E
def help(commmand=nil)
if commmand
explain_command(commmand)
@@ -210,9 +210,9 @@ E
desc "prints information about chef"
def version
puts "This is the chef-shell.\n" +
- " Chef Version: #{::Chef::VERSION}\n" +
- " http://www.chef.io/\n" +
- " http://docs.chef.io/"
+ " Chef Version: #{::Chef::VERSION}\n" +
+ " http://www.chef.io/\n" +
+ " http://docs.chef.io/"
:ucanhaz_automation
end
alias :shell :version
@@ -240,9 +240,9 @@ E
desc "returns an object to control a paused chef run"
subcommands :resume => "resume the chef run",
- :step => "run only the next resource",
- :skip_back => "move back in the run list",
- :skip_forward => "move forward in the run list"
+ :step => "run only the next resource",
+ :skip_back => "move back in the run list",
+ :skip_forward => "move forward in the run list"
def chef_run
Shell.session.resource_collection.iterator
end
@@ -314,7 +314,7 @@ E
1. Looks for an EDITOR set by Shell.editor = "EDITOR"
2. Looks for an EDITOR configured in your chef-shell config file
3. Uses the value of the EDITOR environment variable
-E
+ E
def edit(object)
unless Shell.editor
puts "Please set your editor with Shell.editor = \"vim|emacs|mate|ed\""
@@ -392,19 +392,19 @@ E
end
This will strip the admin privileges from any client named after borat.
-E
+ E
subcommands :all => "list all api clients",
- :show => "load an api client by name",
- :search => "search for API clients",
- :transform => "edit all api clients via a code block and save them"
+ :show => "load an api client by name",
+ :search => "search for API clients",
+ :transform => "edit all api clients via a code block and save them"
def clients
@clients ||= Shell::ModelWrapper.new(Chef::ApiClient, :client)
end
desc "Find and edit cookbooks"
subcommands :all => "list all cookbooks",
- :show => "load a cookbook by name",
- :transform => "edit all cookbooks via a code block and save them"
+ :show => "load a cookbook by name",
+ :transform => "edit all cookbooks via a code block and save them"
def cookbooks
@cookbooks ||= Shell::ModelWrapper.new(Chef::CookbookVersion)
end
@@ -454,11 +454,11 @@ E
end
This will assign the attribute to every node with a FQDN matching the regex.
-E
+ E
subcommands :all => "list all nodes",
- :show => "load a node by name",
- :search => "search for nodes",
- :transform => "edit all nodes via a code block and save them"
+ :show => "load a node by name",
+ :search => "search for nodes",
+ :transform => "edit all nodes via a code block and save them"
def nodes
@nodes ||= Shell::ModelWrapper.new(Chef::Node)
end
@@ -476,11 +476,11 @@ E
## SEE ALSO ##
See the help for +nodes+ for more information about the subcommands.
-E
+ E
subcommands :all => "list all roles",
- :show => "load a role by name",
- :search => "search for roles",
- :transform => "edit all roles via a code block and save them"
+ :show => "load a role by name",
+ :search => "search for roles",
+ :transform => "edit all roles via a code block and save them"
def roles
@roles ||= Shell::ModelWrapper.new(Chef::Role)
end
@@ -502,11 +502,11 @@ E
## SEE ALSO ##
See the help for +nodes+ for more information about the subcommands.
-E
+ E
subcommands :all => "list all items in the data bag",
- :show => "load a data bag item by id",
- :search => "search for items in the data bag",
- :transform => "edit all items via a code block and save them"
+ :show => "load a data bag item by id",
+ :search => "search for items in the data bag",
+ :transform => "edit all items via a code block and save them"
def databags(databag_name)
@named_databags_wrappers ||= {}
@named_databags_wrappers[databag_name] ||= Shell::NamedDataBagWrapper.new(databag_name)
@@ -525,11 +525,11 @@ E
## SEE ALSO ##
See the help for +nodes+ for more information about the subcommands.
-E
+ E
subcommands :all => "list all environments",
- :show => "load an environment by name",
- :search => "search for environments",
- :transform => "edit all environments via a code block and save them"
+ :show => "load an environment by name",
+ :search => "search for environments",
+ :transform => "edit all environments via a code block and save them"
def environments
@environments ||= Shell::ModelWrapper.new(Chef::Environment)
end
diff --git a/lib/chef/user.rb b/lib/chef/user.rb
index 31ebeda86f..1bcef448ff 100644
--- a/lib/chef/user.rb
+++ b/lib/chef/user.rb
@@ -1,6 +1,6 @@
#
# Author:: Steven Danna (steve@opscode.com)
-# Copyright:: Copyright 2012 Opscode, Inc.
+# Copyright:: Copyright 2012-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -135,7 +135,7 @@ class Chef
def inspect
"Chef::User name:'#{name}' admin:'#{admin.inspect}'" +
- "public_key:'#{public_key}' private_key:#{private_key}"
+ "public_key:'#{public_key}' private_key:#{private_key}"
end
# Class Methods
@@ -161,10 +161,10 @@ class Chef
def self.list(inflate=false)
response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "0"}).get('users')
users = if response.is_a?(Array)
- transform_ohc_list_response(response) # OHC/OPC
- else
- response # OSC
- end
+ transform_ohc_list_response(response) # OHC/OPC
+ else
+ response # OSC
+ end
if inflate
users.inject({}) do |user_map, (name, _url)|
user_map[name] = Chef::User.load(name)
diff --git a/lib/chef/win32/api/net.rb b/lib/chef/win32/api/net.rb
index b173987a05..7a578a3833 100644
--- a/lib/chef/win32/api/net.rb
+++ b/lib/chef/win32/api/net.rb
@@ -63,21 +63,21 @@ class Chef
module StructHelpers
def set(key, val)
val = if val.is_a? String
- encoded = if val.encoding == Encoding::UTF_16LE
- val
- else
- val.to_wstring
- end
- FFI::MemoryPointer.from_string(encoded)
- else
- val
- end
+ encoded = if val.encoding == Encoding::UTF_16LE
+ val
+ else
+ val.to_wstring
+ end
+ FFI::MemoryPointer.from_string(encoded)
+ else
+ val
+ end
self[key] = val
end
def get(key)
if respond_to? key
- send(key)
+ send(key)
else
val = self[key]
if val.is_a? FFI::Pointer
@@ -170,153 +170,153 @@ class Chef
end
-#NET_API_STATUS NetLocalGroupAdd(
- #_In_ LPCWSTR servername,
- #_In_ DWORD level,
- #_In_ LPBYTE buf,
- #_Out_ LPDWORD parm_err
-#);
+ #NET_API_STATUS NetLocalGroupAdd(
+ #_In_ LPCWSTR servername,
+ #_In_ DWORD level,
+ #_In_ LPBYTE buf,
+ #_Out_ LPDWORD parm_err
+ #);
safe_attach_function :NetLocalGroupAdd, [
:LPCWSTR, :DWORD, :LPBYTE, :LPDWORD
], :DWORD
-#NET_API_STATUS NetLocalGroupDel(
- #_In_ LPCWSTR servername,
- #_In_ LPCWSTR groupname
-#);
+ #NET_API_STATUS NetLocalGroupDel(
+ #_In_ LPCWSTR servername,
+ #_In_ LPCWSTR groupname
+ #);
safe_attach_function :NetLocalGroupDel, [:LPCWSTR, :LPCWSTR], :DWORD
-#NET_API_STATUS NetLocalGroupGetMembers(
- #_In_ LPCWSTR servername,
- #_In_ LPCWSTR localgroupname,
- #_In_ DWORD level,
- #_Out_ LPBYTE *bufptr,
- #_In_ DWORD prefmaxlen,
- #_Out_ LPDWORD entriesread,
- #_Out_ LPDWORD totalentries,
- #_Inout_ PDWORD_PTR resumehandle
-#);
+ #NET_API_STATUS NetLocalGroupGetMembers(
+ #_In_ LPCWSTR servername,
+ #_In_ LPCWSTR localgroupname,
+ #_In_ DWORD level,
+ #_Out_ LPBYTE *bufptr,
+ #_In_ DWORD prefmaxlen,
+ #_Out_ LPDWORD entriesread,
+ #_Out_ LPDWORD totalentries,
+ #_Inout_ PDWORD_PTR resumehandle
+ #);
safe_attach_function :NetLocalGroupGetMembers, [
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD,
:LPDWORD, :LPDWORD, :PDWORD_PTR
], :DWORD
-# NET_API_STATUS NetUserEnum(
-# _In_ LPCWSTR servername,
-# _In_ DWORD level,
-# _In_ DWORD filter,
-# _Out_ LPBYTE *bufptr,
-# _In_ DWORD prefmaxlen,
-# _Out_ LPDWORD entriesread,
-# _Out_ LPDWORD totalentries,
-# _Inout_ LPDWORD resume_handle
-# );
+ # NET_API_STATUS NetUserEnum(
+ # _In_ LPCWSTR servername,
+ # _In_ DWORD level,
+ # _In_ DWORD filter,
+ # _Out_ LPBYTE *bufptr,
+ # _In_ DWORD prefmaxlen,
+ # _Out_ LPDWORD entriesread,
+ # _Out_ LPDWORD totalentries,
+ # _Inout_ LPDWORD resume_handle
+ # );
safe_attach_function :NetUserEnum, [
:LPCWSTR, :DWORD, :DWORD, :LPBYTE,
:DWORD, :LPDWORD, :LPDWORD, :LPDWORD
], :DWORD
-# NET_API_STATUS NetApiBufferFree(
-# _In_ LPVOID Buffer
-# );
+ # NET_API_STATUS NetApiBufferFree(
+ # _In_ LPVOID Buffer
+ # );
safe_attach_function :NetApiBufferFree, [:LPVOID], :DWORD
-#NET_API_STATUS NetUserAdd(
- #_In_ LMSTR servername,
- #_In_ DWORD level,
- #_In_ LPBYTE buf,
- #_Out_ LPDWORD parm_err
-#);
+ #NET_API_STATUS NetUserAdd(
+ #_In_ LMSTR servername,
+ #_In_ DWORD level,
+ #_In_ LPBYTE buf,
+ #_Out_ LPDWORD parm_err
+ #);
safe_attach_function :NetUserAdd, [
:LMSTR, :DWORD, :LPBYTE, :LPDWORD
], :DWORD
-#NET_API_STATUS NetLocalGroupAddMembers(
-# _In_ LPCWSTR servername,
-# _In_ LPCWSTR groupname,
-# _In_ DWORD level,
-# _In_ LPBYTE buf,
-# _In_ DWORD totalentries
-#);
+ #NET_API_STATUS NetLocalGroupAddMembers(
+ # _In_ LPCWSTR servername,
+ # _In_ LPCWSTR groupname,
+ # _In_ DWORD level,
+ # _In_ LPBYTE buf,
+ # _In_ DWORD totalentries
+ #);
safe_attach_function :NetLocalGroupAddMembers, [
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
], :DWORD
-#NET_API_STATUS NetLocalGroupSetMembers(
-# _In_ LPCWSTR servername,
-# _In_ LPCWSTR groupname,
-# _In_ DWORD level,
-# _In_ LPBYTE buf,
-# _In_ DWORD totalentries
-#);
+ #NET_API_STATUS NetLocalGroupSetMembers(
+ # _In_ LPCWSTR servername,
+ # _In_ LPCWSTR groupname,
+ # _In_ DWORD level,
+ # _In_ LPBYTE buf,
+ # _In_ DWORD totalentries
+ #);
safe_attach_function :NetLocalGroupSetMembers, [
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
], :DWORD
-#NET_API_STATUS NetLocalGroupDelMembers(
-# _In_ LPCWSTR servername,
-# _In_ LPCWSTR groupname,
-# _In_ DWORD level,
-# _In_ LPBYTE buf,
-# _In_ DWORD totalentries
-#);
+ #NET_API_STATUS NetLocalGroupDelMembers(
+ # _In_ LPCWSTR servername,
+ # _In_ LPCWSTR groupname,
+ # _In_ DWORD level,
+ # _In_ LPBYTE buf,
+ # _In_ DWORD totalentries
+ #);
safe_attach_function :NetLocalGroupDelMembers, [
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
], :DWORD
-#NET_API_STATUS NetUserGetInfo(
-# _In_ LPCWSTR servername,
-# _In_ LPCWSTR username,
-# _In_ DWORD level,
-# _Out_ LPBYTE *bufptr
-#);
+ #NET_API_STATUS NetUserGetInfo(
+ # _In_ LPCWSTR servername,
+ # _In_ LPCWSTR username,
+ # _In_ DWORD level,
+ # _Out_ LPBYTE *bufptr
+ #);
safe_attach_function :NetUserGetInfo, [
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE
], :DWORD
-#NET_API_STATUS NetApiBufferFree(
-# _In_ LPVOID Buffer
-#);
+ #NET_API_STATUS NetApiBufferFree(
+ # _In_ LPVOID Buffer
+ #);
safe_attach_function :NetApiBufferFree, [:LPVOID], :DWORD
-#NET_API_STATUS NetUserSetInfo(
-# _In_ LPCWSTR servername,
-# _In_ LPCWSTR username,
-# _In_ DWORD level,
-# _In_ LPBYTE buf,
-# _Out_ LPDWORD parm_err
-#);
+ #NET_API_STATUS NetUserSetInfo(
+ # _In_ LPCWSTR servername,
+ # _In_ LPCWSTR username,
+ # _In_ DWORD level,
+ # _In_ LPBYTE buf,
+ # _Out_ LPDWORD parm_err
+ #);
safe_attach_function :NetUserSetInfo, [
:LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :LPDWORD
], :DWORD
-#NET_API_STATUS NetUserDel(
-# _In_ LPCWSTR servername,
-# _In_ LPCWSTR username
-#);
+ #NET_API_STATUS NetUserDel(
+ # _In_ LPCWSTR servername,
+ # _In_ LPCWSTR username
+ #);
safe_attach_function :NetUserDel, [:LPCWSTR, :LPCWSTR], :DWORD
-#NET_API_STATUS NetUseDel(
- #_In_ LMSTR UncServerName,
- #_In_ LMSTR UseName,
- #_In_ DWORD ForceCond
-#);
+ #NET_API_STATUS NetUseDel(
+ #_In_ LMSTR UncServerName,
+ #_In_ LMSTR UseName,
+ #_In_ DWORD ForceCond
+ #);
safe_attach_function :NetUseDel, [:LMSTR, :LMSTR, :DWORD], :DWORD
-#NET_API_STATUS NetUseGetInfo(
- #_In_ LMSTR UncServerName,
- #_In_ LMSTR UseName,
- #_In_ DWORD Level,
- #_Out_ LPBYTE *BufPtr
-#);
+ #NET_API_STATUS NetUseGetInfo(
+ #_In_ LMSTR UncServerName,
+ #_In_ LMSTR UseName,
+ #_In_ DWORD Level,
+ #_Out_ LPBYTE *BufPtr
+ #);
safe_attach_function :NetUseGetInfo, [:LMSTR, :LMSTR, :DWORD, :pointer], :DWORD
-#NET_API_STATUS NetUseAdd(
- #_In_ LMSTR UncServerName,
- #_In_ DWORD Level,
- #_In_ LPBYTE Buf,
- #_Out_ LPDWORD ParmError
-#);
+ #NET_API_STATUS NetUseAdd(
+ #_In_ LMSTR UncServerName,
+ #_In_ DWORD Level,
+ #_In_ LPBYTE Buf,
+ #_Out_ LPDWORD ParmError
+ #);
safe_attach_function :NetUseAdd, [:LMSTR, :DWORD, :LPBYTE, :LPDWORD], :DWORD
end
end
diff --git a/lib/chef/win32/net.rb b/lib/chef/win32/net.rb
index 59f29c4d1b..c0cf564621 100644
--- a/lib/chef/win32/net.rb
+++ b/lib/chef/win32/net.rb
@@ -71,33 +71,33 @@ class Chef
def self.net_api_error!(code)
msg = case code
- when NERR_InvalidComputer
- "The user does not have access to the requested information."
- when NERR_NotPrimary
- "The operation is allowed only on the primary domain controller of the domain."
- when NERR_SpeGroupOp
- "This operation is not allowed on this special group."
- when NERR_LastAdmin
- "This operation is not allowed on the last administrative account."
- when NERR_BadUsername
- "The user name or group name parameter is invalid."
- when NERR_BadPassword
- "The password parameter is invalid."
- when NERR_UserNotFound
- raise Chef::Exceptions::UserIDNotFound, code
- when NERR_PasswordTooShort
- <<END
+ when NERR_InvalidComputer
+ "The user does not have access to the requested information."
+ when NERR_NotPrimary
+ "The operation is allowed only on the primary domain controller of the domain."
+ when NERR_SpeGroupOp
+ "This operation is not allowed on this special group."
+ when NERR_LastAdmin
+ "This operation is not allowed on the last administrative account."
+ when NERR_BadUsername
+ "The user name or group name parameter is invalid."
+ when NERR_BadPassword
+ "The password parameter is invalid."
+ when NERR_UserNotFound
+ raise Chef::Exceptions::UserIDNotFound, code
+ when NERR_PasswordTooShort
+ <<END
The password is shorter than required. (The password could also be too
long, be too recent in its change history, not have enough unique characters,
or not meet another password policy requirement.)
END
- when NERR_GroupNotFound
- "The group name could not be found."
- when ERROR_ACCESS_DENIED
- "The user does not have access to the requested information."
- else
- "Received unknown error code (#{code})"
- end
+ when NERR_GroupNotFound
+ "The group name could not be found."
+ when ERROR_ACCESS_DENIED
+ "The user does not have access to the requested information."
+ else
+ "Received unknown error code (#{code})"
+ end
raise Chef::Exceptions::Win32NetAPIError.new(msg, code)
end
@@ -145,7 +145,7 @@ END
nread = entries_read_ptr.read_long
nread.times do |i|
member = LOCALGROUP_MEMBERS_INFO_0.new(buf.read_pointer +
- (i * LOCALGROUP_MEMBERS_INFO_0.size))
+ (i * LOCALGROUP_MEMBERS_INFO_0.size))
member_sid = Chef::ReservedNames::Win32::Security::SID.new(member[:lgrmi0_sid])
group_members << member_sid.to_s
end
diff --git a/spec/functional/application_spec.rb b/spec/functional/application_spec.rb
index fe656dca60..4d24549696 100644
--- a/spec/functional/application_spec.rb
+++ b/spec/functional/application_spec.rb
@@ -47,10 +47,10 @@ describe Chef::Application do
it "saves built proxy to ENV which shell_out can use" do
so = if windows?
- shell_out("echo %http_proxy%")
- else
- shell_out("echo $http_proxy")
- end
+ shell_out("echo %http_proxy%")
+ else
+ shell_out("echo $http_proxy")
+ end
expect(so.stdout.chomp).to eq("http://proxy.example.org:8080")
end
diff --git a/spec/functional/mixin/shell_out_spec.rb b/spec/functional/mixin/shell_out_spec.rb
index 35e5b30eae..8f8b54414a 100644
--- a/spec/functional/mixin/shell_out_spec.rb
+++ b/spec/functional/mixin/shell_out_spec.rb
@@ -24,10 +24,10 @@ describe Chef::Mixin::ShellOut do
describe "when environment['LC_ALL'] is not set" do
it "should use the default shell_out setting" do
cmd = if windows?
- shell_out_with_systems_locale('echo %LC_ALL%')
- else
- shell_out_with_systems_locale('echo $LC_ALL')
- end
+ shell_out_with_systems_locale('echo %LC_ALL%')
+ else
+ shell_out_with_systems_locale('echo $LC_ALL')
+ end
expect(cmd.stdout.chomp).to match_environment_variable('LC_ALL')
end
@@ -36,10 +36,10 @@ describe Chef::Mixin::ShellOut do
describe "when environment['LC_ALL'] is set" do
it "should use the option's setting" do
cmd = if windows?
- shell_out_with_systems_locale('echo %LC_ALL%', :environment => {'LC_ALL' => 'POSIX'})
- else
- shell_out_with_systems_locale('echo $LC_ALL', :environment => {'LC_ALL' => 'POSIX'})
- end
+ shell_out_with_systems_locale('echo %LC_ALL%', :environment => {'LC_ALL' => 'POSIX'})
+ else
+ shell_out_with_systems_locale('echo $LC_ALL', :environment => {'LC_ALL' => 'POSIX'})
+ end
expect(cmd.stdout.chomp).to eq 'POSIX'
end
diff --git a/spec/functional/resource/file_spec.rb b/spec/functional/resource/file_spec.rb
index 9e30e62111..861bc65363 100644
--- a/spec/functional/resource/file_spec.rb
+++ b/spec/functional/resource/file_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Seth Chisamore (<schisamo@opscode.com>)
-# Copyright:: Copyright (c) 2011 Opscode, Inc.
+# Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,11 +31,11 @@ describe Chef::Resource::File do
run_context = Chef::RunContext.new(node, {}, events)
use_path = if opts[:use_relative_path]
- Dir.chdir(Dir.tmpdir)
- File.basename(path)
- else
- path
- end
+ Dir.chdir(Dir.tmpdir)
+ File.basename(path)
+ else
+ path
+ end
Chef::Resource::File.new(use_path, run_context)
end
diff --git a/spec/support/shared/context/win32.rb b/spec/support/shared/context/win32.rb
index 3dbe876114..60ed92ca1d 100644
--- a/spec/support/shared/context/win32.rb
+++ b/spec/support/shared/context/win32.rb
@@ -18,12 +18,12 @@
RSpec.shared_context "Win32" do
before(:all) do
@original_win32 = if defined?(Win32)
- win32 = Object.send(:const_get, 'Win32')
- Object.send(:remove_const, 'Win32')
- win32
- else
- nil
- end
+ win32 = Object.send(:const_get, 'Win32')
+ Object.send(:remove_const, 'Win32')
+ win32
+ else
+ nil
+ end
Win32 = Module.new
end
diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb
index 8894e86240..0fb25176f9 100644
--- a/spec/unit/application/knife_spec.rb
+++ b/spec/unit/application/knife_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: AJ Christensen (<aj@junglist.gen.nz>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -104,10 +104,10 @@ describe Chef::Application::Knife do
it "does not expand a full path" do
full_path = if windows?
- 'C:/chef/client.pem'
- else
- '/etc/chef/client.pem'
- end
+ 'C:/chef/client.pem'
+ else
+ '/etc/chef/client.pem'
+ end
with_argv(*%W{noop knife command -k #{full_path}}) do
expect(@knife).to receive(:exit).with(0)
@knife.run
diff --git a/spec/unit/knife/cookbook_site_install_spec.rb b/spec/unit/knife/cookbook_site_install_spec.rb
index 07b268bb64..9779de4a64 100644
--- a/spec/unit/knife/cookbook_site_install_spec.rb
+++ b/spec/unit/knife/cookbook_site_install_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Steven Danna (<steve@opscode.com>)
-# Copyright:: Copyright (c) 2011 Opscode, Inc.
+# Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,11 +26,13 @@ describe Chef::Knife::CookbookSiteInstall do
let(:repo) { double(:sanity_check => true, :reset_to_default_state => true,
:prepare_to_import => true, :finalize_updates_to => true,
:merge_updates_from => true) }
- let(:install_path) { if Chef::Platform.windows?
- 'C:/tmp/chef'
- else
- '/var/tmp/chef'
- end }
+ let(:install_path) {
+ if Chef::Platform.windows?
+ 'C:/tmp/chef'
+ else
+ '/var/tmp/chef'
+ end
+ }
before(:each) do
require 'chef/knife/core/cookbook_scm_repo'
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb
index f790bdb1ce..5e4d8a6224 100644
--- a/spec/unit/provider/package/rubygems_spec.rb
+++ b/spec/unit/provider/package/rubygems_spec.rb
@@ -223,10 +223,10 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do
it "determines the installed versions of gems from the source index (part2: the unmockening)" do
allow($stdout).to receive(:write)
path_to_gem = if windows?
- `where gem`.split[1]
- else
- `which gem`.strip
- end
+ `where gem`.split[1]
+ else
+ `which gem`.strip
+ end
skip("cant find your gem executable") if path_to_gem.empty?
gem_env = Chef::Provider::Package::Rubygems::AlternateGemEnvironment.new(path_to_gem)
expected = ['rspec-core', Gem::Version.new(RSpec::Core::Version::STRING)]
@@ -261,7 +261,7 @@ RubyGems Environment:
- REMOTE SOURCES:
- https://rubygems.org/
- http://gems.github.com/
-JRUBY_GEM_ENV
+ JRUBY_GEM_ENV
expect(@gem_env).to receive(:shell_out!).with('/usr/weird/bin/gem env').and_return(double('jruby_gem_env', :stdout => gem_env_out))
expected = ['ruby', Gem::Platform.new('universal-java-1.6')]
expect(@gem_env.gem_platforms).to eq(expected)
@@ -303,7 +303,7 @@ RubyGems Environment:
- REMOTE SOURCES:
- https://rubygems.org/
- http://gems.github.com/
-RBX_GEM_ENV
+ RBX_GEM_ENV
expect(@gem_env).to receive(:shell_out!).with('/usr/weird/bin/gem env').and_return(double('rbx_gem_env', :stdout => gem_env_out))
expect(@gem_env.gem_platforms).to eq(Gem.platforms)
expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache['/usr/weird/bin/gem']).to eq(Gem.platforms)
@@ -459,8 +459,8 @@ describe Chef::Provider::Package::Rubygems do
@provider.current_resource.version('0.0.1')
version = Gem::Version.new(@spec_version)
expect(@provider.gem_env).to receive(:candidate_version_from_remote).
- with(Gem::Dependency.new('rspec-core', @spec_version), "http://mygems.example.com").
- and_return(version)
+ with(Gem::Dependency.new('rspec-core', @spec_version), "http://mygems.example.com").
+ and_return(version)
expect(@provider.candidate_version).to eq(@spec_version)
end