summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network/handler/filebucket.rb
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:12:17 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:12:17 -0700
commit3180b9d9b2c844dade1d361326600f7001ec66dd (patch)
tree98fe7c5ac7eb942aac9c39f019a17b0b3f5a57f4 /lib/puppet/network/handler/filebucket.rb
parent543225970225de5697734bfaf0a6eee996802c04 (diff)
downloadpuppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.gz
puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.xz
puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.zip
Code smell: Two space indentation
Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
Diffstat (limited to 'lib/puppet/network/handler/filebucket.rb')
-rwxr-xr-xlib/puppet/network/handler/filebucket.rb86
1 files changed, 43 insertions, 43 deletions
diff --git a/lib/puppet/network/handler/filebucket.rb b/lib/puppet/network/handler/filebucket.rb
index c0693ad7a..6aaa2df1c 100755
--- a/lib/puppet/network/handler/filebucket.rb
+++ b/lib/puppet/network/handler/filebucket.rb
@@ -3,49 +3,49 @@ require 'digest/md5'
require 'puppet/external/base64'
class Puppet::Network::Handler # :nodoc:
- # Accept files and store them by md5 sum, returning the md5 sum back
- # to the client. Alternatively, accept an md5 sum and return the
- # associated content.
- class FileBucket < Handler
- desc "The interface to Puppet's FileBucket system. Can be used to store
- files in and retrieve files from a filebucket."
-
- @interface = XMLRPC::Service::Interface.new("puppetbucket") { |iface|
- iface.add_method("string addfile(string, string)")
- iface.add_method("string getfile(string)")
- }
-
- Puppet::Util.logmethods(self, true)
- attr_reader :name, :path
-
- def initialize(hash)
- @path = hash[:Path] || Puppet[:bucketdir]
- @name = "Filebucket[#{@path}]"
- end
-
- # Accept a file from a client and store it by md5 sum, returning
- # the sum.
- def addfile(contents, path, client = nil, clientip = nil)
- contents = Base64.decode64(contents) if client
- bucket = Puppet::FileBucket::File.new(contents)
- bucket.save
- end
-
- # Return the contents associated with a given md5 sum.
- def getfile(md5, client = nil, clientip = nil)
- bucket = Puppet::FileBucket::File.find("md5:#{md5}")
- contents = bucket.contents
-
- if client
- return Base64.encode64(contents)
- else
- return contents
- end
- end
-
- def to_s
- self.name
- end
+ # Accept files and store them by md5 sum, returning the md5 sum back
+ # to the client. Alternatively, accept an md5 sum and return the
+ # associated content.
+ class FileBucket < Handler
+ desc "The interface to Puppet's FileBucket system. Can be used to store
+ files in and retrieve files from a filebucket."
+
+ @interface = XMLRPC::Service::Interface.new("puppetbucket") { |iface|
+ iface.add_method("string addfile(string, string)")
+ iface.add_method("string getfile(string)")
+ }
+
+ Puppet::Util.logmethods(self, true)
+ attr_reader :name, :path
+
+ def initialize(hash)
+ @path = hash[:Path] || Puppet[:bucketdir]
+ @name = "Filebucket[#{@path}]"
end
+
+ # Accept a file from a client and store it by md5 sum, returning
+ # the sum.
+ def addfile(contents, path, client = nil, clientip = nil)
+ contents = Base64.decode64(contents) if client
+ bucket = Puppet::FileBucket::File.new(contents)
+ bucket.save
+ end
+
+ # Return the contents associated with a given md5 sum.
+ def getfile(md5, client = nil, clientip = nil)
+ bucket = Puppet::FileBucket::File.find("md5:#{md5}")
+ contents = bucket.contents
+
+ if client
+ return Base64.encode64(contents)
+ else
+ return contents
+ end
+ end
+
+ def to_s
+ self.name
+ end
+ end
end