diff options
Diffstat (limited to 'lib/puppet')
32 files changed, 52 insertions, 52 deletions
diff --git a/lib/puppet/agent.rb b/lib/puppet/agent.rb index b860677fd..6682b8450 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 defined?(@sync) and @sync + @sync = Sync.new unless @sync @sync end diff --git a/lib/puppet/file_serving/content.rb b/lib/puppet/file_serving/content.rb index 87ef4fbbf..cacd908e8 100644 --- a/lib/puppet/file_serving/content.rb +++ b/lib/puppet/file_serving/content.rb @@ -35,7 +35,7 @@ class Puppet::FileServing::Content < Puppet::FileServing::Base # Read the content of our file in. def content - unless defined?(@content) and @content + unless @content # This stat can raise an exception, too. raise(ArgumentError, "Cannot read the contents of links unless following links") if stat().ftype == "symlink" diff --git a/lib/puppet/indirector.rb b/lib/puppet/indirector.rb index 97892d99a..125445d23 100644 --- a/lib/puppet/indirector.rb +++ b/lib/puppet/indirector.rb @@ -18,7 +18,7 @@ module Puppet::Indirector # evaluated at parse time, which is before the user has had a chance # to override it. def indirects(indirection, options = {}) - raise(ArgumentError, "Already handling indirection for #{@indirection.name}; cannot also handle #{indirection}") if defined?(@indirection) and @indirection + raise(ArgumentError, "Already handling indirection for #{@indirection.name}; cannot also handle #{indirection}") if @indirection # populate this class with the various new methods extend ClassMethods include InstanceMethods diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb index 89235f356..8eaaf26d6 100644 --- a/lib/puppet/indirector/indirection.rb +++ b/lib/puppet/indirector/indirection.rb @@ -77,7 +77,7 @@ class Puppet::Indirector::Indirection def doc text = "" - text += scrub(@doc) + "\n\n" if defined?(@doc) and @doc + text += scrub(@doc) + "\n\n" if @doc if s = terminus_setting() text += "* **Terminus Setting**: #{terminus_setting}" diff --git a/lib/puppet/indirector/ldap.rb b/lib/puppet/indirector/ldap.rb index 0b95b6ee0..3ccb21d52 100644 --- a/lib/puppet/indirector/ldap.rb +++ b/lib/puppet/indirector/ldap.rb @@ -61,7 +61,7 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus # Create an ldap connection. def connection - unless defined?(@connection) and @connection + unless @connection raise Puppet::Error, "Could not set up LDAP Connection: Missing ruby/ldap libraries" unless Puppet.features.ldap? begin conn = Puppet::Util::Ldap::Connection.instance diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb index 898722fd6..32494e18c 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 defined?(@environment) and @environment + @environment = Puppet::Node::Environment.new() unless @environment @environment end diff --git a/lib/puppet/network/client.rb b/lib/puppet/network/client.rb index 6d8779f5b..258e577cd 100644 --- a/lib/puppet/network/client.rb +++ b/lib/puppet/network/client.rb @@ -104,7 +104,7 @@ class Puppet::Network::Client # Are we a local client? def local? - if defined?(@local) and @local + if @local true else false diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb index c068e8e11..54e71dd41 100644 --- a/lib/puppet/parameter.rb +++ b/lib/puppet/parameter.rb @@ -90,7 +90,7 @@ class Puppet::Parameter # Is this parameter the namevar? Defaults to false. def isnamevar? - defined?(@isnamevar) && @isnamevar + @isnamevar end # This parameter is required. @@ -105,7 +105,7 @@ class Puppet::Parameter # Is this parameter required? Defaults to false. def required? - defined?(@required) && @required + @required end # Verify that we got a good value @@ -164,9 +164,9 @@ class Puppet::Parameter error = type.new(args.join(" ")) - error.line = @resource.line if defined?(@resource) and @resource and @resource.line + error.line = @resource.line if @resource and @resource.line - error.file = @resource.file if defined?(@resource) and @resource and @resource.file + error.file = @resource.file if @resource and @resource.file raise error end @@ -212,7 +212,7 @@ class Puppet::Parameter # return the full path to us, for logging and rollback; not currently # used def pathbuilder - if defined?(@resource) and @resource + if @resource return [@resource.pathbuilder, self.name] else return [self.name] diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index baae78a8f..65d657b63 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -102,7 +102,7 @@ class Puppet::Parser::Resource < Puppet::Resource # Has this resource already been finished? def finished? - defined?(@finished) and @finished + @finished end def initialize(*args) diff --git a/lib/puppet/property/keyvalue.rb b/lib/puppet/property/keyvalue.rb index fcd9d57f1..2ac87acfd 100644 --- a/lib/puppet/property/keyvalue.rb +++ b/lib/puppet/property/keyvalue.rb @@ -50,7 +50,7 @@ module Puppet end def should - return nil unless defined?(@should) and @should + return nil unless @should members = hashify(@should) current = process_current_hash(retrieve) @@ -77,7 +77,7 @@ module Puppet end def insync?(is) - return true unless defined?(@should) and @should + return true unless @should return true unless is diff --git a/lib/puppet/property/list.rb b/lib/puppet/property/list.rb index fa85ac033..0433a515a 100644 --- a/lib/puppet/property/list.rb +++ b/lib/puppet/property/list.rb @@ -36,7 +36,7 @@ module Puppet end def should - return nil unless defined?(@should) and @should + return nil unless @should members = @should #inclusive means we are managing everything so if it isn't in should, its gone @@ -66,7 +66,7 @@ module Puppet end def insync?(is) - return true unless defined?(@should) and @should + return true unless @should return true unless is diff --git a/lib/puppet/provider/confine/variable.rb b/lib/puppet/provider/confine/variable.rb index 66fe9b836..504c6a0c9 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 defined?(@facter_value) and @facter_value + @facter_value = ::Facter.value(name).to_s.downcase unless @facter_value @facter_value end diff --git a/lib/puppet/provider/naginator.rb b/lib/puppet/provider/naginator.rb index 75337f2bf..1006a4c0d 100644 --- a/lib/puppet/provider/naginator.rb +++ b/lib/puppet/provider/naginator.rb @@ -10,7 +10,7 @@ class Puppet::Provider::Naginator < Puppet::Provider::ParsedFile NAME_STRING = "## --PUPPET_NAME-- (called '_naginator_name' in the manifest)" # Retrieve the associated class from Nagios::Base. def self.nagios_type - unless defined?(@nagios_type) and @nagios_type + unless @nagios_type name = resource_type.name.to_s.sub(/^nagios_/, '') unless @nagios_type = Nagios::Base.type(name.to_sym) raise Puppet::DevError, "Could not find nagios type '#{name}'" diff --git a/lib/puppet/provider/service/daemontools.rb b/lib/puppet/provider/service/daemontools.rb index 934e96aea..7a584a1f9 100644 --- a/lib/puppet/provider/service/daemontools.rb +++ b/lib/puppet/provider/service/daemontools.rb @@ -46,7 +46,7 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do # Determine the daemon path. def defpath(dummy_argument=:work_arround_for_ruby_GC_bug) - unless defined?(@defpath) and @defpath + unless @defpath ["/var/lib/service", "/etc"].each do |path| if FileTest.exist?(path) @defpath = path @@ -87,7 +87,7 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do # find the service dir on this node def servicedir - unless defined?(@servicedir) and @servicedir + unless @servicedir ["/service", "/etc/service","/var/lib/svscan"].each do |path| if FileTest.exist?(path) @servicedir = path diff --git a/lib/puppet/provider/service/runit.rb b/lib/puppet/provider/service/runit.rb index 26c8954e8..c2603c9d8 100644 --- a/lib/puppet/provider/service/runit.rb +++ b/lib/puppet/provider/service/runit.rb @@ -39,7 +39,7 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do # this is necessary to autodetect a valid resource # default path, since there is no standard for such directory. def defpath(dummy_argument=:work_arround_for_ruby_GC_bug) - unless defined?(@defpath) and @defpath + unless @defpath ["/etc/sv", "/var/lib/service"].each do |path| if FileTest.exist?(path) @defpath = path @@ -54,7 +54,7 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do # find the service dir on this node def servicedir - unless defined?(@servicedir) and @servicedir + unless @servicedir ["/service", "/etc/service","/var/service"].each do |path| if FileTest.exist?(path) @servicedir = path diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb index 3e699006d..b5f173718 100644 --- a/lib/puppet/resource/catalog.rb +++ b/lib/puppet/resource/catalog.rb @@ -173,7 +173,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph @resource_table.values.each { |resource| resource.remove } if remove_resources @resource_table.clear - if defined?(@relationship_graph) and @relationship_graph + if @relationship_graph @relationship_graph.clear @relationship_graph = nil end @@ -303,7 +303,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph # Create a graph of all of the relationships in our catalog. def relationship_graph - unless defined?(@relationship_graph) and @relationship_graph + unless @relationship_graph # It's important that we assign the graph immediately, because # the debug messages below use the relationships in the # relationship graph to determine the path to the resources diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb index 24f4399cc..18bca611c 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 defined?(@reversal) and @reversal + @reversal = reversal unless @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/host.rb b/lib/puppet/ssl/host.rb index cfc40fd1f..ae91ceafb 100644 --- a/lib/puppet/ssl/host.rb +++ b/lib/puppet/ssl/host.rb @@ -203,7 +203,7 @@ class Puppet::SSL::Host # Create/return a store that uses our SSL info to validate # connections. def ssl_store(purpose = OpenSSL::X509::PURPOSE_ANY) - unless defined?(@ssl_store) and @ssl_store + unless @ssl_store @ssl_store = OpenSSL::X509::Store.new @ssl_store.purpose = purpose diff --git a/lib/puppet/sslcertificates/certificate.rb b/lib/puppet/sslcertificates/certificate.rb index 1a5c31d18..92a2a7c88 100644 --- a/lib/puppet/sslcertificates/certificate.rb +++ b/lib/puppet/sslcertificates/certificate.rb @@ -23,7 +23,7 @@ class Puppet::SSLCertificates::Certificate File.unlink(file) if FileTest.exists?(file) } - if defined?(@hash) and @hash + if @hash File.unlink(@hash) if FileTest.symlink?(@hash) end end @@ -120,7 +120,7 @@ class Puppet::SSLCertificates::Certificate # this only works for servers, not for users def mkcsr - self.getkey unless defined?(@key) and @key + self.getkey unless @key name = OpenSSL::X509::Name.new self.subject @@ -178,9 +178,9 @@ class Puppet::SSLCertificates::Certificate end def mkselfsigned - self.getkey unless defined?(@key) and @key + self.getkey unless @key - raise Puppet::Error, "Cannot replace existing certificate" if defined?(@cert) and @cert + raise Puppet::Error, "Cannot replace existing certificate" if @cert args = { :name => self.certname, @@ -228,7 +228,7 @@ class Puppet::SSLCertificates::Certificate files[@cacertfile] = @cacert if defined?(@cacert) files.each { |file,thing| - if defined?(thing) and thing + if thing next if FileTest.exists?(file) text = nil diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb index c0b3edcfc..b97817c85 100644 --- a/lib/puppet/transportable.rb +++ b/lib/puppet/transportable.rb @@ -157,7 +157,7 @@ module Puppet # Convert to a parseable manifest def to_manifest unless self.top - raise Puppet::DevError, "No keyword; cannot convert to manifest" unless defined?(@keyword) and @keyword + raise Puppet::DevError, "No keyword; cannot convert to manifest" unless @keyword end str = "#{@keyword} #{@name} {\n%s\n}" diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index f84abd449..47e015168 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -572,7 +572,7 @@ class Type # Once an object is managed, it always stays managed; but an object # that is listed as unmanaged might become managed later in the process, # so we have to check that every time - if defined?(@managed) and @managed + if @managed return @managed else @managed = false @@ -593,7 +593,7 @@ class Type # this is a retarded hack method to get around the difference between # component children and file children def self.depthfirst? - defined?(@depthfirst) && @depthfirst + @depthfirst end def depthfirst? @@ -1328,7 +1328,7 @@ class Type # Find the default provider. def self.defaultprovider - unless defined?(@defaultprovider) and @defaultprovider + unless @defaultprovider suitable = suitableprovider() # Find which providers are a default for this system. @@ -1824,7 +1824,7 @@ class Type # Retrieve the title of an object. If no title was set separately, # then use the object's name. def title - unless defined?(@title) and @title + unless @title if self.class.validparameter?(name_var) @title = self[:name] elsif self.class.validproperty?(name_var) diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb index 9d5d2f45d..856ea7cc9 100755 --- a/lib/puppet/type/cron.rb +++ b/lib/puppet/type/cron.rb @@ -54,7 +54,7 @@ Puppet::Type.newtype(:cron) do # We have to override the parent method, because we consume the entire # "should" array def insync?(is) - if defined?(@should) and @should + if @should self.is_to_s(is) == self.should_to_s else true diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index a823ea9a5..0f1f5d81b 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -330,7 +330,7 @@ Puppet::Type.newtype(:file) do end def bucket - return @bucket if defined?(@bucket) and @bucket + return @bucket if @bucket backup = self[:backup] return nil unless backup diff --git a/lib/puppet/type/file/mode.rb b/lib/puppet/type/file/mode.rb index d38157b7d..03cb63f4b 100755 --- a/lib/puppet/type/file/mode.rb +++ b/lib/puppet/type/file/mode.rb @@ -99,7 +99,7 @@ module Puppet if stat = @resource.stat(false) unless defined?(@fixed) - @should = @should.collect { |s| self.dirmask(s) } if defined?(@should) and @should + @should = @should.collect { |s| self.dirmask(s) } if @should end return stat.mode & 007777 else diff --git a/lib/puppet/util/cacher.rb b/lib/puppet/util/cacher.rb index d229c40ca..8a0acc82f 100644 --- a/lib/puppet/util/cacher.rb +++ b/lib/puppet/util/cacher.rb @@ -58,7 +58,7 @@ module Puppet::Util::Cacher end def attr_ttl(name) - return nil unless defined?(@attr_ttls) and @attr_ttls + return nil unless @attr_ttls @attr_ttls[name] end @@ -122,7 +122,7 @@ module Puppet::Util::Cacher end def value_cache - @value_cache = {} unless defined?(@value_cache) and @value_cache + @value_cache = {} unless @value_cache @value_cache end end diff --git a/lib/puppet/util/docs.rb b/lib/puppet/util/docs.rb index beed4bb0b..d247ec044 100644 --- a/lib/puppet/util/docs.rb +++ b/lib/puppet/util/docs.rb @@ -22,7 +22,7 @@ module Puppet::Util::Docs self.send(m) }.join(" ") - if defined?(@doc) and @doc + if @doc @doc + extra else extra diff --git a/lib/puppet/util/inline_docs.rb b/lib/puppet/util/inline_docs.rb index 695b8e8df..b04b40a22 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 defined?(@doc) and @doc + @doc = "" unless @doc @doc end diff --git a/lib/puppet/util/ldap/generator.rb b/lib/puppet/util/ldap/generator.rb index fb4915100..2320c203c 100644 --- a/lib/puppet/util/ldap/generator.rb +++ b/lib/puppet/util/ldap/generator.rb @@ -30,7 +30,7 @@ class Puppet::Util::Ldap::Generator end def source - if defined?(@source) and @source + if @source @source.to_s else nil diff --git a/lib/puppet/util/ldap/manager.rb b/lib/puppet/util/ldap/manager.rb index b1048a1a3..3e3c54562 100644 --- a/lib/puppet/util/ldap/manager.rb +++ b/lib/puppet/util/ldap/manager.rb @@ -46,7 +46,7 @@ class Puppet::Util::Ldap::Manager def connect raise ArgumentError, "You must pass a block to #connect" unless block_given? - unless defined?(@connection) and @connection + unless @connection if Puppet[:ldaptls] ssl = :tls elsif Puppet[:ldapssl] diff --git a/lib/puppet/util/settings/file_setting.rb b/lib/puppet/util/settings/file_setting.rb index 351a1ae81..ee17d7ddc 100644 --- a/lib/puppet/util/settings/file_setting.rb +++ b/lib/puppet/util/settings/file_setting.rb @@ -23,7 +23,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting end def group - return unless defined?(@group) && @group + return unless @group @settings[:group] end @@ -36,7 +36,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting end def owner - return unless defined?(@owner) && @owner + return unless @owner return "root" if @owner == "root" or ! use_service_user? @settings[:user] end diff --git a/lib/puppet/util/settings/setting.rb b/lib/puppet/util/settings/setting.rb index ba7e4b526..a14dcf050 100644 --- a/lib/puppet/util/settings/setting.rb +++ b/lib/puppet/util/settings/setting.rb @@ -50,11 +50,11 @@ class Puppet::Util::Settings::Setting end def iscreated? - defined?(@iscreated) && @iscreated + @iscreated end def set? - !!(defined?(@value) and ! @value.nil?) + !!(!@value.nil?) end # short name for the celement @@ -68,7 +68,7 @@ class Puppet::Util::Settings::Setting str = @desc.gsub(/^/, "# ") + "\n" # Add in a statement about the default. - str += "# The default value is '#{@default}'.\n" if defined?(@default) and @default + str += "# The default value is '#{@default}'.\n" if @default # If the value has not been overridden, then print it out commented # and unconverted, so it's clear that that's the default and how it diff --git a/lib/puppet/util/storage.rb b/lib/puppet/util/storage.rb index f821c8fd7..6927092de 100644 --- a/lib/puppet/util/storage.rb +++ b/lib/puppet/util/storage.rb @@ -47,7 +47,7 @@ class Puppet::Util::Storage Puppet.settings.use(:main) unless FileTest.directory?(Puppet[:statedir]) unless File.exists?(Puppet[:statefile]) - self.init unless defined?(@@state) and ! @@state.nil? + self.init unless !@@state.nil? return end unless File.file?(Puppet[:statefile]) |