You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2018/07/03 22:14:06 UTC
[77/89] [abbrv] qpid-proton git commit: NO-JIRA: [ruby] add
Disposition::State::name_of int values
NO-JIRA: [ruby] add Disposition::State::name_of int values
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8e65759f
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8e65759f
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8e65759f
Branch: refs/heads/go1
Commit: 8e65759f0f1682b5c45e41b67ff049bd3caf04b0
Parents: 2dda72c
Author: Alan Conway <ac...@redhat.com>
Authored: Fri May 11 12:05:33 2018 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri May 11 12:06:10 2018 -0400
----------------------------------------------------------------------
ruby/lib/core/disposition.rb | 30 ++++++++++++++++++++++++------
ruby/lib/core/transfer.rb | 21 +--------------------
ruby/tests/test_delivery.rb | 8 ++++++++
3 files changed, 33 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8e65759f/ruby/lib/core/disposition.rb
----------------------------------------------------------------------
diff --git a/ruby/lib/core/disposition.rb b/ruby/lib/core/disposition.rb
index bbc4b06..9078fc2 100644
--- a/ruby/lib/core/disposition.rb
+++ b/ruby/lib/core/disposition.rb
@@ -18,7 +18,6 @@
module Qpid::Proton
- # @deprecated use {Delivery}
class Disposition
include Util::Deprecation
@@ -27,12 +26,31 @@ module Qpid::Proton
# @private
extend Util::SWIGClassHelper
+ # States of a message transfer
+ module State
+ # Message was successfully processed by the receiver
+ ACCEPTED = Cproton::PN_ACCEPTED
- ACCEPTED = Cproton::PN_ACCEPTED
- REJECTED = Cproton::PN_REJECTED
- RELEASED = Cproton::PN_RELEASED
- MODIFIED = Cproton::PN_MODIFIED
- RECEIVED = Cproton::PN_RECEIVED
+ # Message rejected as invalid and unprocessable by the receiver.
+ REJECTED = Cproton::PN_REJECTED
+
+ # Message was not (and will not be) processed by the receiver, but may be
+ # acceptable if re-delivered to another receiver
+ RELEASED = Cproton::PN_RELEASED
+ # Like {RELEASED}, but there are modifications (see {Tracker#modifications})
+ # that must be applied to the message by the {Sender} before re-delivering it.
+ MODIFIED = Cproton::PN_MODIFIED
+
+ # Partial message data received. Only used during link recovery.
+ RECEIVED = Cproton::PN_RECEIVED
+
+ module ClassMethods
+ def name_of(state) Cproton::pn_disposition_type_name(state); end
+ end
+ extend ClassMethods
+ def self.included(klass) klass.extend ClassMethods; end
+ end
+ include State
attr_reader :impl
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8e65759f/ruby/lib/core/transfer.rb
----------------------------------------------------------------------
diff --git a/ruby/lib/core/transfer.rb b/ruby/lib/core/transfer.rb
index 53adf69..ded3726 100644
--- a/ruby/lib/core/transfer.rb
+++ b/ruby/lib/core/transfer.rb
@@ -42,26 +42,7 @@ module Qpid::Proton
public
- # AMQP Delivery States describing the outcome of a message transfer
- module State
- # Message was successfully processed by the receiver
- ACCEPTED = Cproton::PN_ACCEPTED
-
- # Message rejected as invalid and unprocessable by the receiver.
- REJECTED = Cproton::PN_REJECTED
-
- # Message was not (and will not be) processed by the receiver, but may be
- # acceptable if re-delivered to another receiver
- RELEASED = Cproton::PN_RELEASED
-
- # Like {RELEASED}, but there are modifications (see {Tracker#modifications})
- # that must be applied to the message by the {Sender} before re-delivering it.
- MODIFIED = Cproton::PN_MODIFIED
-
- # Partial message data received. Only used during link recovery.
- RECEIVED = Cproton::PN_RECEIVED
- end
-
+ State = Disposition::State
include State
# @return [String] Unique ID for the transfer in the context of the {#link}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8e65759f/ruby/tests/test_delivery.rb
----------------------------------------------------------------------
diff --git a/ruby/tests/test_delivery.rb b/ruby/tests/test_delivery.rb
index f061665..db50582 100644
--- a/ruby/tests/test_delivery.rb
+++ b/ruby/tests/test_delivery.rb
@@ -107,4 +107,12 @@ class TestDelivery < MiniTest::Test
assert_equal ["accept", "reject", "release-really", "release", "modify", "modify-empty", "modify-nil", "reject-raise", "release-raise"], rh.received
assert_empty sh.unsettled
end
+
+ def test_names
+ names = ["accepted", "rejected", "released", "modified"]
+ states = names.collect { |n| Disposition.const_get(n.upcase) }
+ assert_equal names, states.collect { |s| Disposition::name_of(s) }
+ assert_equal names, states.collect { |s| Disposition::State::name_of(s) }
+ assert_equal names, states.collect { |s| Transfer::name_of(s) }
+ end
end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org