You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mc...@apache.org on 2013/07/12 21:13:59 UTC

svn commit: r1502660 - in /qpid/trunk/qpid/cpp/bindings/qpid/ruby: ChangeLog examples/spout.rb

Author: mcpierce
Date: Fri Jul 12 19:13:58 2013
New Revision: 1502660

URL: http://svn.apache.org/r1502660
Log:
QPID-4834: Fixed how Ruby spout example processes connection options

The argument comes in as a string. It is now processed, the keys and
values extracted and put into a proper Hash that is then passed to the
Qpid::Messaging::Connection object.

Modified:
    qpid/trunk/qpid/cpp/bindings/qpid/ruby/ChangeLog
    qpid/trunk/qpid/cpp/bindings/qpid/ruby/examples/spout.rb

Modified: qpid/trunk/qpid/cpp/bindings/qpid/ruby/ChangeLog
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qpid/ruby/ChangeLog?rev=1502660&r1=1502659&r2=1502660&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qpid/ruby/ChangeLog (original)
+++ qpid/trunk/qpid/cpp/bindings/qpid/ruby/ChangeLog Fri Jul 12 19:13:58 2013
@@ -1,3 +1,6 @@
+Version 0.26:
+	* QPID-4834: Ruby client examples incorrectly handles '--connection-options' option
+
 Version 0.24:
 	* No language-specific changes.
 

Modified: qpid/trunk/qpid/cpp/bindings/qpid/ruby/examples/spout.rb
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qpid/ruby/examples/spout.rb?rev=1502660&r1=1502659&r2=1502660&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qpid/ruby/examples/spout.rb (original)
+++ qpid/trunk/qpid/cpp/bindings/qpid/ruby/examples/spout.rb Fri Jul 12 19:13:58 2013
@@ -85,8 +85,9 @@ opts = OptionParser.new do |opts|
     options[:content] = content
   end
 
-  opts.on(nil, "--connection-options VALUE",
+  opts.on("--connection-options VALUE",
           "connection options string in the form {name1:value1, name2:value2}") do |conopts|
+
     options[:connection_options] = conopts
   end
 end
@@ -100,7 +101,27 @@ end
 # now get the non-arg options
 options[:address] = ARGV[0] unless ARGV[0].nil?
 
-connection = Qpid::Messaging::Connection.new :url => options[:broker], :options => options[:connection_options]
+# process the connection options
+unless options[:connection_options].nil?
+  fields = options[:connection_options].gsub(/^{(.*)}$/, '\1')
+  # remove any surrounding braces
+  if /{.*}/ =~ fields
+    fields = fields[1..-2]
+  end
+  # break up the options separated by commas
+  keysvalues = {}
+  fields.split(",").each do |field|
+    if /.+:.+/ =~ field
+      (key, value) = field.split(":")
+      keysvalues[key] = value
+    end
+  end
+  # now store the options
+  options[:connection_options] = keysvalues
+end
+
+connection = Qpid::Messaging::Connection.new(:url => options[:broker],
+                                             :options => options[:connection_options])
 connection.open
 session = connection.create_session
 sender = session.create_sender options[:address]



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org