http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/proton-c/bindings/ruby/lib/messenger/tracker_status.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/messenger/tracker_status.rb b/proton-c/bindings/ruby/lib/messenger/tracker_status.rb index 81c9ea3..6eea9ce 100644 --- a/proton-c/bindings/ruby/lib/messenger/tracker_status.rb +++ b/proton-c/bindings/ruby/lib/messenger/tracker_status.rb @@ -17,57 +17,53 @@ # under the License. #++ -module Qpid # :nodoc: +module Qpid::Proton::Messenger - module Proton # :nodoc: + # TrackerStatus contains symbols that represent the status value for a + # Tracker. + # + class TrackerStatus - # TrackerStatus contains symbols that represent the status value for a - # Tracker. - # - class TrackerStatus - - def initialize value, name # :nodoc: - @value = value - @name = name - end - - def value # :nodoc: - @value - end - - def to_s # :nodoc: - @name.to_s - end + def initialize value, name # :nodoc: + @value = value + @name = name + end - def self.by_name(name) # :nodoc: - @by_name[name.to_sym] unless name.nil? - end + def value # :nodoc: + @value + end - def self.by_value(value) # :nodoc: - @by_value[value] unless value.nil? - end + def to_s # :nodoc: + @name.to_s + end - private + def self.by_name(name) # :nodoc: + @by_name[name.to_sym] unless name.nil? + end - def self.add_item(key, value) # :nodoc: - @by_name ||= {} - @by_name[key] = TrackerStatus.new value, key - @by_value ||= {} - @by_value[value] = @by_name[key] - end + def self.by_value(value) # :nodoc: + @by_value[value] unless value.nil? + end - def self.const_missing(key) # :nodoc: - @by_name[key] - end + private - self.add_item :UNKNOWN, Cproton::PN_STATUS_UNKNOWN - self.add_item :PENDING, Cproton::PN_STATUS_PENDING - self.add_item :ACCEPTED, Cproton::PN_STATUS_ACCEPTED - self.add_item :REJECTED, Cproton::PN_STATUS_REJECTED - self.add_item :SETTLED, Cproton::PN_STATUS_SETTLED + def self.add_item(key, value) # :nodoc: + @by_name ||= {} + @by_name[key] = TrackerStatus.new value, key + @by_value ||= {} + @by_value[value] = @by_name[key] + end + def self.const_missing(key) # :nodoc: + @by_name[key] end + self.add_item :UNKNOWN, Cproton::PN_STATUS_UNKNOWN + self.add_item :PENDING, Cproton::PN_STATUS_PENDING + self.add_item :ACCEPTED, Cproton::PN_STATUS_ACCEPTED + self.add_item :REJECTED, Cproton::PN_STATUS_REJECTED + self.add_item :SETTLED, Cproton::PN_STATUS_SETTLED + end end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/proton-c/bindings/ruby/lib/types/array.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/types/array.rb b/proton-c/bindings/ruby/lib/types/array.rb index a4294a3..5677295 100644 --- a/proton-c/bindings/ruby/lib/types/array.rb +++ b/proton-c/bindings/ruby/lib/types/array.rb @@ -22,38 +22,37 @@ # to a Qpid::Proton::Data instance. #++ -module Qpid # :nodoc: - - module Proton # :nodoc: - - # Holds the information for an AMQP Array compound type. - # - # It holds the type for the array and the descriptor if the - # array is described. - # - class ArrayHeader - attr_reader :type - attr_reader :descriptor - - def initialize(type, descriptor = nil) - @type = type - @descriptor = descriptor - end +module Qpid::Proton::Types - # Returns true if the array is described. - def described? - !@descriptor.nil? - end + # Holds the information for an AMQP Array compound type. + # + # It holds the type for the array and the descriptor if the + # array is described. + # + # @private + # + class ArrayHeader + attr_reader :type + attr_reader :descriptor - def ==(that) - ((@type == that.type) && (@descriptor == that.descriptor)) - end + def initialize(type, descriptor = nil) + @type = type + @descriptor = descriptor + end + + # Returns true if the array is described. + def described? + !@descriptor.nil? end + def ==(that) + ((@type == that.type) && (@descriptor == that.descriptor)) + end end end +# @private class Array # :nodoc: # Used to declare an array as an AMQP array. http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/proton-c/bindings/ruby/lib/types/described.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/types/described.rb b/proton-c/bindings/ruby/lib/types/described.rb index 98679c2..ca9fa24 100644 --- a/proton-c/bindings/ruby/lib/types/described.rb +++ b/proton-c/bindings/ruby/lib/types/described.rb @@ -17,48 +17,45 @@ # under the License. #++ -module Qpid # :nodoc: +module Qpid::Proton::Types - module Proton # :nodoc: + # @private + class Described - class Described + attr_reader :descriptor + attr_reader :value - attr_reader :descriptor - attr_reader :value - - def initialize(descriptor, value) - @descriptor = descriptor - @value = value - end - - # Puts the description into the Data object. - # - # ==== Arguments - # - # * data - the Qpid::Proton::Data instance - # - # ==== Examples - # - # described = Qpid::Proton::Described.new("my-descriptor", "the value") - # data = Qpid::Proton::Data.new - # ... - # described.put(data) - # - def put(data) - data.symbol = @descriptor - data.string = @value - end + def initialize(descriptor, value) + @descriptor = descriptor + @value = value + end - def ==(that) # :nodoc: - (that.is_a?(Qpid::Proton::Described) && - (self.descriptor == that.descriptor) && - (self.value == that.value)) - end + # Puts the description into the Data object. + # + # ==== Arguments + # + # * data - the Qpid::Proton::Data instance + # + # ==== Examples + # + # described = Qpid::Proton::Described.new("my-descriptor", "the value") + # data = Qpid::Proton::Data.new + # ... + # described.put(data) + # + def put(data) + data.symbol = @descriptor + data.string = @value + end - def to_s # :nodoc: - "descriptor=#{descriptor} value=#{value}" - end + def ==(that) # :nodoc: + (that.is_a?(Qpid::Proton::Described) && + (self.descriptor == that.descriptor) && + (self.value == that.value)) + end + def to_s # :nodoc: + "descriptor=#{descriptor} value=#{value}" end end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/proton-c/bindings/ruby/lib/types/hash.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/types/hash.rb b/proton-c/bindings/ruby/lib/types/hash.rb index 1e19da1..f2e6117 100644 --- a/proton-c/bindings/ruby/lib/types/hash.rb +++ b/proton-c/bindings/ruby/lib/types/hash.rb @@ -22,6 +22,7 @@ # to a Qpid::Proton::Data instance. #++ +# @private class Hash # :nodoc: # Places the contents of the hash into the specified data object. @@ -59,7 +60,7 @@ class Hash # :nodoc: type = data.type - raise TypeError, "element is not a map" unless type == Qpid::Proton::MAP + raise TypeError, "element is not a map" unless type == Qpid::Proton::Codec::MAP count = data.map result = {} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/proton-c/bindings/ruby/lib/types/strings.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/types/strings.rb b/proton-c/bindings/ruby/lib/types/strings.rb index 0b21886..ffbea3c 100644 --- a/proton-c/bindings/ruby/lib/types/strings.rb +++ b/proton-c/bindings/ruby/lib/types/strings.rb @@ -17,49 +17,46 @@ # under the License. #++ -module Qpid # :nodoc: +module Qpid::Proton::Types - module Proton # :nodoc: - - def self.is_valid_utf?(value) - # In Ruby 1.9+ we have encoding methods that can check the content of - # the string, so use them to see if what we have is unicode. If so, - # good! If not, then just treat is as binary. - # - # No such thing in Ruby 1.8. So there we need to use Iconv to try and - # convert it to unicode. If it works, good! But if it raises an - # exception then we'll treat it as binary. - if RUBY_VERSION < "1.9" - return true if value.isutf8 - return false - else - return true if (value.encoding == "UTF-8" || - value.encode("UTF-8").valid_encoding?) - - return false - end - end - - # UTFString lets an application explicitly state that a - # string of characters is to be UTF-8 encoded. + # @private + def self.is_valid_utf?(value) + # In Ruby 1.9+ we have encoding methods that can check the content of + # the string, so use them to see if what we have is unicode. If so, + # good! If not, then just treat is as binary. # - class UTFString < ::String + # No such thing in Ruby 1.8. So there we need to use Iconv to try and + # convert it to unicode. If it works, good! But if it raises an + # exception then we'll treat it as binary. + if RUBY_VERSION < "1.9" + return true if value.isutf8 + return false + else + return true if (value.encoding == "UTF-8" || + value.encode("UTF-8").valid_encoding?) + + return false + end + end - def initialize(value) - if !Qpid::Proton.is_valid_utf?(value) - raise RuntimeError.new("invalid UTF string") - end + # UTFString lets an application explicitly state that a + # string of characters is to be UTF-8 encoded. + # + class UTFString < ::String - super(value) + def initialize(value) + if !Qpid::Proton::Types.is_valid_utf?(value) + raise RuntimeError.new("invalid UTF string") end + super(value) end - # BinaryString lets an application explicitly declare that - # a string value represents arbitrary data. - # - class BinaryString < ::String; end - end + # BinaryString lets an application explicitly declare that + # a string value represents arbitrary data. + # + class BinaryString < ::String; end + end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/proton-c/bindings/ruby/lib/util/error_handler.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/util/error_handler.rb b/proton-c/bindings/ruby/lib/util/error_handler.rb index b3707c3..2f43609 100644 --- a/proton-c/bindings/ruby/lib/util/error_handler.rb +++ b/proton-c/bindings/ruby/lib/util/error_handler.rb @@ -17,106 +17,103 @@ # under the License. #++ -module Qpid # :nodoc: +module Qpid::Proton::Util - module Proton # :nodoc: + # Provides mixin functionality for dealing with exception conditions. + # + # @private + module ErrorHandler - # Provides mixin functionality for dealing with exception conditions. - # - module ExceptionHandling - - def self.included(base) - base.extend(self) - - unless defined? base.to_be_wrapped - class << base - @@to_be_wrapped = [] - end - end + def self.included(base) + base.extend(self) - define_method :method_added do |name| - if (!@@to_be_wrapped.nil?) && (@@to_be_wrapped.include? name) - @@to_be_wrapped.delete name - create_exception_handler_wrapper(name) - end + unless defined? base.to_be_wrapped + class << base + @@to_be_wrapped = [] end end - def can_raise_exception(method_names) - # coerce the names to be an array - Array(method_names).each do |method_name| - # if the method doesn't already exist then queue this aliasing - unless self.method_defined? method_name - @@to_be_wrapped ||= [] - @@to_be_wrapped << method_name - else - create_exception_handler_wrapper(method_name) - end + define_method :method_added do |name| + if (!@@to_be_wrapped.nil?) && (@@to_be_wrapped.include? name) + @@to_be_wrapped.delete name + create_exception_handler_wrapper(name) end end + end - def create_exception_handler_wrapper(method_name) - original_method_name = method_name.to_s - wrapped_method_name = "_excwrap_#{original_method_name}" - alias_method wrapped_method_name, original_method_name - define_method original_method_name do |*args, &block| - # need to get a reference to the method object itself since - # calls to Class.send interfere with Messenger.send - method = self.method(wrapped_method_name.to_sym) - rc = method.call(*args, &block) - check_for_error(rc) + def can_raise_error(method_names, error_class = nil) + # coerce the names to be an array + Array(method_names).each do |method_name| + # if the method doesn't already exist then queue this aliasing + unless self.method_defined? method_name + @@to_be_wrapped ||= [] + @@to_be_wrapped << method_name + else + create_exception_handler_wrapper(method_name, error_class) end end + end - # Raises an Proton-specific error if a return code is non-zero. - # - # Expects the class to provide an +error+ method. - def check_for_error(code) + def create_exception_handler_wrapper(method_name, error_class = nil) + original_method_name = method_name.to_s + wrapped_method_name = "_excwrap_#{original_method_name}" + alias_method wrapped_method_name, original_method_name + define_method original_method_name do |*args, &block| + # need to get a reference to the method object itself since + # calls to Class.send interfere with Messenger.send + method = self.method(wrapped_method_name.to_sym) + rc = method.call(*args, &block) + check_for_error(rc, error_class) + end + end - raise ::ArgumentError.new("Invalid error code: #{code}") if code.nil? + # Raises an Proton-specific error if a return code is non-zero. + # + # Expects the class to provide an +error+ method. + def check_for_error(code, error_class = nil) - return code if code > 0 + raise ::ArgumentError.new("Invalid error code: #{code}") if code.nil? - case(code) + return code if code > 0 - when Qpid::Proton::Error::NONE - return + case(code) - when Qpid::Proton::Error::EOS - raise Qpid::Proton::EOSError.new(self.error) + when Qpid::Proton::Error::NONE + return - when Qpid::Proton::Error::ERROR - raise Qpid::Proton::ProtonError.new(self.error) + when Qpid::Proton::Error::EOS + raise Qpid::Proton::EOSError.new(self.error) - when Qpid::Proton::Error::OVERFLOW - raise Qpid::Proton::OverflowError.new(self.error) + when Qpid::Proton::Error::ERROR + raise Qpid::Proton::ProtonError.new(self.error) - when Qpid::Proton::Error::UNDERFLOW - raise Qpid::Proton::UnderflowError.new(self.error) + when Qpid::Proton::Error::OVERFLOW + raise Qpid::Proton::OverflowError.new(self.error) - when Qpid::Proton::Error::ARGUMENT - raise Qpid::Proton::ArgumentError.new(self.error) + when Qpid::Proton::Error::UNDERFLOW + raise Qpid::Proton::UnderflowError.new(self.error) - when Qpid::Proton::Error::STATE - raise Qpid::Proton::StateError.new(self.error) + when Qpid::Proton::Error::ARGUMENT + raise Qpid::Proton::ArgumentError.new(self.error) - when Qpid::Proton::Error::TIMEOUT - raise Qpid::Proton::TimeoutError.new(self.error) + when Qpid::Proton::Error::STATE + raise Qpid::Proton::StateError.new(self.error) - when Qpid::Proton::Error::INPROGRESS - return + when Qpid::Proton::Error::TIMEOUT + raise Qpid::Proton::TimeoutError.new(self.error) - when Qpid::Proton::Error::INTERRUPTED - raise Qpid::Proton::InterruptedError.new(self.error) + when Qpid::Proton::Error::INPROGRESS + return - when Qpid::Proton::Error::INPROGRESS - raise Qpid::Proton::InProgressError.new(self.error) + when Qpid::Proton::Error::INTERRUPTED + raise Qpid::Proton::InterruptedError.new(self.error) - else + when Qpid::Proton::Error::INPROGRESS + raise Qpid::Proton::InProgressError.new(self.error) - raise ::ArgumentError.new("Unknown error code: #{code}") + else - end + raise ::ArgumentError.new("Unknown error code: #{code}") end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/31c3a764/proton-c/bindings/ruby/lib/util/version.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/util/version.rb b/proton-c/bindings/ruby/lib/util/version.rb index ebc92c5..f9962ba 100644 --- a/proton-c/bindings/ruby/lib/util/version.rb +++ b/proton-c/bindings/ruby/lib/util/version.rb @@ -17,16 +17,14 @@ # under the License. #++ -module Qpid # :nodoc: +module Qpid::Proton::Util - module Proton # :nodoc: + # The major version for the underlying Proton library. + # @private + VERSION_MAJOR = Cproton::PN_VERSION_MAJOR - # The major version for the underlying Proton library. - VERSION_MAJOR = Cproton::PN_VERSION_MAJOR - - # The minor version for the underlying Proton library. - VERSION_MINOR = Cproton::PN_VERSION_MINOR - - end + # The minor version for the underlying Proton library. + # @private + VERSION_MINOR = Cproton::PN_VERSION_MINOR end --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org