These are a grab-bag of code simplification changes I made in
the process of figuring out what was going on with #2881; they
should all be absolutely behavior neutral.

Signed-off-by: Markus Roberts <[email protected]>
---
 lib/puppet/application/ralsh.rb       |   31 ++++++++-----------------------
 lib/puppet/network/client/resource.rb |   17 ++---------------
 2 files changed, 10 insertions(+), 38 deletions(-)

diff --git a/lib/puppet/application/ralsh.rb b/lib/puppet/application/ralsh.rb
index 6ad520d..a9921d7 100644
--- a/lib/puppet/application/ralsh.rb
+++ b/lib/puppet/application/ralsh.rb
@@ -38,25 +38,16 @@ Puppet::Application.new(:ralsh) do
     end
 
     command(:main) do
-        if ARGV.length > 0
-            type = ARGV.shift
-        else
-            raise "You must specify the type to display"
-        end
-
-        name = nil
+        type = ARGV.shift or raise "You must specify the type to display"
+        typeobj = Puppet::Type.type(type) or raise "Could not find type 
#{type}"
+        name = ARGV.shift
         params = {}
-        if ARGV.length > 0
-            name = ARGV.shift
-        end
 
-        if ARGV.length > 0
-            ARGV.each do |setting|
-                if setting =~ /^(\w+)=(.+)$/
-                    params[$1] = $2
-                else
-                    raise "Invalid parameter setting %s" % setting
-                end
+        ARGV.each do |setting|
+            if setting =~ /^(\w+)=(.+)$/
+                params[$1] = $2
+            else
+                raise "Invalid parameter setting %s" % setting
             end
         end
 
@@ -64,12 +55,6 @@ Puppet::Application.new(:ralsh) do
             raise "You cannot edit a remote host"
         end
 
-        typeobj = nil
-
-        unless typeobj = Puppet::Type.type(type)
-            raise "Could not find type %s" % type
-        end
-
         properties = typeobj.properties.collect { |s| s.name }
 
         format = proc {|trans|
diff --git a/lib/puppet/network/client/resource.rb 
b/lib/puppet/network/client/resource.rb
index bc4a8e5..ad32106 100644
--- a/lib/puppet/network/client/resource.rb
+++ b/lib/puppet/network/client/resource.rb
@@ -27,25 +27,12 @@ class Puppet::Network::Client::Resource < 
Puppet::Network::Client
     def describe(type, name, retrieve = false, ignore = false)
         Puppet.info "Describing %s[%s]" % [type.to_s.capitalize, name]
         text = @driver.describe(type, name, retrieve, ignore, "yaml")
-
-        object = nil
-        if @local
-            object = text
-        else
-            object = YAML::load(Base64.decode64(text))
-        end
-
-        return object
+        @local ? text : YAML::load(Base64.decode64(text))
     end
 
     def list(type, ignore = false, base = false)
         bucket = @driver.list(type, ignore, base, "yaml")
-
-        unless @local
-            bucket = YAML::load(Base64.decode64(bucket))
-        end
-
-        return bucket
+        @local ? bucket : YAML::load(Base64.decode64(bucket))
     end
 end
 
-- 
1.6.4

--

You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.


Reply via email to