summaryrefslogtreecommitdiffstats
path: root/lib/puppet/provider
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:05:08 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:05:08 -0700
commiteefccf252527dc5b69af5959b0b0e2ddb5c91b74 (patch)
treea37e13c9cd4aab7e8671004cf4f83000b52c96a8 /lib/puppet/provider
parent184132e07fc1461555cb4da842df15f32842a843 (diff)
Code smell: English names for special globals rather than line-noise
* Replaced 36 occurances of [$][?] with $CHILD_STATUS 3 Examples: The code: print "%s finished with exit code %s\n" % [host, $?.exitstatus] becomes: print "%s finished with exit code %s\n" % [host, $CHILD_STATUS.exitstatus] The code: $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus] becomes: $stderr.puts "Could not find host for PID %s with status %s" % [pid, $CHILD_STATUS.exitstatus] The code: unless $? == 0 becomes: unless $CHILD_STATUS == 0 * Replaced 3 occurances of [$][$] with $PID 3 Examples: The code: Process.kill(:HUP, $$) if restart_requested? becomes: Process.kill(:HUP, $PID) if restart_requested? The code: if pid == $$ becomes: if pid == $PID The code: host[:name] = "!invalid.hostname.$$$" becomes: host[:name] = "!invalid.hostname.$PID$" * Replaced 7 occurances of [$]& with $MATCH 3 Examples: The code: work.slice!(0, $&.length) becomes: work.slice!(0, $MATCH.length) The code: if $& becomes: if $MATCH The code: if $& becomes: if $MATCH * Replaced 28 occurances of [$]:(?!:) with $LOAD_PATH 3 Examples: The code: sitelibdir = $:.find { |x| x =~ /site_ruby/ } becomes: sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ } The code: $:.unshift "lib" becomes: $LOAD_PATH.unshift "lib" The code: $:.shift becomes: $LOAD_PATH.shift * Replaced 3 occurances of [$]! with $ERROR_INFO 3 Examples: The code: $LOG.fatal("Problem reading #{filepath}: #{$!}") becomes: $LOG.fatal("Problem reading #{filepath}: #{$ERROR_INFO}") The code: $stderr.puts "Couldn't build man pages: " + $! becomes: $stderr.puts "Couldn't build man pages: " + $ERROR_INFO The code: $stderr.puts $!.message becomes: $stderr.puts $ERROR_INFO.message * Replaced 3 occurances of ^(.*)[$]" with \1$LOADED_FEATURES 3 Examples: The code: unless $".index 'racc/parser.rb' becomes: unless $LOADED_FEATURES.index 'racc/parser.rb' The code: $".push 'racc/parser.rb' becomes: $LOADED_FEATURES.push 'racc/parser.rb' The code: $".should be_include("tmp/myfile.rb") becomes: $LOADED_FEATURES.should be_include("tmp/myfile.rb")
Diffstat (limited to 'lib/puppet/provider')
-rwxr-xr-xlib/puppet/provider/package/darwinport.rb2
-rwxr-xr-xlib/puppet/provider/service/base.rb2
-rwxr-xr-xlib/puppet/provider/service/debian.rb2
-rwxr-xr-xlib/puppet/provider/service/smf.rb2
-rw-r--r--lib/puppet/provider/zone/solaris.rb2
5 files changed, 5 insertions, 5 deletions
diff --git a/lib/puppet/provider/package/darwinport.rb b/lib/puppet/provider/package/darwinport.rb
index 7829438c5..5cced62d5 100755
--- a/lib/puppet/provider/package/darwinport.rb
+++ b/lib/puppet/provider/package/darwinport.rb
@@ -67,7 +67,7 @@ Puppet::Type.type(:package).provide :darwinport, :parent => Puppet::Provider::Pa
def latest
info = port :search, "^#{@resource[:name]}$"
- if $? != 0 or info =~ /^Error/
+ if $CHILD_STATUS != 0 or info =~ /^Error/
return nil
end
diff --git a/lib/puppet/provider/service/base.rb b/lib/puppet/provider/service/base.rb
index aa11f26fc..2e9ac778a 100755
--- a/lib/puppet/provider/service/base.rb
+++ b/lib/puppet/provider/service/base.rb
@@ -64,7 +64,7 @@ Puppet::Type.type(:service).provide :base do
ucommand(:status, false)
# Expicitly calling exitstatus to facilitate testing
- if $?.exitstatus == 0
+ if $CHILD_STATUS.exitstatus == 0
return :running
else
return :stopped
diff --git a/lib/puppet/provider/service/debian.rb b/lib/puppet/provider/service/debian.rb
index 34e2cf8b1..1f95d66f7 100755
--- a/lib/puppet/provider/service/debian.rb
+++ b/lib/puppet/provider/service/debian.rb
@@ -34,7 +34,7 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do
# 104 is the exit status when you query start an enabled service.
# 106 is the exit status when the policy layer supplies a fallback action
# See x-man-page://invoke-rc.d
- if [104, 106].include?($?.exitstatus)
+ if [104, 106].include?($CHILD_STATUS.exitstatus)
return :true
else
return :false
diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb
index 685889386..72f34ef37 100755
--- a/lib/puppet/provider/service/smf.rb
+++ b/lib/puppet/provider/service/smf.rb
@@ -22,7 +22,7 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
begin
if resource[:manifest]
[command(:svcs), "-l", @resource[:name]]
- if $?.exitstatus == 1
+ if $CHILD_STATUS.exitstatus == 1
Puppet.notice "Importing %s for %s" % [ @resource[:manifest], @resource[:name] ]
svccfg :import, resource[:manifest]
end
diff --git a/lib/puppet/provider/zone/solaris.rb b/lib/puppet/provider/zone/solaris.rb
index 1aaa70d47..4d7e7473d 100644
--- a/lib/puppet/provider/zone/solaris.rb
+++ b/lib/puppet/provider/zone/solaris.rb
@@ -150,7 +150,7 @@ Puppet::Type.type(:zone).provide(:solaris) do
pipe.puts str
end
- unless $? == 0
+ unless $CHILD_STATUS == 0
raise ArgumentError, "Failed to apply configuration"
end
end