Author: mcpierce
Date: Wed Nov 14 20:15:30 2012
New Revision: 1409367

URL: http://svn.apache.org/viewvc?rev=1409367&view=rev
Log:
NO-JIRA: Provides support for subscriptions to the Ruby language bindings.

Added the new type, Qpid::Proton::Subscription, which encapsulates the
subscription value returned by the underlying C code.

Added:
    qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/subscription.rb
      - copied, changed from r1409366, 
qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton.rb
Modified:
    qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton.rb
    qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb
    qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/messenger_spec.rb

Modified: qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton.rb
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton.rb?rev=1409367&r1=1409366&r2=1409367&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton.rb (original)
+++ qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton.rb Wed Nov 14 
20:15:30 2012
@@ -24,6 +24,7 @@ require "qpid_proton/exceptions"
 require "qpid_proton/exception_handling"
 require "qpid_proton/message_format"
 require "qpid_proton/message"
+require "qpid_proton/subscription"
 require "qpid_proton/tracker_status"
 require "qpid_proton/tracker"
 require "qpid_proton/messenger"

Modified: qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb?rev=1409367&r1=1409366&r2=1409367&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb 
(original)
+++ qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb Wed 
Nov 14 20:15:30 2012
@@ -120,7 +120,9 @@ module Qpid
       #
       def subscribe(address)
         raise TypeError.new("invalid address: #{address}") if address.nil?
-        check_for_error(Cproton.pn_messenger_subscribe(@impl, address))
+        subscription = Cproton.pn_messenger_subscribe(@impl, address)
+        raise Qpid::Proton::ProtonError.new("Subscribe failed") if 
subscription.nil?
+        Qpid::Proton::Subscription.new(subscription)
       end
 
       # Path to a certificate file for the +Messenger+.

Copied: 
qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/subscription.rb (from 
r1409366, qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton.rb)
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/subscription.rb?p2=qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/subscription.rb&p1=qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton.rb&r1=1409366&r2=1409367&rev=1409367&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton.rb (original)
+++ qpid/proton/trunk/proton-c/bindings/ruby/lib/qpid_proton/subscription.rb 
Wed Nov 14 20:15:30 2012
@@ -17,13 +17,25 @@
 # under the License.
 #
 
-require "cproton"
+module Qpid
 
-require "qpid_proton/version"
-require "qpid_proton/exceptions"
-require "qpid_proton/exception_handling"
-require "qpid_proton/message_format"
-require "qpid_proton/message"
-require "qpid_proton/tracker_status"
-require "qpid_proton/tracker"
-require "qpid_proton/messenger"
+  module Proton
+
+    # A +Subscription+ is an opaque object for working with a +Messenger+'s
+    # subscriptions.
+    #
+    class Subscription
+
+      def initialize(impl) # :nodoc:
+          @impl = impl
+      end
+
+      def impl # :nodoc:
+          @impl
+      end
+
+    end
+
+  end
+
+end

Modified: 
qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/messenger_spec.rb
URL: 
http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/messenger_spec.rb?rev=1409367&r1=1409366&r2=1409367&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/messenger_spec.rb 
(original)
+++ qpid/proton/trunk/proton-c/bindings/ruby/spec/qpid/proton/messenger_spec.rb 
Wed Nov 14 20:15:30 2012
@@ -192,9 +192,7 @@ module Qpid
         end
 
         it "can subscribe to an address" do
-          expect{
-            @messenger.subscribe("amqp://~0.0.0.0")
-          }.to_not raise_error
+          @messenger.subscribe("amqp://~0.0.0.0").should_not be_nil
         end
 
         it "does not return a tracker before sending messages" do



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to