[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

Markus Roberts Markus at reality.com
Wed Jul 14 10:37:23 UTC 2010


The following commit has been merged in the upstream branch:
commit 42a539061293f8e745a9dc5b97b4415b6a275e04
Author: Markus Roberts <Markus at reality.com>
Date:   Fri Jul 9 18:06:48 2010 -0700

    Code smell: Use ||= for conditional initialization
    
    Replaced 55 occurances of
    
        ([$@]?\w+) += +(.*) +(if +\1.nil\?|if +! *\1|unless +\1|unless +defined\?\(\1\))$
    
    with
    
        \1 ||= \2
    
    3 Examples:
    
        The code:
            @sync
        becomes:
            @sync
        The code:
    
        becomes:
    
        The code:
            if @yydebug
        becomes:
            if @yydebug

diff --git a/lib/puppet/agent.rb b/lib/puppet/agent.rb
index 6682b84..58bf5cd 100644
--- a/lib/puppet/agent.rb
+++ b/lib/puppet/agent.rb
@@ -81,7 +81,7 @@ class Puppet::Agent
     end
 
     def sync
-        @sync = Sync.new unless @sync
+        @sync ||= Sync.new
         @sync
     end
 
diff --git a/lib/puppet/agent/locker.rb b/lib/puppet/agent/locker.rb
index c49121e..52f3002 100644
--- a/lib/puppet/agent/locker.rb
+++ b/lib/puppet/agent/locker.rb
@@ -29,7 +29,7 @@ module Puppet::Agent::Locker
     end
 
     def lockfile
-        @lockfile = Puppet::Util::Pidlock.new(lockfile_path) unless defined?(@lockfile)
+        @lockfile ||= Puppet::Util::Pidlock.new(lockfile_path)
 
         @lockfile
     end
diff --git a/lib/puppet/external/nagios/parser.rb b/lib/puppet/external/nagios/parser.rb
index 7e83f03..934af14 100644
--- a/lib/puppet/external/nagios/parser.rb
+++ b/lib/puppet/external/nagios/parser.rb
@@ -70,9 +70,9 @@ module Racc
 
         def _racc_setup
             @yydebug = false unless self.class::Racc_debug_parser
-            @yydebug = false unless defined?(@yydebug)
+            @yydebug ||= false
             if @yydebug
-                @racc_debug_out = $stderr unless defined?(@racc_debug_out)
+                @racc_debug_out ||= $stderr
                 @racc_debug_out ||= $stderr
             end
             arg = self.class::Racc_arg
diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb
index 0871c4a..7077130 100644
--- a/lib/puppet/file_serving/base.rb
+++ b/lib/puppet/file_serving/base.rb
@@ -67,7 +67,7 @@ class Puppet::FileServing::Base
 
     # Stat our file, using the appropriate link-sensitive method.
     def stat
-        @stat_method = self.links == :manage ? :lstat : :stat unless defined?(@stat_method)
+        @stat_method ||= self.links == :manage ? :lstat : :stat
         File.send(@stat_method, full_path())
     end
 
diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb
index 99bd840..15d9f9a 100644
--- a/lib/puppet/file_serving/fileset.rb
+++ b/lib/puppet/file_serving/fileset.rb
@@ -158,7 +158,7 @@ class Puppet::FileServing::Fileset
     public
     # Stat a given file, using the links-appropriate method.
     def stat(path)
-        @stat_method = self.links == :manage ? :lstat : :stat unless defined?(@stat_method)
+        @stat_method ||= self.links == :manage ? :lstat : :stat
 
         begin
             return File.send(@stat_method, path)
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb
index 8eaaf26..2827628 100644
--- a/lib/puppet/indirector/indirection.rb
+++ b/lib/puppet/indirector/indirection.rb
@@ -64,7 +64,7 @@ class Puppet::Indirector::Indirection
 
     # Default to the runinterval for the ttl.
     def ttl
-        @ttl = Puppet[:runinterval].to_i unless defined?(@ttl)
+        @ttl ||= Puppet[:runinterval].to_i
         @ttl
     end
 
diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb
index 32494e1..faf9a13 100644
--- a/lib/puppet/indirector/request.rb
+++ b/lib/puppet/indirector/request.rb
@@ -21,7 +21,7 @@ class Puppet::Indirector::Request
     end
 
     def environment
-        @environment = Puppet::Node::Environment.new() unless @environment
+        @environment ||= Puppet::Node::Environment.new()
         @environment
     end
 
@@ -69,7 +69,7 @@ class Puppet::Indirector::Request
         if key_or_instance.is_a?(String) || key_or_instance.is_a?(Symbol)
             key = key_or_instance
         else
-            @instance = key_or_instance if ! @instance
+            @instance ||= key_or_instance
         end
 
         if key
diff --git a/lib/puppet/network/authconfig.rb b/lib/puppet/network/authconfig.rb
index 8c2ad58..b058012 100644
--- a/lib/puppet/network/authconfig.rb
+++ b/lib/puppet/network/authconfig.rb
@@ -6,7 +6,7 @@ module Puppet
     class Network::AuthConfig < Puppet::Util::LoadedFile
 
         def self.main
-            @main = self.new() unless defined?(@main)
+            @main ||= self.new()
             @main
         end
 
diff --git a/lib/puppet/network/authorization.rb b/lib/puppet/network/authorization.rb
index 1368753..3d47ea3 100644
--- a/lib/puppet/network/authorization.rb
+++ b/lib/puppet/network/authorization.rb
@@ -10,7 +10,7 @@ module Puppet::Network
         # Create our config object if necessary.  This works even if
         # there's no configuration file.
         def authconfig
-            @authconfig = Puppet::Network::AuthConfig.main() unless defined?(@authconfig)
+            @authconfig ||= Puppet::Network::AuthConfig.main()
 
             @authconfig
         end
diff --git a/lib/puppet/network/client.rb b/lib/puppet/network/client.rb
index 258e577..1d720cc 100644
--- a/lib/puppet/network/client.rb
+++ b/lib/puppet/network/client.rb
@@ -48,19 +48,19 @@ class Puppet::Network::Client
     # Determine what clients look for when being passed an object for local
     # client/server stuff.  E.g., you could call Client::CA.new(:CA => ca).
     def self.drivername
-        @drivername = self.name unless defined?(@drivername)
+        @drivername ||= self.name
         @drivername
     end
 
     # Figure out the handler for our client.
     def self.handler
-        @handler = Puppet::Network::Handler.handler(self.name) unless defined?(@handler)
+        @handler ||= Puppet::Network::Handler.handler(self.name)
         @handler
     end
 
     # The class that handles xmlrpc interaction for us.
     def self.xmlrpc_client
-        @xmlrpc_client = Puppet::Network::XMLRPCClient.handler_class(self.handler) unless defined?(@xmlrpc_client)
+        @xmlrpc_client ||= Puppet::Network::XMLRPCClient.handler_class(self.handler)
         @xmlrpc_client
     end
 
diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb
index efd7122..1131e43 100755
--- a/lib/puppet/network/handler/fileserver.rb
+++ b/lib/puppet/network/handler/fileserver.rb
@@ -701,7 +701,7 @@ class Puppet::Network::Handler
                     if modpath = mod.plugin(relpath)
                         if FileTest.directory?(modpath) and recurse
                             ary = reclist(modpath, recurse, ignore)
-                            ary = [] if ary.nil?
+                            ary ||= []
                             result += ary
                         else
                             result += [["/", File.stat(modpath).ftype]]
diff --git a/lib/puppet/network/rest_authorization.rb b/lib/puppet/network/rest_authorization.rb
index 3c7c98a..d9a8370 100644
--- a/lib/puppet/network/rest_authorization.rb
+++ b/lib/puppet/network/rest_authorization.rb
@@ -9,7 +9,7 @@ module Puppet::Network
         # Create our config object if necessary. If there's no configuration file
         # we install our defaults
         def authconfig
-            @authconfig = Puppet::Network::RestAuthConfig.main unless defined?(@authconfig)
+            @authconfig ||= Puppet::Network::RestAuthConfig.main
 
             @authconfig
         end
diff --git a/lib/puppet/network/xmlrpc/client.rb b/lib/puppet/network/xmlrpc/client.rb
index 2bf30e7..5bcd5fb 100644
--- a/lib/puppet/network/xmlrpc/client.rb
+++ b/lib/puppet/network/xmlrpc/client.rb
@@ -150,7 +150,7 @@ module Puppet::Network
         end
 
         def http
-            @http = Puppet::Network::HttpPool.http_instance(host, port, true) unless @http
+            @http ||= Puppet::Network::HttpPool.http_instance(host, port, true)
             @http
         end
 
diff --git a/lib/puppet/network/xmlrpc/webrick_servlet.rb b/lib/puppet/network/xmlrpc/webrick_servlet.rb
index e7fb2ae..890f299 100644
--- a/lib/puppet/network/xmlrpc/webrick_servlet.rb
+++ b/lib/puppet/network/xmlrpc/webrick_servlet.rb
@@ -10,7 +10,7 @@ module Puppet::Network::XMLRPC
         # This is a hackish way to avoid an auth message every time we have a
         # normal operation
         def self.log(msg)
-            @logs = {} unless defined?(@logs)
+            @logs ||= {}
             if @logs.include?(msg)
                 @logs[msg] += 1
             else
diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb
index 54e71dd..b3ec171 100644
--- a/lib/puppet/parameter.rb
+++ b/lib/puppet/parameter.rb
@@ -203,7 +203,7 @@ class Puppet::Parameter
 
     # for testing whether we should actually do anything
     def noop
-        @noop = false unless defined?(@noop)
+        @noop ||= false
         tmp = @noop || self.resource.noop || Puppet[:noop] || false
         #debug "noop is #{tmp}"
         tmp
diff --git a/lib/puppet/parser/ast/branch.rb b/lib/puppet/parser/ast/branch.rb
index 0be6ca0..96d065e 100644
--- a/lib/puppet/parser/ast/branch.rb
+++ b/lib/puppet/parser/ast/branch.rb
@@ -23,7 +23,7 @@ class Puppet::Parser::AST
             super(arghash)
 
             # Create the hash, if it was not set at initialization time.
-            @children = [] unless defined?(@children)
+            @children ||= []
 
             # Verify that we only got valid AST nodes.
             @children.each { |child|
diff --git a/lib/puppet/parser/ast/caseopt.rb b/lib/puppet/parser/ast/caseopt.rb
index b18a403..6cf36f9 100644
--- a/lib/puppet/parser/ast/caseopt.rb
+++ b/lib/puppet/parser/ast/caseopt.rb
@@ -29,7 +29,7 @@ class Puppet::Parser::AST
                 @default = true if @value.is_a?(AST::Default)
             end
 
-            @default = false unless defined?(@default)
+            @default ||= false
 
             @default
         end
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index 65d657b..ba2a5f3 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -27,7 +27,7 @@ class Puppet::Parser::Resource < Puppet::Resource
 
     # Determine whether the provided parameter name is a relationship parameter.
     def self.relationship_parameter?(name)
-        @relationship_names = Puppet::Type.relationship_params.collect { |p| p.name } unless defined?(@relationship_names)
+        @relationship_names ||= Puppet::Type.relationship_params.collect { |p| p.name }
         @relationship_names.include?(name)
     end
 
diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb
index 0ded4c5..ba4c269 100644
--- a/lib/puppet/property.rb
+++ b/lib/puppet/property.rb
@@ -21,7 +21,7 @@ class Puppet::Property < Puppet::Parameter
         # Return array matching info, defaulting to just matching
         # the first value.
         def array_matching
-            @array_matching = :first unless defined?(@array_matching)
+            @array_matching ||= :first
             @array_matching
         end
 
diff --git a/lib/puppet/provider.rb b/lib/puppet/provider.rb
index e7a241a..937f114 100644
--- a/lib/puppet/provider.rb
+++ b/lib/puppet/provider.rb
@@ -174,7 +174,7 @@ class Puppet::Provider
 
     # Retrieve the data source.  Defaults to the provider name.
     def self.source
-        @source = self.name unless defined?(@source)
+        @source ||= self.name
         @source
     end
 
diff --git a/lib/puppet/provider/confine/variable.rb b/lib/puppet/provider/confine/variable.rb
index 504c6a0..9dde40a 100644
--- a/lib/puppet/provider/confine/variable.rb
+++ b/lib/puppet/provider/confine/variable.rb
@@ -18,7 +18,7 @@ class Puppet::Provider::Confine::Variable < Puppet::Provider::Confine
 
     # Retrieve the value from facter
     def facter_value
-        @facter_value = ::Facter.value(name).to_s.downcase unless @facter_value
+        @facter_value ||= ::Facter.value(name).to_s.downcase
         @facter_value
     end
 
diff --git a/lib/puppet/provider/confiner.rb b/lib/puppet/provider/confiner.rb
index bb26ea4..012eaa8 100644
--- a/lib/puppet/provider/confiner.rb
+++ b/lib/puppet/provider/confiner.rb
@@ -6,7 +6,7 @@ module Puppet::Provider::Confiner
     end
 
     def confine_collection
-        @confine_collection = Puppet::Provider::ConfineCollection.new(self.to_s) unless defined?(@confine_collection)
+        @confine_collection ||= Puppet::Provider::ConfineCollection.new(self.to_s)
         @confine_collection
     end
 
diff --git a/lib/puppet/provider/macauthorization/macauthorization.rb b/lib/puppet/provider/macauthorization/macauthorization.rb
index 22186de..4c55d72 100644
--- a/lib/puppet/provider/macauthorization/macauthorization.rb
+++ b/lib/puppet/provider/macauthorization/macauthorization.rb
@@ -157,7 +157,7 @@ Puppet::Type.type(:macauthorization).provide :macauthorization, :parent => Puppe
         cmds << :security << "authorizationdb" << "read" << resource[:name]
         output = execute(cmds, :combine => false)
         current_values = Plist::parse_xml(output)
-        current_values = {} if current_values.nil?
+        current_values ||= {}
         specified_values = convert_plist_to_native_attributes(@property_hash)
 
         # take the current values, merge the specified values to obtain a
diff --git a/lib/puppet/provider/mcx/mcxcontent.rb b/lib/puppet/provider/mcx/mcxcontent.rb
index 97a778f..4711413 100644
--- a/lib/puppet/provider/mcx/mcxcontent.rb
+++ b/lib/puppet/provider/mcx/mcxcontent.rb
@@ -140,11 +140,11 @@ Puppet::Type.type(:mcx).provide :mcxcontent, :parent => Puppet::Provider do
     # This is a private instance method, not a class method.
     def get_dsparams
         ds_type = resource[:ds_type]
-        ds_type = parse_type(resource[:name]) if ds_type.nil?
+        ds_type ||= parse_type(resource[:name])
         raise MCXContentProviderException unless TypeMap.keys.include? ds_type.to_sym
 
         ds_name = resource[:ds_name]
-        ds_name = parse_name(resource[:name]) if ds_name.nil?
+        ds_name ||= parse_name(resource[:name])
 
         rval = {
             :ds_type => ds_type.to_sym,
diff --git a/lib/puppet/provider/parsedfile.rb b/lib/puppet/provider/parsedfile.rb
index cdbcdd0..53585b1 100755
--- a/lib/puppet/provider/parsedfile.rb
+++ b/lib/puppet/provider/parsedfile.rb
@@ -34,7 +34,7 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
     end
 
     def self.filetype
-        @filetype = Puppet::Util::FileType.filetype(:flat) unless defined?(@filetype)
+        @filetype ||= Puppet::Util::FileType.filetype(:flat)
         @filetype
     end
 
@@ -79,7 +79,7 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
     def self.backup_target(target)
         return nil unless target_object(target).respond_to?(:backup)
 
-        @backup_stats = {} unless defined?(@backup_stats)
+        @backup_stats ||= {}
         return nil if @backup_stats[target] == @records.object_id
 
         target_object(target).backup
diff --git a/lib/puppet/reports/rrdgraph.rb b/lib/puppet/reports/rrdgraph.rb
index 0b1bd87..c93f13e 100644
--- a/lib/puppet/reports/rrdgraph.rb
+++ b/lib/puppet/reports/rrdgraph.rb
@@ -22,7 +22,7 @@ Puppet::Reports.register_report(:rrdgraph) do
         which defaults to the ``runinterval``."
 
     def hostdir
-        @hostdir = File.join(Puppet[:rrddir], self.host) unless defined?(@hostdir)
+        @hostdir ||= File.join(Puppet[:rrddir], self.host)
         @hostdir
     end
 
diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb
index 18bca61..027b0fb 100644
--- a/lib/puppet/simple_graph.rb
+++ b/lib/puppet/simple_graph.rb
@@ -119,7 +119,7 @@ class Puppet::SimpleGraph
     def dependencies(resource)
         # Cache the reversal graph, because it's somewhat expensive
         # to create.
-        @reversal = reversal unless @reversal
+        @reversal ||= reversal
         # Strangely, it's significantly faster to search a reversed
         # tree in the :out direction than to search a normal tree
         # in the :in direction.
diff --git a/lib/puppet/ssl/certificate_authority.rb b/lib/puppet/ssl/certificate_authority.rb
index 357e54e..00dbf60 100644
--- a/lib/puppet/ssl/certificate_authority.rb
+++ b/lib/puppet/ssl/certificate_authority.rb
@@ -148,7 +148,7 @@ class Puppet::SSL::CertificateAuthority
 
     # Retrieve (or create, if necessary) our inventory manager.
     def inventory
-        @inventory = Puppet::SSL::Inventory.new unless defined?(@inventory)
+        @inventory ||= Puppet::SSL::Inventory.new
         @inventory
     end
 
diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb
index b97817c..74c1bbf 100644
--- a/lib/puppet/transportable.rb
+++ b/lib/puppet/transportable.rb
@@ -34,7 +34,7 @@ module Puppet
         end
 
         def ref
-            @ref = Puppet::Resource.new(@type, @name) unless defined?(@ref)
+            @ref ||= Puppet::Resource.new(@type, @name)
             @ref.to_s
         end
 
@@ -239,7 +239,7 @@ module Puppet
         end
 
         def param(param,value)
-            @parameters = {} unless defined?(@parameters)
+            @parameters ||= {}
             @parameters[param] = value
         end
 
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 47e0151..7aab88c 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -1624,7 +1624,7 @@ class Type
 
         @defaults = {}
 
-        @parameters = [] unless defined?(@parameters)
+        @parameters ||= []
 
         @validproperties = {}
         @properties = []
@@ -1642,7 +1642,7 @@ class Type
             end
         }
 
-        @doc = "" unless defined?(@doc)
+        @doc ||= ""
 
     end
 
diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb
index 856ea7c..7a1f37f 100755
--- a/lib/puppet/type/cron.rb
+++ b/lib/puppet/type/cron.rb
@@ -387,7 +387,7 @@ Puppet::Type.newtype(:cron) do
         if obj = @parameters[name]
             ret = obj.should
 
-            ret = obj.retrieve if ret.nil?
+            ret ||= obj.retrieve
 
             if ret == :absent
                 ret = nil
diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb
index fdcd2c8..e1a23dd 100644
--- a/lib/puppet/type/package.rb
+++ b/lib/puppet/type/package.rb
@@ -112,7 +112,7 @@ module Puppet
             def insync?(is)
                 @should ||= []
 
-                @latest = nil unless defined?(@latest)
+                @latest ||= nil
                 @lateststamp ||= (Time.now.to_i - 1000)
                 # Iterate across all of the should values, and see how they
                 # turn out.
diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb
index fc7109c..76685d6 100644
--- a/lib/puppet/type/resources.rb
+++ b/lib/puppet/type/resources.rb
@@ -68,8 +68,8 @@ Puppet::Type.newtype(:resources) do
     end
 
     def check(resource)
-        @checkmethod = "#{self[:name]}_check" unless defined?(@checkmethod)
-        @hascheck = respond_to?(@checkmethod) unless defined?(@hascheck)
+        @checkmethod ||= "#{self[:name]}_check"
+        @hascheck ||= respond_to?(@checkmethod)
         if @hascheck
             return send(@checkmethod, resource)
         else
diff --git a/lib/puppet/util/cacher.rb b/lib/puppet/util/cacher.rb
index 8a0acc8..df8c28a 100644
--- a/lib/puppet/util/cacher.rb
+++ b/lib/puppet/util/cacher.rb
@@ -88,7 +88,7 @@ module Puppet::Util::Cacher
         private
 
         def cache_timestamp
-            @cache_timestamp = Time.now unless defined?(@cache_timestamp)
+            @cache_timestamp ||= Time.now
             @cache_timestamp
         end
 
@@ -122,7 +122,7 @@ module Puppet::Util::Cacher
         end
 
         def value_cache
-            @value_cache = {} unless @value_cache
+            @value_cache ||= {}
             @value_cache
         end
     end
diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb
index a5d7ca4..bc35559 100644
--- a/lib/puppet/util/fileparsing.rb
+++ b/lib/puppet/util/fileparsing.rb
@@ -203,7 +203,7 @@ module Puppet::Util::FileParsing
     end
 
     def line_separator
-        @line_separator = "\n" unless defined?(@line_separator)
+        @line_separator ||= "\n"
 
         @line_separator
     end
diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb
index 712895f..98aaf8c 100755
--- a/lib/puppet/util/filetype.rb
+++ b/lib/puppet/util/filetype.rb
@@ -72,7 +72,7 @@ class Puppet::Util::FileType
 
     # Pick or create a filebucket to use.
     def bucket
-        @bucket = Puppet::Type.type(:filebucket).mkdefaultbucket.bucket unless defined?(@bucket)
+        @bucket ||= Puppet::Type.type(:filebucket).mkdefaultbucket.bucket
         @bucket
     end
 
diff --git a/lib/puppet/util/inline_docs.rb b/lib/puppet/util/inline_docs.rb
index b04b40a..95a8c2a 100644
--- a/lib/puppet/util/inline_docs.rb
+++ b/lib/puppet/util/inline_docs.rb
@@ -15,7 +15,7 @@ module Puppet::Util::InlineDocs
         attr_writer :doc
 
         def doc
-            @doc = "" unless @doc
+            @doc ||= ""
             @doc
         end
 
diff --git a/lib/puppet/util/log/destinations.rb b/lib/puppet/util/log/destinations.rb
index 6c94247..515568c 100644
--- a/lib/puppet/util/log/destinations.rb
+++ b/lib/puppet/util/log/destinations.rb
@@ -154,7 +154,7 @@ Puppet::Util::Log.newdesttype :host do
 
     def handle(msg)
         unless msg.is_a?(String) or msg.remote
-            @hostname = Facter["hostname"].value unless defined?(@hostname)
+            @hostname ||= Facter["hostname"].value
             unless defined?(@domain)
                 @domain = Facter["domain"].value
                 @hostname += ".#{@domain}" if @domain
diff --git a/lib/puppet/util/log_paths.rb b/lib/puppet/util/log_paths.rb
index a7ad189..e09ceb7 100644
--- a/lib/puppet/util/log_paths.rb
+++ b/lib/puppet/util/log_paths.rb
@@ -5,7 +5,7 @@ module Puppet::Util::LogPaths
     # return the full path to us, for logging and rollback
     # some classes (e.g., FileTypeRecords) will have to override this
     def path
-        @path = pathbuilder unless defined?(@path)
+        @path ||= pathbuilder
 
         "/" + @path.join("/")
     end
diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb
index c79adf6..606d06c 100644
--- a/lib/puppet/util/rdoc/parser.rb
+++ b/lib/puppet/util/rdoc/parser.rb
@@ -67,7 +67,7 @@ class Parser
         names.each do |name|
             prev_container = container
             container = find_object_named(container, name)
-            container = prev_container.add_class(PuppetClass, name, nil) unless container
+            container ||= prev_container.add_class(PuppetClass, name, nil)
         end
         [container, final_name]
     end
diff --git a/lib/puppet/util/subclass_loader.rb b/lib/puppet/util/subclass_loader.rb
index 6f86143..ee6b68b 100644
--- a/lib/puppet/util/subclass_loader.rb
+++ b/lib/puppet/util/subclass_loader.rb
@@ -68,7 +68,7 @@ module Puppet::Util::SubclassLoader
 
     # Retrieve or calculate a name.
     def name(dummy_argument=:work_arround_for_ruby_GC_bug)
-        @name = self.to_s.sub(/.+::/, '').intern unless defined?(@name)
+        @name ||= self.to_s.sub(/.+::/, '').intern
 
         @name
     end
diff --git a/test/lib/puppettest/filetesting.rb b/test/lib/puppettest/filetesting.rb
index 6f07c2a..79981ce 100644
--- a/test/lib/puppettest/filetesting.rb
+++ b/test/lib/puppettest/filetesting.rb
@@ -32,9 +32,9 @@ module PuppetTest::FileTesting
     def mkranddirsandfiles(dirs = nil,files = nil,depth = 3)
         return if depth < 0
 
-        dirs = %w{This Is A Set Of Directories} unless dirs
+        dirs ||= %w{This Is A Set Of Directories}
 
-        files = %w{and this is a set of files} unless files
+        files ||= %w{and this is a set of files}
 
         tfiles = randlist(files)
         tdirs = randlist(dirs)
diff --git a/test/ral/providers/cron/crontab.rb b/test/ral/providers/cron/crontab.rb
index 3dfac96..41d12c8 100755
--- a/test/ral/providers/cron/crontab.rb
+++ b/test/ral/providers/cron/crontab.rb
@@ -23,7 +23,7 @@ class TestCronParsedProvider < Test::Unit::TestCase
     # a full cron job.  These tests assume individual record types will always be correctly
     # parsed, so all they
     def sample_crons
-        @sample_crons = YAML.load(File.read(File.join(@crondir, "crontab_collections.yaml"))) unless defined?(@sample_crons)
+        @sample_crons ||= YAML.load(File.read(File.join(@crondir, "crontab_collections.yaml")))
         @sample_crons
     end
 
@@ -31,7 +31,7 @@ class TestCronParsedProvider < Test::Unit::TestCase
     # mapping between records and lines.  We have plenty of redundancy here because
     # we use these records to build up our complex, multi-line cron jobs below.
     def sample_records
-        @sample_records = YAML.load(File.read(File.join(@crondir, "crontab_sample_records.yaml"))) unless defined?(@sample_records)
+        @sample_records ||= YAML.load(File.read(File.join(@crondir, "crontab_sample_records.yaml")))
         @sample_records
     end
 

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list