diff options
| author | Markus Roberts <Markus@reality.com> | 2010-07-09 18:12:17 -0700 |
|---|---|---|
| committer | Markus Roberts <Markus@reality.com> | 2010-07-09 18:12:17 -0700 |
| commit | 3180b9d9b2c844dade1d361326600f7001ec66dd (patch) | |
| tree | 98fe7c5ac7eb942aac9c39f019a17b0b3f5a57f4 /lib/puppet/util/queue/stomp.rb | |
| parent | 543225970225de5697734bfaf0a6eee996802c04 (diff) | |
| download | puppet-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/util/queue/stomp.rb')
| -rw-r--r-- | lib/puppet/util/queue/stomp.rb | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/lib/puppet/util/queue/stomp.rb b/lib/puppet/util/queue/stomp.rb index ffe745ff7..c18edae6a 100644 --- a/lib/puppet/util/queue/stomp.rb +++ b/lib/puppet/util/queue/stomp.rb @@ -9,39 +9,39 @@ require 'uri' # consequently, for this client to work, <tt>Puppet[:queue_source]</tt> must use the Stomp::Client URL-like # syntax for identifying the Stomp message broker: <em>login:pass@host.port</em> class Puppet::Util::Queue::Stomp - attr_accessor :stomp_client + attr_accessor :stomp_client - def initialize - begin - uri = URI.parse(Puppet[:queue_source]) - rescue => detail - raise ArgumentError, "Could not create Stomp client instance - queue source #{Puppet[:queue_source]} is invalid: #{detail}" - end - unless uri.scheme == "stomp" - raise ArgumentError, "Could not create Stomp client instance - queue source #{Puppet[:queue_source]} is not a Stomp URL: #{detail}" - end - - begin - self.stomp_client = Stomp::Client.new(uri.user, uri.password, uri.host, uri.port, true) - rescue => detail - raise ArgumentError, "Could not create Stomp client instance with queue source #{Puppet[:queue_source]}: got internal Stomp client error #{detail}" - end + def initialize + begin + uri = URI.parse(Puppet[:queue_source]) + rescue => detail + raise ArgumentError, "Could not create Stomp client instance - queue source #{Puppet[:queue_source]} is invalid: #{detail}" end - - def send_message(target, msg) - stomp_client.send(stompify_target(target), msg, :persistent => true) + unless uri.scheme == "stomp" + raise ArgumentError, "Could not create Stomp client instance - queue source #{Puppet[:queue_source]} is not a Stomp URL: #{detail}" end - def subscribe(target) - stomp_client.subscribe(stompify_target(target), :ack => :client) do |stomp_message| - yield(stomp_message.body) - stomp_client.acknowledge(stomp_message) - end + begin + self.stomp_client = Stomp::Client.new(uri.user, uri.password, uri.host, uri.port, true) + rescue => detail + raise ArgumentError, "Could not create Stomp client instance with queue source #{Puppet[:queue_source]}: got internal Stomp client error #{detail}" end + end - def stompify_target(target) - '/queue/' + target.to_s + def send_message(target, msg) + stomp_client.send(stompify_target(target), msg, :persistent => true) + end + + def subscribe(target) + stomp_client.subscribe(stompify_target(target), :ack => :client) do |stomp_message| + yield(stomp_message.body) + stomp_client.acknowledge(stomp_message) end + end + + def stompify_target(target) + '/queue/' + target.to_s + end - Puppet::Util::Queue.register_queue_type(self, :stomp) + Puppet::Util::Queue.register_queue_type(self, :stomp) end |
