diff options
Diffstat (limited to 'lib/chef/mixin')
-rw-r--r-- | lib/chef/mixin/command.rb | 4 | ||||
-rw-r--r-- | lib/chef/mixin/create_path.rb | 8 | ||||
-rw-r--r-- | lib/chef/mixin/from_file.rb | 4 | ||||
-rw-r--r-- | lib/chef/mixin/notifying_block.rb | 16 | ||||
-rw-r--r-- | lib/chef/mixin/params_validate.rb | 6 | ||||
-rw-r--r-- | lib/chef/mixin/securable.rb | 2 | ||||
-rw-r--r-- | lib/chef/mixin/shell_out.rb | 2 | ||||
-rw-r--r-- | lib/chef/mixin/unformatter.rb | 4 | ||||
-rw-r--r-- | lib/chef/mixin/uris.rb | 10 | ||||
-rw-r--r-- | lib/chef/mixin/windows_architecture_helper.rb | 4 | ||||
-rw-r--r-- | lib/chef/mixin/xml_escape.rb | 8 |
11 files changed, 30 insertions, 38 deletions
diff --git a/lib/chef/mixin/command.rb b/lib/chef/mixin/command.rb index 269f1d1194..b1fa7ebd89 100644 --- a/lib/chef/mixin/command.rb +++ b/lib/chef/mixin/command.rb @@ -103,7 +103,7 @@ class Chef command_output << "STDERR: #{stderr}" handle_command_failures(status, command_output, args) - return status, stdout, stderr + [status, stdout, stderr] end def output_of_command(command, args) @@ -141,7 +141,7 @@ class Chef Chef::Log.debug("Ran #{command} returned #{status.exitstatus}") end - return status, stdout_string, stderr_string + [status, stdout_string, stderr_string] end def handle_command_failures(status, command_output, opts = {}) diff --git a/lib/chef/mixin/create_path.rb b/lib/chef/mixin/create_path.rb index 233f7b9521..21a945d2ae 100644 --- a/lib/chef/mixin/create_path.rb +++ b/lib/chef/mixin/create_path.rb @@ -53,7 +53,6 @@ class Chef private def create_dir(path) - begin # When doing multithreaded downloads into the file cache, the following # interleaving raises an error here: # @@ -62,10 +61,9 @@ class Chef # File.directory?(create_path) <- false # Dir.mkdir(create_path) # Dir.mkdir(create_path) <- raises Errno::EEXIST - Chef::Log.debug("Creating directory #{path}") - Dir.mkdir(path) - rescue Errno::EEXIST - end + Chef::Log.debug("Creating directory #{path}") + Dir.mkdir(path) + rescue Errno::EEXIST end end diff --git a/lib/chef/mixin/from_file.rb b/lib/chef/mixin/from_file.rb index a6692d798d..4afea5d9f4 100644 --- a/lib/chef/mixin/from_file.rb +++ b/lib/chef/mixin/from_file.rb @@ -27,7 +27,7 @@ class Chef # Raises an IOError if the file cannot be found, or is not readable. def from_file(filename) if File.exists?(filename) && File.readable?(filename) - self.instance_eval(IO.read(filename), filename, 1) + instance_eval(IO.read(filename), filename, 1) else raise IOError, "Cannot open or read #{filename}!" end @@ -39,7 +39,7 @@ class Chef # Raises an IOError if the file cannot be found, or is not readable. def class_from_file(filename) if File.exists?(filename) && File.readable?(filename) - self.class_eval(IO.read(filename), filename, 1) + class_eval(IO.read(filename), filename, 1) else raise IOError, "Cannot open or read #{filename}!" end diff --git a/lib/chef/mixin/notifying_block.rb b/lib/chef/mixin/notifying_block.rb index 2d6a82f493..d3f235f968 100644 --- a/lib/chef/mixin/notifying_block.rb +++ b/lib/chef/mixin/notifying_block.rb @@ -20,15 +20,13 @@ class Chef module NotifyingBlock def notifying_block(&block) - begin - subcontext = subcontext_block(&block) - Chef::Runner.new(subcontext).converge - ensure - # recipes don't have a new_resource - if respond_to?(:new_resource) - if subcontext && subcontext.resource_collection.any?(&:updated?) - new_resource.updated_by_last_action(true) - end + subcontext = subcontext_block(&block) + Chef::Runner.new(subcontext).converge + ensure + # recipes don't have a new_resource + if respond_to?(:new_resource) + if subcontext && subcontext.resource_collection.any?(&:updated?) + new_resource.updated_by_last_action(true) end end end diff --git a/lib/chef/mixin/params_validate.rb b/lib/chef/mixin/params_validate.rb index b16df41c8e..0db058c3ab 100644 --- a/lib/chef/mixin/params_validate.rb +++ b/lib/chef/mixin/params_validate.rb @@ -102,8 +102,8 @@ class Chef when Hash validation.each do |check, carg| check_method = "_pv_#{check}" - if self.respond_to?(check_method, true) - self.send(check_method, opts, key, carg) + if respond_to?(check_method, true) + send(check_method, opts, key, carg) else raise ArgumentError, "Validation map has unknown check: #{check}" end @@ -333,7 +333,7 @@ class Chef if is_name_property if opts[key].nil? raise CannotValidateStaticallyError, "name_property cannot be evaluated without a resource." if self == Chef::Mixin::ParamsValidate - opts[key] = self.instance_variable_get(:"@name") + opts[key] = instance_variable_get(:"@name") end end end diff --git a/lib/chef/mixin/securable.rb b/lib/chef/mixin/securable.rb index 55b4e0a6d1..85c9dea1d4 100644 --- a/lib/chef/mixin/securable.rb +++ b/lib/chef/mixin/securable.rb @@ -110,7 +110,7 @@ class Chef # equivalent to something like: # def rights(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) + rights = instance_variable_get("@#{name}".to_sym) unless permissions.nil? input = { :permissions => permissions, diff --git a/lib/chef/mixin/shell_out.rb b/lib/chef/mixin/shell_out.rb index 92518a1e11..18bd067989 100644 --- a/lib/chef/mixin/shell_out.rb +++ b/lib/chef/mixin/shell_out.rb @@ -148,7 +148,7 @@ class Chef my_options[new_option] = value end - return my_command_args + my_command_args end # Helper for sublcasses to convert an array of string args into a string. It diff --git a/lib/chef/mixin/unformatter.rb b/lib/chef/mixin/unformatter.rb index 7dad56b270..5663749e58 100644 --- a/lib/chef/mixin/unformatter.rb +++ b/lib/chef/mixin/unformatter.rb @@ -22,9 +22,9 @@ class Chef def write(message) data = message.match(/(\[.+?\] )?([\w]+):(.*)$/) - self.send(data[2].downcase.chomp.to_sym, data[3].strip) + send(data[2].downcase.chomp.to_sym, data[3].strip) rescue NoMethodError - self.send(:info, message) + send(:info, message) end end diff --git a/lib/chef/mixin/uris.rb b/lib/chef/mixin/uris.rb index 7dc04d662b..ea55eefd8f 100644 --- a/lib/chef/mixin/uris.rb +++ b/lib/chef/mixin/uris.rb @@ -31,12 +31,10 @@ class Chef end def as_uri(source) - begin - URI.parse(source) - rescue URI::InvalidURIError - Chef::Log.warn("#{source} was an invalid URI. Trying to escape invalid characters") - URI.parse(Addressable::URI.encode(source)) - end + URI.parse(source) + rescue URI::InvalidURIError + Chef::Log.warn("#{source} was an invalid URI. Trying to escape invalid characters") + URI.parse(Addressable::URI.encode(source)) end end diff --git a/lib/chef/mixin/windows_architecture_helper.rb b/lib/chef/mixin/windows_architecture_helper.rb index 49252af484..67c34a85a1 100644 --- a/lib/chef/mixin/windows_architecture_helper.rb +++ b/lib/chef/mixin/windows_architecture_helper.rb @@ -74,11 +74,11 @@ class Chef def node_supports_windows_architecture?(node, desired_architecture) assert_valid_windows_architecture!(desired_architecture) - return ( node_windows_architecture(node) == :x86_64 ) || ( desired_architecture == :i386 ) + ( node_windows_architecture(node) == :x86_64 ) || ( desired_architecture == :i386 ) end def valid_windows_architecture?(architecture) - return ( architecture == :x86_64 ) || ( architecture == :i386 ) + ( architecture == :x86_64 ) || ( architecture == :i386 ) end def assert_valid_windows_architecture!(architecture) diff --git a/lib/chef/mixin/xml_escape.rb b/lib/chef/mixin/xml_escape.rb index f9a41b9fd0..243bb7f044 100644 --- a/lib/chef/mixin/xml_escape.rb +++ b/lib/chef/mixin/xml_escape.rb @@ -103,11 +103,9 @@ class Chef (0xE000..0xFFFD), (0x10000..0x10FFFF)] def xml_escape(unescaped_str) - begin - unescaped_str.unpack("U*").map { |char| xml_escape_char!(char) }.join - rescue - unescaped_str.unpack("C*").map { |char| xml_escape_char!(char) }.join - end + unescaped_str.unpack("U*").map { |char| xml_escape_char!(char) }.join + rescue + unescaped_str.unpack("C*").map { |char| xml_escape_char!(char) }.join end private |