diff options
author | Seth Vargo <sethvargo@gmail.com> | 2013-09-24 17:38:44 -0400 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2013-09-26 11:13:59 -0700 |
commit | 6315871ae7deeead95d84d2487c54a03c47e318f (patch) | |
tree | a2bf980c434c657aa350c0d3fc4073652cdf43cf /lib/chef/mixin | |
parent | 61e98b94fb387353841d5b4575816a1d716cfbc9 (diff) | |
download | chef-6315871ae7deeead95d84d2487c54a03c47e318f.tar.gz |
Normalize whitespace on all files
Diffstat (limited to 'lib/chef/mixin')
-rw-r--r-- | lib/chef/mixin/checksum.rb | 4 | ||||
-rw-r--r-- | lib/chef/mixin/command.rb | 28 | ||||
-rw-r--r-- | lib/chef/mixin/convert_to_class_name.rb | 16 | ||||
-rw-r--r-- | lib/chef/mixin/create_path.rb | 18 | ||||
-rw-r--r-- | lib/chef/mixin/deep_merge.rb | 4 | ||||
-rw-r--r-- | lib/chef/mixin/from_file.rb | 12 | ||||
-rw-r--r-- | lib/chef/mixin/language_include_recipe.rb | 4 | ||||
-rw-r--r-- | lib/chef/mixin/params_validate.rb | 42 | ||||
-rw-r--r-- | lib/chef/mixin/why_run.rb | 30 | ||||
-rw-r--r-- | lib/chef/mixin/windows_architecture_helper.rb | 10 | ||||
-rw-r--r-- | lib/chef/mixin/xml_escape.rb | 20 |
11 files changed, 94 insertions, 94 deletions
diff --git a/lib/chef/mixin/checksum.rb b/lib/chef/mixin/checksum.rb index 8217296915..1d9c99ec7e 100644 --- a/lib/chef/mixin/checksum.rb +++ b/lib/chef/mixin/checksum.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/lib/chef/mixin/command.rb b/lib/chef/mixin/command.rb index 719151a6b6..2cc25e149e 100644 --- a/lib/chef/mixin/command.rb +++ b/lib/chef/mixin/command.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -41,23 +41,23 @@ class Chef # === Parameters # args<Hash>: A number of required and optional arguments - # command<String>, <Array>: A complete command with options to execute or a command and options as an Array + # command<String>, <Array>: A complete command with options to execute or a command and options as an Array # creates<String>: The absolute path to a file that prevents the command from running if it exists # cwd<String>: Working directory to execute command in, defaults to Dir.tmpdir # timeout<String>: How many seconds to wait for the command to execute before timing out # returns<String>: The single exit value command is expected to return, otherwise causes an exception # ignore_failure<Boolean>: Whether to raise an exception on failure, or just return the status # output_on_failure<Boolean>: Return output in raised exception regardless of Log.level - # + # # user<String>: The UID or user name of the user to execute the command as # group<String>: The GID or group name of the group to execute the command as # environment<Hash>: Pairs of environment variable names and their values to set before execution # # === 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 end @@ -77,7 +77,7 @@ class Chef return false end end - + status, stdout, stderr = output_of_command(args[:command], args) command_output << "STDOUT: #{stdout}" command_output << "STDERR: #{stderr}" @@ -89,16 +89,16 @@ class Chef def output_of_command(command, args) Chef::Log.debug("Executing #{command}") stderr_string, stdout_string, status = "", "", nil - + exec_processing_block = lambda do |pid, stdin, stdout, stderr| stdout_string, stderr_string = stdout.string.chomp, stderr.string.chomp end - + args[:cwd] ||= Dir.tmpdir unless ::File.directory?(args[:cwd]) raise Chef::Exceptions::Exec, "#{args[:cwd]} does not exist or is not a directory" end - + Dir.chdir(args[:cwd]) do if args[:timeout] begin @@ -112,17 +112,17 @@ class Chef else status = popen4(command, args, &exec_processing_block) end - + Chef::Log.debug("---- Begin output of #{command} ----") Chef::Log.debug("STDOUT: #{stdout_string}") Chef::Log.debug("STDERR: #{stderr_string}") Chef::Log.debug("---- End output of #{command} ----") Chef::Log.debug("Ran #{command} returned #{status.exitstatus}") end - + return status, stdout_string, stderr_string end - + def handle_command_failures(status, command_output, opts={}) unless opts[:ignore_failure] opts[:returns] ||= 0 @@ -138,7 +138,7 @@ class Chef end end end - + # Call #run_command but set LC_ALL to the system's current environment so it doesn't get changed to C. # # === Parameters diff --git a/lib/chef/mixin/convert_to_class_name.rb b/lib/chef/mixin/convert_to_class_name.rb index 7b4ec7ad3f..ece16990a1 100644 --- a/lib/chef/mixin/convert_to_class_name.rb +++ b/lib/chef/mixin/convert_to_class_name.rb @@ -7,9 +7,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,20 +27,20 @@ class Chef str.gsub!(/[^A-Za-z0-9_]/,'_') rname = nil regexp = %r{^(.+?)(_(.+))?$} - + mn = str.match(regexp) if mn rname = mn[1].capitalize while mn && mn[3] - mn = mn[3].match(regexp) + mn = mn[3].match(regexp) rname << mn[1].capitalize if mn end end rname end - + def convert_to_snake_case(str, namespace=nil) str = str.dup str.sub!(/^#{namespace}(\:\:)?/, '') if namespace @@ -49,17 +49,17 @@ class Chef str.sub!(/^\_/, "") str end - + def snake_case_basename(str) with_namespace = convert_to_snake_case(str) with_namespace.split("::").last.sub(/^_/, '') end - + def filename_to_qualified_string(base, filename) file_base = File.basename(filename, ".rb") base.to_s + (file_base == 'default' ? '' : "_#{file_base}") end - + end end end diff --git a/lib/chef/mixin/create_path.rb b/lib/chef/mixin/create_path.rb index 9b5dba14f2..9d1248e907 100644 --- a/lib/chef/mixin/create_path.rb +++ b/lib/chef/mixin/create_path.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,21 +18,21 @@ class Chef module Mixin module CreatePath - + # Creates a given path, including all directories that lead up to it. # Like mkdir_p, but without the leaking. # # === Parameters - # file_path<String, Array>:: A string that represents the path to create, + # file_path<String, Array>:: A string that represents the path to create, # or an Array with the path-parts. # # === Returns # The created file_path. def create_path(file_path) unless file_path.kind_of?(String) || file_path.kind_of?(Array) - raise ArgumentError, "file_path must be a string or an array!" + raise ArgumentError, "file_path must be a string or an array!" end - + if file_path.kind_of?(String) file_path = File.expand_path(file_path).split(File::SEPARATOR) file_path.shift if file_path[0] == '' @@ -41,17 +41,17 @@ class Chef file_path[0] = "#{File::SEPARATOR}#{file_path[0]}" end end - + file_path.each_index do |i| create_path = File.join(file_path[0, i + 1]) unless File.directory?(create_path) Chef::Log.debug("Creating directory #{create_path}") Dir.mkdir(create_path) - end + end end File.expand_path(File.join(file_path)) end - + end end end diff --git a/lib/chef/mixin/deep_merge.rb b/lib/chef/mixin/deep_merge.rb index 1f2125be01..9fa86948b6 100644 --- a/lib/chef/mixin/deep_merge.rb +++ b/lib/chef/mixin/deep_merge.rb @@ -8,9 +8,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/lib/chef/mixin/from_file.rb b/lib/chef/mixin/from_file.rb index 609fe1de55..0d1ddca4fa 100644 --- a/lib/chef/mixin/from_file.rb +++ b/lib/chef/mixin/from_file.rb @@ -7,9 +7,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,9 +20,9 @@ class Chef module Mixin module FromFile - - # Loads a given ruby file, and runs instance_eval against it in the context of the current - # object. + + # Loads a given ruby file, and runs instance_eval against it in the context of the current + # object. # # Raises an IOError if the file cannot be found, or is not readable. def from_file(filename) @@ -33,7 +33,7 @@ class Chef end end - # Loads a given ruby file, and runs class_eval against it in the context of the current + # Loads a given ruby file, and runs class_eval against it in the context of the current # object. # # Raises an IOError if the file cannot be found, or is not readable. diff --git a/lib/chef/mixin/language_include_recipe.rb b/lib/chef/mixin/language_include_recipe.rb index b534b6628f..d85e5c682d 100644 --- a/lib/chef/mixin/language_include_recipe.rb +++ b/lib/chef/mixin/language_include_recipe.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/lib/chef/mixin/params_validate.rb b/lib/chef/mixin/params_validate.rb index a9822df134..a9799f749c 100644 --- a/lib/chef/mixin/params_validate.rb +++ b/lib/chef/mixin/params_validate.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,7 +20,7 @@ class Chef end module Mixin module ParamsValidate - + # Takes a hash of options, along with a map to validate them. Returns the original # options hash, plus any changes that might have been made (through things like setting # default values in the validation map) @@ -28,19 +28,19 @@ class Chef # For example: # # validate({ :one => "neat" }, { :one => { :kind_of => String }}) - # + # # Would raise an exception if the value of :one above is not a kind_of? string. Valid # map options are: # # :default:: Sets the default value for this parameter. - # :callbacks:: Takes a hash of Procs, which should return true if the argument is valid. + # :callbacks:: Takes a hash of Procs, which should return true if the argument is valid. # The key will be inserted into the error message if the Proc does not return true: # "Option #{key}'s value #{value} #{message}!" - # :kind_of:: Ensure that the value is a kind_of?(Whatever). If passed an array, it will ensure + # :kind_of:: Ensure that the value is a kind_of?(Whatever). If passed an array, it will ensure # that the value is one of those types. # :respond_to:: Ensure that the value has a given method. Takes one method name or an array of # method names. - # :required:: Raise an exception if this parameter is missing. Valid values are true or false, + # :required:: Raise an exception if this parameter is missing. Valid values are true or false, # by default, options are not required. # :regex:: Match the value of the paramater against a regular expression. # :equal_to:: Match the value of the paramater with ==. An array means it can be equal to any @@ -48,12 +48,12 @@ class Chef def validate(opts, map) #-- # validate works by taking the keys in the validation map, assuming it's a hash, and - # looking for _pv_:symbol as methods. Assuming it find them, it calls the right - # one. + # looking for _pv_:symbol as methods. Assuming it find them, it calls the right + # one. #++ raise ArgumentError, "Options must be a hash" unless opts.kind_of?(Hash) - raise ArgumentError, "Validation Map must be a hash" unless map.kind_of?(Hash) - + raise ArgumentError, "Validation Map must be a hash" unless map.kind_of?(Hash) + map.each do |key, validation| unless key.kind_of?(Symbol) || key.kind_of?(String) raise ArgumentError, "Validation map keys must be symbols or strings!" @@ -76,7 +76,7 @@ class Chef end opts end - + def lazy(&block) DelayedEvaluator.new(&block) end @@ -99,9 +99,9 @@ class Chef self.instance_variable_set(iv_symbol, val) end end - + private - + # Return the value of a parameter, or nil if it doesn't exist. def _pv_opts_lookup(opts, key) if opts.has_key?(key.to_s) @@ -112,7 +112,7 @@ class Chef nil end end - + # Raise an exception if the parameter is not found. def _pv_required(opts, key, is_required=true) if is_required @@ -124,7 +124,7 @@ class Chef end end end - + def _pv_equal_to(opts, key, to_be) value = _pv_opts_lookup(opts, key) unless value.nil? @@ -137,7 +137,7 @@ class Chef end end end - + # Raise an exception if the parameter is not a kind_of?(to_be) def _pv_kind_of(opts, key, to_be) value = _pv_opts_lookup(opts, key) @@ -151,7 +151,7 @@ class Chef end end end - + # Raise an exception if the parameter does not respond to a given set of methods. def _pv_respond_to(opts, key, method_name_list) value = _pv_opts_lookup(opts, key) @@ -181,7 +181,7 @@ class Chef end end end - + # Assign a default value to a parameter. def _pv_default(opts, key, default_value) value = _pv_opts_lookup(opts, key) @@ -189,7 +189,7 @@ class Chef opts[key] = default_value end end - + # Check a parameter against a regular expression. def _pv_regex(opts, key, regex) value = _pv_opts_lookup(opts, key) @@ -207,7 +207,7 @@ class Chef end end end - + # Check a parameter against a hash of proc's. def _pv_callbacks(opts, key, callbacks) raise ArgumentError, "Callback list must be a hash!" unless callbacks.kind_of?(Hash) diff --git a/lib/chef/mixin/why_run.rb b/lib/chef/mixin/why_run.rb index 788e2fe2bc..2fefaad424 100644 --- a/lib/chef/mixin/why_run.rb +++ b/lib/chef/mixin/why_run.rb @@ -178,7 +178,7 @@ class Chef # when the requirement is not met and Chef is executing in why run # mode # - # If no failure_message is provided (above), then execution + # If no failure_message is provided (above), then execution # will be allowed to continue in both whyrun an dnon-whyrun # mode # @@ -196,16 +196,16 @@ class Chef @resource_modifier = resource_modifier end - # Prevents associated actions from being invoked in whyrun mode. - # This will also stop further processing of assertions for a given action. - # - # An example from the template provider: if the source template doesn't exist - # we can't parse it in the action_create block of template - something that we do - # even in whyrun mode. Because the soruce template may have been created in an earlier + # Prevents associated actions from being invoked in whyrun mode. + # This will also stop further processing of assertions for a given action. + # + # An example from the template provider: if the source template doesn't exist + # we can't parse it in the action_create block of template - something that we do + # even in whyrun mode. Because the soruce template may have been created in an earlier # step, we still want to keep going in whyrun mode. - # + # # assert(:create, :create_if_missing) do |a| - # a.assertion { File::exists?(@new_resource.source) } + # a.assertion { File::exists?(@new_resource.source) } # a.whyrun "Template source file does not exist, assuming it would have been created." # a.block_action! # end @@ -214,7 +214,7 @@ class Chef @block_action = true end - def block_action? + def block_action? @block_action end @@ -258,7 +258,7 @@ class Chef # Check to see if a given action is blocked by a failed assertion # # Takes the action name to be verified. - def action_blocked?(action) + def action_blocked?(action) @blocked_actions.include?(action) end @@ -296,9 +296,9 @@ class Chef # "You don't have sufficient privileges to delete #{@new_resource.path}") # end # - # A Template provider that will prevent action execution but continue the run in + # A Template provider that will prevent action execution but continue the run in # whyrun mode if the template source is not available. - # assert(:create, :create_if_missing) do |a| + # assert(:create, :create_if_missing) do |a| # a.assertion { File::exist?(@new_resource.source) } # a.failure_message Chef::Exceptions::TemplateError, "Template #{@new_resource.source} could not be found exist." # a.whyrun "Template source #{@new_resource.source} does not exist. Assuming it would have been created." @@ -318,9 +318,9 @@ class Chef # Run the assertion and assumption logic. def run(action) - @assertions[action.to_sym].each do |a| + @assertions[action.to_sym].each do |a| a.run(action, events, @resource) - if a.assertion_failed? and a.block_action? + if a.assertion_failed? and a.block_action? @blocked_actions << action return end diff --git a/lib/chef/mixin/windows_architecture_helper.rb b/lib/chef/mixin/windows_architecture_helper.rb index 38c08e236d..c13278693f 100644 --- a/lib/chef/mixin/windows_architecture_helper.rb +++ b/lib/chef/mixin/windows_architecture_helper.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,7 @@ # -require 'chef/exceptions' +require 'chef/exceptions' require 'win32/api' if Chef::Platform.windows? class Chef @@ -32,7 +32,7 @@ class Chef is_i386_windows_process? && node_windows_architecture(node) == :x86_64 && desired_architecture == :x86_64 - end + end def node_supports_windows_architecture?(node, desired_architecture) assert_valid_windows_architecture!(desired_architecture) @@ -85,7 +85,7 @@ class Chef end end end - + end end end diff --git a/lib/chef/mixin/xml_escape.rb b/lib/chef/mixin/xml_escape.rb index dac2f0c6af..ceb45df3e6 100644 --- a/lib/chef/mixin/xml_escape.rb +++ b/lib/chef/mixin/xml_escape.rb @@ -7,9 +7,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,26 +18,26 @@ #-- # Portions of this code are adapted from Sam Ruby's xchar.rb -# http://intertwingly.net/stories/2005/09/28/xchar.rb +# http://intertwingly.net/stories/2005/09/28/xchar.rb # # Such code appears here under Sam's original MIT license, while portions of # this file are covered by the above Apache License. For a completely MIT # licensed version, please see Sam's original. # # Thanks, Sam! -# -# Copyright (c) 2005, Sam Ruby -# +# +# Copyright (c) 2005, Sam Ruby +# # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -99,7 +99,7 @@ class Chef } # http://www.w3.org/TR/REC-xml/#charsets - VALID = [[0x9, 0xA, 0xD], (0x20..0xD7FF), + VALID = [[0x9, 0xA, 0xD], (0x20..0xD7FF), (0xE000..0xFFFD), (0x10000..0x10FFFF)] def xml_escape(unescaped_str) @@ -118,7 +118,7 @@ class Chef char = PREDEFINED[char] || (char<128 ? char.chr : "&##{char};") end end - + module FastXS extend self |