summaryrefslogtreecommitdiff
path: root/lib/chef/mixin
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/mixin')
-rw-r--r--lib/chef/mixin/command.rb8
-rw-r--r--lib/chef/mixin/command/unix.rb8
-rw-r--r--lib/chef/mixin/command/windows.rb5
-rw-r--r--lib/chef/mixin/convert_to_class_name.rb8
-rw-r--r--lib/chef/mixin/deprecation.rb45
-rw-r--r--lib/chef/mixin/descendants_tracker.rb3
-rw-r--r--lib/chef/mixin/get_source_from_package.rb1
-rw-r--r--lib/chef/mixin/language_include_attribute.rb1
-rw-r--r--lib/chef/mixin/language_include_recipe.rb1
-rw-r--r--lib/chef/mixin/params_validate.rb7
-rw-r--r--lib/chef/mixin/path_sanity.rb2
-rw-r--r--lib/chef/mixin/powershell_type_coercions.rb18
-rw-r--r--lib/chef/mixin/properties.rb10
-rw-r--r--lib/chef/mixin/provides.rb2
-rw-r--r--lib/chef/mixin/securable.rb31
-rw-r--r--lib/chef/mixin/template.rb9
-rw-r--r--lib/chef/mixin/uris.rb1
-rw-r--r--lib/chef/mixin/why_run.rb5
-rw-r--r--lib/chef/mixin/windows_architecture_helper.rb1
-rw-r--r--lib/chef/mixin/windows_env_helper.rb1
-rw-r--r--lib/chef/mixin/xml_escape.rb10
21 files changed, 81 insertions, 96 deletions
diff --git a/lib/chef/mixin/command.rb b/lib/chef/mixin/command.rb
index 8e0b105274..257ed11221 100644
--- a/lib/chef/mixin/command.rb
+++ b/lib/chef/mixin/command.rb
@@ -75,7 +75,7 @@ class Chef
#
# === Returns
# Returns the exit status of args[:command]
- def run_command(args={})
+ def run_command(args = {})
status, stdout, stderr = run_command_and_return_stdout_stderr(args)
status
@@ -84,7 +84,7 @@ class Chef
# works same as above, except that it returns stdout and stderr
# requirement => platforms like solaris 9,10 has weird issues where
# even in command failure the exit code is zero, so we need to lookup stderr.
- def run_command_and_return_stdout_stderr(args={})
+ def run_command_and_return_stdout_stderr(args = {})
command_output = ""
args[:ignore_failure] ||= false
@@ -143,7 +143,7 @@ class Chef
return status, stdout_string, stderr_string
end
- def handle_command_failures(status, command_output, opts={})
+ def handle_command_failures(status, command_output, opts = {})
return if opts[:ignore_failure]
opts[:returns] ||= 0
return if Array(opts[:returns]).include?(status.exitstatus)
@@ -165,7 +165,7 @@ class Chef
#
# === Returns
# Returns the result of #run_command
- def run_command_with_systems_locale(args={})
+ def run_command_with_systems_locale(args = {})
args[:environment] ||= {}
args[:environment]["LC_ALL"] = ENV["LC_ALL"]
run_command args
diff --git a/lib/chef/mixin/command/unix.rb b/lib/chef/mixin/command/unix.rb
index 3d97b961aa..d930ee33e6 100644
--- a/lib/chef/mixin/command/unix.rb
+++ b/lib/chef/mixin/command/unix.rb
@@ -27,7 +27,7 @@ class Chef
# The original appears in external/open4.rb in its unmodified form.
#
# Thanks Ara!
- def popen4(cmd, args={}, &b)
+ def popen4(cmd, args = {}, &b)
# Ruby 1.8 suffers from intermittent segfaults believed to be due to GC while IO.select
# See CHEF-2916 / CHEF-1305
GC.disable
@@ -89,7 +89,7 @@ class Chef
Process.uid = args[:user]
end
- args[:environment].each do |key,value|
+ args[:environment].each do |key, value|
ENV[key] = value
end
@@ -116,7 +116,7 @@ class Chef
$VERBOSE = verbose
end
- [pw.first, pr.last, pe.last, ps.last].each{|fd| fd.close}
+ [pw.first, pr.last, pe.last, ps.last].each { |fd| fd.close }
begin
e = Marshal.load ps.first
@@ -205,7 +205,7 @@ class Chef
results.last
end
ensure
- pi.each{|fd| fd.close unless fd.closed?}
+ pi.each { |fd| fd.close unless fd.closed? }
end
else
[cid, pw.last, pr.first, pe.first]
diff --git a/lib/chef/mixin/command/windows.rb b/lib/chef/mixin/command/windows.rb
index 5580aaec59..fd45ab0467 100644
--- a/lib/chef/mixin/command/windows.rb
+++ b/lib/chef/mixin/command/windows.rb
@@ -24,14 +24,13 @@ class Chef
module Mixin
module Command
module Windows
- def popen4(cmd, args={}, &b)
-
+ def popen4(cmd, args = {}, &b)
# By default, we are waiting before we yield the block.
args[:waitlast] ||= false
#XXX :user, :group, :environment support?
- Open3.popen3(cmd) do |stdin,stdout,stderr,cid|
+ Open3.popen3(cmd) do |stdin, stdout, stderr, cid|
if b
if args[:waitlast]
b[cid, stdin, stdout, stderr]
diff --git a/lib/chef/mixin/convert_to_class_name.rb b/lib/chef/mixin/convert_to_class_name.rb
index 5029474de9..d6bd8a4ea7 100644
--- a/lib/chef/mixin/convert_to_class_name.rb
+++ b/lib/chef/mixin/convert_to_class_name.rb
@@ -40,10 +40,10 @@ class Chef
rname
end
- def convert_to_snake_case(str, namespace=nil)
+ 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]/) { |s| "_" + s }
str.downcase!
str.sub!(/^\_/, "")
str
@@ -51,8 +51,8 @@ class Chef
def normalize_snake_case_name(str)
str = str.dup
- str.gsub!(/[^A-Za-z0-9_]/,"_")
- str.gsub!(/^(_+)?/,"")
+ str.gsub!(/[^A-Za-z0-9_]/, "_")
+ str.gsub!(/^(_+)?/, "")
str
end
diff --git a/lib/chef/mixin/deprecation.rb b/lib/chef/mixin/deprecation.rb
index 04c40dcf29..0f059a215f 100644
--- a/lib/chef/mixin/deprecation.rb
+++ b/lib/chef/mixin/deprecation.rb
@@ -19,10 +19,9 @@
class Chef
module Mixin
-
- def self.deprecated_constants
- @deprecated_constants ||= {}
- end
+ def self.deprecated_constants
+ @deprecated_constants ||= {}
+ end
# Add a deprecated constant to the Chef::Mixin namespace.
# === Arguments
@@ -33,34 +32,34 @@ class Chef
# deprecate_constant(:RecipeDefinitionDSLCore, Chef::DSL::Recipe, <<-EOM)
# Chef::Mixin::RecipeDefinitionDSLCore is deprecated, use Chef::DSL::Recipe instead.
# EOM
- def self.deprecate_constant(name, replacement, message)
- deprecated_constants[name] = {:replacement => replacement, :message => message}
- end
+ def self.deprecate_constant(name, replacement, message)
+ deprecated_constants[name] = { :replacement => replacement, :message => message }
+ end
# Const missing hook to look up deprecated constants defined with
# deprecate_constant. Emits a warning to the logger and returns the
# replacement constant. Will call super, most likely causing an exception
# for the missing constant, if +name+ is not found in the
# deprecated_constants collection.
- def self.const_missing(name)
- if new_const = deprecated_constants[name]
- Chef::Log.warn(new_const[:message])
- Chef::Log.warn("Called from: \n#{caller[0...3].map {|l| "\t#{l}"}.join("\n")}")
- new_const[:replacement]
- else
- super
- end
+ def self.const_missing(name)
+ if new_const = deprecated_constants[name]
+ Chef::Log.warn(new_const[:message])
+ Chef::Log.warn("Called from: \n#{caller[0...3].map { |l| "\t#{l}" }.join("\n")}")
+ new_const[:replacement]
+ else
+ super
end
+ end
module Deprecation
class DeprecatedObjectProxyBase
KEEPERS = %w{__id__ __send__ instance_eval == equal? initialize object_id}
- instance_methods.each { |method_name| undef_method(method_name) unless KEEPERS.include?(method_name.to_s)}
+ instance_methods.each { |method_name| undef_method(method_name) unless KEEPERS.include?(method_name.to_s) }
end
class DeprecatedInstanceVariable < DeprecatedObjectProxyBase
- def initialize(target, ivar_name, level=nil)
+ def initialize(target, ivar_name, level = nil)
@target, @ivar_name = target, ivar_name
@level ||= :warn
end
@@ -80,7 +79,7 @@ class Chef
called_from = called_from.flatten
log("Accessing #{@ivar_name} by the variable @#{@ivar_name} is deprecated. Support will be removed in a future release.")
log("Please update your cookbooks to use #{@ivar_name} in place of @#{@ivar_name}. Accessed from:")
- called_from.each {|l| log(l)}
+ called_from.each { |l| log(l) }
end
def log(msg)
@@ -91,7 +90,7 @@ class Chef
end
- def deprecated_ivar(obj, name, level=nil)
+ def deprecated_ivar(obj, name, level = nil)
DeprecatedInstanceVariable.new(obj, name, level)
end
@@ -100,22 +99,22 @@ class Chef
deprecated_attr_writer(name, alternative)
end
- def deprecated_attr_reader(name, alternative, level=:warn)
+ def deprecated_attr_reader(name, alternative, level = :warn)
define_method(name) do
Chef.log_deprecation("#{self.class}.#{name} is deprecated. Support will be removed in a future release.")
Chef.log_deprecation(alternative)
Chef.log_deprecation("Called from:")
- caller[0..3].each {|c| Chef.log_deprecation(c)}
+ caller[0..3].each { |c| Chef.log_deprecation(c) }
instance_variable_get("@#{name}")
end
end
- def deprecated_attr_writer(name, alternative, level=:warn)
+ def deprecated_attr_writer(name, alternative, level = :warn)
define_method("#{name}=") do |value|
Chef.log_deprecation("Writing to #{self.class}.#{name} with #{name}= is deprecated. Support will be removed in a future release.")
Chef.log_deprecation(alternative)
Chef.log_deprecation("Called from:")
- caller[0..3].each {|c| Chef.log_deprecation(c)}
+ caller[0..3].each { |c| Chef.log_deprecation(c) }
instance_variable_set("@#{name}", value)
end
end
diff --git a/lib/chef/mixin/descendants_tracker.rb b/lib/chef/mixin/descendants_tracker.rb
index e6c59d305e..b0f0ff2227 100644
--- a/lib/chef/mixin/descendants_tracker.rb
+++ b/lib/chef/mixin/descendants_tracker.rb
@@ -21,7 +21,6 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-
# This is lifted from rails activesupport (note the copyright above):
# https://github.com/rails/rails/blob/9f84e60ac9d7bf07d6ae1bc94f3941f5b8f1a228/activesupport/lib/active_support/descendants_tracker.rb
@@ -42,7 +41,7 @@ class Chef
end
def find_descendants_by_name(klass, name)
- descendants(klass).first {|c| c.name == name }
+ descendants(klass).first { |c| c.name == name }
end
# This is the only method that is not thread safe, but is only ever called
diff --git a/lib/chef/mixin/get_source_from_package.rb b/lib/chef/mixin/get_source_from_package.rb
index abab763436..555dd634f8 100644
--- a/lib/chef/mixin/get_source_from_package.rb
+++ b/lib/chef/mixin/get_source_from_package.rb
@@ -15,7 +15,6 @@
# limitations under the License.
#
-
#
# mixin to make this syntax work without specifying a source:
#
diff --git a/lib/chef/mixin/language_include_attribute.rb b/lib/chef/mixin/language_include_attribute.rb
index 39a04bb701..7cb66dc272 100644
--- a/lib/chef/mixin/language_include_attribute.rb
+++ b/lib/chef/mixin/language_include_attribute.rb
@@ -32,4 +32,3 @@ EOM
end
end
-
diff --git a/lib/chef/mixin/language_include_recipe.rb b/lib/chef/mixin/language_include_recipe.rb
index 9dd64673a1..97e384c7c4 100644
--- a/lib/chef/mixin/language_include_recipe.rb
+++ b/lib/chef/mixin/language_include_recipe.rb
@@ -29,4 +29,3 @@ EOM
end
end
-
diff --git a/lib/chef/mixin/params_validate.rb b/lib/chef/mixin/params_validate.rb
index a51b24df24..598c6c3c23 100644
--- a/lib/chef/mixin/params_validate.rb
+++ b/lib/chef/mixin/params_validate.rb
@@ -140,7 +140,7 @@ class Chef
end
# Raise an exception if the parameter is not found.
- def _pv_required(opts, key, is_required=true, explicitly_allows_nil=false)
+ def _pv_required(opts, key, is_required = true, explicitly_allows_nil = false)
if is_required
return true if opts.has_key?(key.to_s) && (explicitly_allows_nil || !opts[key.to_s].nil?)
return true if opts.has_key?(key.to_sym) && (explicitly_allows_nil || !opts[key.to_sym].nil?)
@@ -329,7 +329,7 @@ class Chef
# property :x, name_property: true
# ```
#
- def _pv_name_property(opts, key, is_name_property=true)
+ def _pv_name_property(opts, key, is_name_property = true)
if is_name_property
if opts[key].nil?
raise CannotValidateStaticallyError, "name_property cannot be evaluated without a resource." if self == Chef::Mixin::ParamsValidate
@@ -462,7 +462,6 @@ class Chef
# (which is the norm).
extend self
-
# Used by #set_or_return to avoid emitting a deprecation warning for
# "value nil" and to keep default stickiness working exactly the same
# @api private
@@ -476,7 +475,7 @@ class Chef
value
end
- def call(resource, value=NOT_PASSED)
+ def call(resource, value = NOT_PASSED)
# setting to nil does a get
if value.nil? && !explicitly_accepts_nil?(resource)
get(resource)
diff --git a/lib/chef/mixin/path_sanity.rb b/lib/chef/mixin/path_sanity.rb
index 6c1b26fabd..7078c585e0 100644
--- a/lib/chef/mixin/path_sanity.rb
+++ b/lib/chef/mixin/path_sanity.rb
@@ -20,7 +20,7 @@ class Chef
module Mixin
module PathSanity
- def enforce_path_sanity(env=ENV)
+ def enforce_path_sanity(env = ENV)
if Chef::Config[:enforce_path_sanity]
env["PATH"] = "" if env["PATH"].nil?
path_separator = Chef::Platform.windows? ? ";" : ":"
diff --git a/lib/chef/mixin/powershell_type_coercions.rb b/lib/chef/mixin/powershell_type_coercions.rb
index 60c04e85ae..381cbed637 100644
--- a/lib/chef/mixin/powershell_type_coercions.rb
+++ b/lib/chef/mixin/powershell_type_coercions.rb
@@ -23,14 +23,14 @@ class Chef
def type_coercions
@type_coercions ||= {
- Fixnum => { :type => lambda { |x| x.to_s }},
- Float => { :type => lambda { |x| x.to_s }},
- FalseClass => { :type => lambda { |x| "$false" }},
- TrueClass => { :type => lambda { |x| "$true" }},
- Hash => {:type => Proc.new { |x| translate_hash(x)}},
- Array => {:type => Proc.new { |x| translate_array(x)}},
- Chef::Node::ImmutableMash => {:type => Proc.new { |x| translate_hash(x)}},
- Chef::Node::ImmutableArray => {:type => Proc.new { |x| translate_array(x)}},
+ Fixnum => { :type => lambda { |x| x.to_s } },
+ Float => { :type => lambda { |x| x.to_s } },
+ FalseClass => { :type => lambda { |x| "$false" } },
+ TrueClass => { :type => lambda { |x| "$true" } },
+ Hash => { :type => Proc.new { |x| translate_hash(x) } },
+ Array => { :type => Proc.new { |x| translate_array(x) } },
+ Chef::Node::ImmutableMash => { :type => Proc.new { |x| translate_hash(x) } },
+ Chef::Node::ImmutableArray => { :type => Proc.new { |x| translate_array(x) } },
}
end
@@ -49,7 +49,7 @@ class Chef
private
def translate_hash(x)
- translated = x.inject([]) do |memo, (k,v)|
+ translated = x.inject([]) do |memo, (k, v)|
memo << "#{k}=#{translate_type(v)}"
end
"@{#{translated.join(';')}}"
diff --git a/lib/chef/mixin/properties.rb b/lib/chef/mixin/properties.rb
index af4e2c2c09..2e33d2d0e7 100644
--- a/lib/chef/mixin/properties.rb
+++ b/lib/chef/mixin/properties.rb
@@ -17,7 +17,7 @@ class Chef
#
# @return [Hash<Symbol,Property>] The list of property names and types.
#
- def properties(include_superclass=true)
+ def properties(include_superclass = true)
if include_superclass
result = {}
ancestors.reverse_each { |c| result.merge!(c.properties(false)) if c.respond_to?(:properties) }
@@ -92,10 +92,10 @@ class Chef
# @example With type and options
# property :x, String, default: 'hi'
#
- def property(name, type=NOT_PASSED, **options)
+ def property(name, type = NOT_PASSED, **options)
name = name.to_sym
- options.each { |k,v| options[k.to_sym] = v if k.is_a?(String) }
+ options.each { |k, v| options[k.to_sym] = v if k.is_a?(String) }
options[:instance_variable_name] = :"@#{name}" if !options.has_key?(:instance_variable_name)
options.merge!(name: name, declared_in: self)
@@ -200,7 +200,7 @@ class Chef
# If state_attrs *excludes* something which is currently desired state,
# mark it as desired_state: false.
- local_properties.each do |name,property|
+ local_properties.each do |name, property|
if property.desired_state? && !names.include?(name)
self.property name, desired_state: false
end
@@ -248,7 +248,7 @@ class Chef
# If identity_properties *excludes* something which is currently part of
# the identity, mark it as identity: false.
- properties.each do |name,property|
+ properties.each do |name, property|
if property.identity? && !names.include?(name)
self.property name, identity: false
diff --git a/lib/chef/mixin/provides.rb b/lib/chef/mixin/provides.rb
index 5885752752..34a078c010 100644
--- a/lib/chef/mixin/provides.rb
+++ b/lib/chef/mixin/provides.rb
@@ -7,7 +7,7 @@ class Chef
# TODO no longer needed, remove or deprecate?
include Chef::Mixin::DescendantsTracker
- def provides(short_name, opts={}, &block)
+ def provides(short_name, opts = {}, &block)
raise NotImplementedError, :provides
end
diff --git a/lib/chef/mixin/securable.rb b/lib/chef/mixin/securable.rb
index d83d009638..af3e10126b 100644
--- a/lib/chef/mixin/securable.rb
+++ b/lib/chef/mixin/securable.rb
@@ -20,7 +20,7 @@ class Chef
module Mixin
module Securable
- def owner(arg=nil)
+ def owner(arg = nil)
set_or_return(
:owner,
arg,
@@ -30,7 +30,7 @@ class Chef
alias :user :owner
- def group(arg=nil)
+ def group(arg = nil)
set_or_return(
:group,
arg,
@@ -38,28 +38,27 @@ class Chef
)
end
- def mode(arg=nil)
+ def mode(arg = nil)
set_or_return(
:mode,
arg,
:callbacks => {
"not in valid numeric range" => lambda { |m|
if m.kind_of?(String)
- m =~ /^0/ || m="0#{m}"
+ m =~ /^0/ || m = "0#{m}"
end
# Windows does not support the sticky or setuid bits
if Chef::Platform.windows?
- Integer(m)<=0777 && Integer(m)>=0
+ Integer(m) <= 0777 && Integer(m) >= 0
else
- Integer(m)<=07777 && Integer(m)>=0
+ Integer(m) <= 07777 && Integer(m) >= 0
end
}
},
)
end
-
#==WindowsMacros
# Defines methods for adding attributes to a chef resource to describe
# Windows file security metadata.
@@ -108,10 +107,9 @@ class Chef
# * `:one_level_deep` (optional): Boolean
#
def rights_attribute(name)
-
# equivalent to something like:
# def rights(permissions=nil, principals=nil, args_hash=nil)
- define_method(name) do |permissions=nil, principals=nil, args_hash=nil|
+ define_method(name) do |permissions = nil, principals = nil, args_hash = nil|
rights = self.instance_variable_get("@#{name}".to_sym)
unless permissions.nil?
input = {
@@ -120,17 +118,17 @@ class Chef
}
input.merge!(args_hash) unless args_hash.nil?
- validations = {:permissions => { :required => true },
- :principals => { :required => true, :kind_of => [String, Array] },
- :applies_to_children => { :equal_to => [ true, false, :containers_only, :objects_only ]},
- :applies_to_self => { :kind_of => [ TrueClass, FalseClass ] },
- :one_level_deep => { :kind_of => [ TrueClass, FalseClass ] },
+ validations = { :permissions => { :required => true },
+ :principals => { :required => true, :kind_of => [String, Array] },
+ :applies_to_children => { :equal_to => [ true, false, :containers_only, :objects_only ] },
+ :applies_to_self => { :kind_of => [ TrueClass, FalseClass ] },
+ :one_level_deep => { :kind_of => [ TrueClass, FalseClass ] },
}
validate(input, validations)
[ permissions ].flatten.each do |permission|
if permission.is_a?(Integer)
- if permission < 0 || permission > 1<<32
+ if permission < 0 || permission > 1 << 32
raise ArgumentError, "permissions flags must be positive and <= 32 bits (#{permission})"
end
elsif !([:full_control, :modify, :read_execute, :read, :write].include?(permission.to_sym))
@@ -169,8 +167,7 @@ class Chef
# including class
module WindowsSecurableAttributes
-
- def inherits(arg=nil)
+ def inherits(arg = nil)
set_or_return(
:inherits,
arg,
diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb
index be46f0cd2c..c423ccaa42 100644
--- a/lib/chef/mixin/template.rb
+++ b/lib/chef/mixin/template.rb
@@ -105,10 +105,9 @@ class Chef
def node
return @node if @node
raise "Could not find a value for node. If you are explicitly setting variables in a template, " +
- "include a node variable if you plan to use it."
+ "include a node variable if you plan to use it."
end
-
#
# Takes the name of the partial, plus a hash of options. Returns a
# string that contains the result of the evaluation of the partial.
@@ -177,7 +176,7 @@ class Chef
# this template.
if Chef::Platform.windows?
- output = output.gsub(/\r?\n/,"\r\n")
+ output = output.gsub(/\r?\n/, "\r\n")
end
output
@@ -225,7 +224,7 @@ class Chef
end
def line_number
- @line_number ||= $1.to_i if original_exception.backtrace.find {|line| line =~ /\(erubis\):(\d+)/ }
+ @line_number ||= $1.to_i if original_exception.backtrace.find { |line| line =~ /\(erubis\):(\d+)/ }
end
def source_location
@@ -246,7 +245,7 @@ class Chef
contextual_lines = lines[beginning_line, source_size]
output = []
contextual_lines.each_with_index do |line, index|
- line_number = (index+beginning_line+1).to_s.rjust(3)
+ line_number = (index + beginning_line + 1).to_s.rjust(3)
output << "#{line_number}: #{line}"
end
output.join("\n")
diff --git a/lib/chef/mixin/uris.rb b/lib/chef/mixin/uris.rb
index 5122177728..24e8a4f9ed 100644
--- a/lib/chef/mixin/uris.rb
+++ b/lib/chef/mixin/uris.rb
@@ -29,7 +29,6 @@ class Chef
!!(%r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ source)
end
-
def as_uri(source)
begin
URI.parse(source)
diff --git a/lib/chef/mixin/why_run.rb b/lib/chef/mixin/why_run.rb
index be9808b1fe..b2aa5949c0 100644
--- a/lib/chef/mixin/why_run.rb
+++ b/lib/chef/mixin/why_run.rb
@@ -222,7 +222,6 @@ class Chef
@assertion_failed
end
-
# Runs the assertion/assumption logic. Will raise an Exception of the
# type specified in #failure_message (or AssertionFailure by default)
# if the requirement is not met and Chef is not running in why run
@@ -247,7 +246,7 @@ class Chef
def initialize(resource, run_context)
@resource, @run_context = resource, run_context
- @assertions = Hash.new {|h,k| h[k] = [] }
+ @assertions = Hash.new { |h, k| h[k] = [] }
@blocked_actions = []
end
@@ -313,7 +312,7 @@ class Chef
def assert(*actions)
assertion = Assertion.new
yield assertion
- actions.each {|action| @assertions[action] << assertion }
+ actions.each { |action| @assertions[action] << assertion }
end
# Run the assertion and assumption logic.
diff --git a/lib/chef/mixin/windows_architecture_helper.rb b/lib/chef/mixin/windows_architecture_helper.rb
index edda6cf401..5f8d3e3729 100644
--- a/lib/chef/mixin/windows_architecture_helper.rb
+++ b/lib/chef/mixin/windows_architecture_helper.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require "chef/exceptions"
require "chef/platform/query_helpers"
require "chef/win32/process" if Chef::Platform.windows?
diff --git a/lib/chef/mixin/windows_env_helper.rb b/lib/chef/mixin/windows_env_helper.rb
index e46b40b240..b2e08edc08 100644
--- a/lib/chef/mixin/windows_env_helper.rb
+++ b/lib/chef/mixin/windows_env_helper.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
require "chef/exceptions"
require "chef/mixin/wide_string"
require "chef/platform/query_helpers"
diff --git a/lib/chef/mixin/xml_escape.rb b/lib/chef/mixin/xml_escape.rb
index a278c81554..afb0d09c2d 100644
--- a/lib/chef/mixin/xml_escape.rb
+++ b/lib/chef/mixin/xml_escape.rb
@@ -95,7 +95,7 @@ class Chef
PREDEFINED = {
38 => "&amp;", # ampersand
60 => "&lt;", # left angle bracket
- 62 => "&gt;" # right angle bracket
+ 62 => "&gt;" # right angle bracket
}
# http://www.w3.org/TR/REC-xml/#charsets
@@ -104,9 +104,9 @@ class Chef
def xml_escape(unescaped_str)
begin
- unescaped_str.unpack("U*").map {|char| xml_escape_char!(char)}.join
+ unescaped_str.unpack("U*").map { |char| xml_escape_char!(char) }.join
rescue
- unescaped_str.unpack("C*").map {|char| xml_escape_char!(char)}.join
+ unescaped_str.unpack("C*").map { |char| xml_escape_char!(char) }.join
end
end
@@ -114,8 +114,8 @@ class Chef
def xml_escape_char!(char)
char = CP1252[char] || char
- char = 42 unless VALID.detect {|range| range.include? char}
- char = PREDEFINED[char] || (char<128 ? char.chr : "&##{char};")
+ char = 42 unless VALID.detect { |range| range.include? char }
+ char = PREDEFINED[char] || (char < 128 ? char.chr : "&##{char};")
end
end