onstomp 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/.gitignore +4 -0
  2. data/.yardopts +2 -1
  3. data/Rakefile +147 -0
  4. data/extra_doc/API.md +491 -0
  5. data/extra_doc/API.md.erb +33 -0
  6. data/extra_doc/DeveloperNarrative.md +123 -0
  7. data/extra_doc/UserNarrative.md +511 -0
  8. data/lib/onstomp.rb +5 -5
  9. data/lib/onstomp/client.rb +6 -1
  10. data/lib/onstomp/components/frame.rb +6 -6
  11. data/lib/onstomp/components/frame_headers.rb +18 -18
  12. data/lib/onstomp/components/scopes/transaction_scope.rb +11 -11
  13. data/lib/onstomp/components/subscription.rb +2 -2
  14. data/lib/onstomp/components/threaded_processor.rb +1 -1
  15. data/lib/onstomp/components/uri.rb +1 -1
  16. data/lib/onstomp/connections/base.rb +5 -5
  17. data/lib/onstomp/connections/heartbeating.rb +2 -2
  18. data/lib/onstomp/connections/serializers/stomp_1.rb +6 -6
  19. data/lib/onstomp/connections/serializers/stomp_1_1.rb +2 -2
  20. data/lib/onstomp/connections/stomp_1_0.rb +1 -1
  21. data/lib/onstomp/connections/stomp_1_1.rb +1 -1
  22. data/lib/onstomp/failover.rb +4 -0
  23. data/lib/onstomp/failover/buffers.rb +1 -0
  24. data/lib/onstomp/failover/buffers/receipts.rb +101 -0
  25. data/lib/onstomp/failover/buffers/written.rb +2 -2
  26. data/lib/onstomp/failover/client.rb +15 -12
  27. data/lib/onstomp/failover/failover_configurable.rb +3 -3
  28. data/lib/onstomp/failover/pools/base.rb +1 -1
  29. data/lib/onstomp/failover/uri.rb +41 -16
  30. data/lib/onstomp/interfaces/client_configurable.rb +1 -1
  31. data/lib/onstomp/interfaces/client_events.rb +30 -11
  32. data/lib/onstomp/interfaces/connection_events.rb +5 -1
  33. data/lib/onstomp/interfaces/event_manager.rb +2 -2
  34. data/lib/onstomp/interfaces/frame_methods.rb +169 -8
  35. data/lib/onstomp/interfaces/uri_configurable.rb +3 -3
  36. data/lib/onstomp/open-uri/client_extensions.rb +4 -4
  37. data/lib/onstomp/version.rb +2 -2
  38. data/onstomp.gemspec +0 -1
  39. data/spec/onstomp/components/threaded_processor_spec.rb +21 -0
  40. data/spec/onstomp/connections/base_spec.rb +15 -0
  41. data/spec/onstomp/failover/buffers/receipts_spec.rb +189 -0
  42. data/spec/onstomp/failover/buffers/written_spec.rb +167 -1
  43. data/spec/onstomp/failover/client_spec.rb +70 -1
  44. data/spec/onstomp/failover/failover_events_spec.rb +1 -2
  45. data/spec/onstomp/failover/uri_spec.rb +37 -4
  46. data/spec/onstomp/full_stacks/failover_spec.rb +76 -25
  47. data/spec/onstomp/full_stacks/onstomp_spec.rb +52 -8
  48. data/spec/onstomp/full_stacks/onstomp_ssh_spec.rb +83 -0
  49. data/spec/onstomp/full_stacks/test_broker.rb +45 -29
  50. metadata +11 -15
  51. data/DeveloperNarrative.md +0 -15
  52. data/UserNarrative.md +0 -8
@@ -31,7 +31,7 @@ require 'thread'
31
31
  # Monitor support (prevent recursive dead locking)
32
32
  require 'monitor'
33
33
 
34
- # Primary namespace for the +onstomp+ gem
34
+ # Primary namespace for the `onstomp` gem
35
35
  module OnStomp
36
36
  # Class to use for creating enumerator objects, which depends upon the
37
37
  # version of Ruby being used.
@@ -98,11 +98,11 @@ module OnStomp
98
98
  alias :open :connect
99
99
 
100
100
  # Duplicates an existing hash while transforming its keys to symbols.
101
- # The keys must implement the +to_sym+ method, otherwise an exception will
101
+ # The keys must implement the `to_sym` method, otherwise an exception will
102
102
  # be raised. This method is used internally to convert hashes keyed with
103
103
  # Strings.
104
104
  #
105
- # @param [{Object => Object}] hsh The hash to convert. It's keys must respond to +to_sym+.
105
+ # @param [{Object => Object}] hsh The hash to convert. It's keys must respond to `to_sym`.
106
106
  # @return [{Symbol => Object}]
107
107
  # @example
108
108
  # hash = { '10' => nil, 'key2' => [3, 5, 8, 13, 21], :other => :value }
@@ -126,8 +126,8 @@ module OnStomp
126
126
  end
127
127
  end
128
128
 
129
- # Converts a string to the Ruby constant it names. If the +klass+ parameter
130
- # is a kind of +Module+, this method will return +klass+ directly.
129
+ # Converts a string to the Ruby constant it names. If the `klass` parameter
130
+ # is a kind of `Module`, this method will return `klass` directly.
131
131
  # @param [String,Module] klass
132
132
  # @return [Module]
133
133
  # @example
@@ -10,7 +10,7 @@ class OnStomp::Client
10
10
  include OnStomp::Interfaces::SubscriptionManager
11
11
  include OnStomp::Components::Scopes
12
12
 
13
- # The +URI+ reference to the STOMP broker
13
+ # The `URI` reference to the STOMP broker
14
14
  # @return [String]
15
15
  attr_reader :uri
16
16
  # SSL options for the connection
@@ -47,6 +47,7 @@ class OnStomp::Client
47
47
  # @return [Class]
48
48
  attr_configurable_processor :processor
49
49
 
50
+ # @api gem:1 STOMP:1.0,1.1
50
51
  # Creates a new client for the specified uri and optional hash of options.
51
52
  # @param [String,URI] uri
52
53
  # @param [{Symbol => Object}] options
@@ -61,6 +62,7 @@ class OnStomp::Client
61
62
  end
62
63
  end
63
64
 
65
+ # @api gem:1 STOMP:1.0,1.1
64
66
  # Connects to the STOMP broker referenced by {#uri}. Includes optional
65
67
  # headers in the CONNECT frame, if specified.
66
68
  # @param [{#to_sym => #to_s}] headers
@@ -75,6 +77,7 @@ class OnStomp::Client
75
77
  end
76
78
  alias :open :connect
77
79
 
80
+ # @api gem:1 STOMP:1.0,1.1
78
81
  # Sends a DISCONNECT frame to the broker and blocks until the connection
79
82
  # has been closed. This method ensures that all frames not yet sent to
80
83
  # the broker will get processed barring any IO exceptions.
@@ -89,12 +92,14 @@ class OnStomp::Client
89
92
  alias :disconnect_without_flush :disconnect
90
93
  alias :disconnect :disconnect_with_flush
91
94
 
95
+ # @api gem:1 STOMP:1.0,1.1
92
96
  # Returns true if a connection to the broker exists and itself is connected.
93
97
  # @return [true,false]
94
98
  def connected?
95
99
  connection && connection.connected?
96
100
  end
97
101
 
102
+ # @api gem:1 STOMP:1.0,1.1
98
103
  # Forces the connection between broker and client closed.
99
104
  # @note Use of this method may result in frames never being sent to the
100
105
  # broker. This method should only be used if {#disconnect} is not an
@@ -13,8 +13,8 @@ class OnStomp::Components::Frame
13
13
  attr_reader :headers
14
14
 
15
15
  # Creates a new frame. The frame will be initialized with the optional
16
- # +command+ name, a {OnStomp::Components::FrameHeaders headers} collection initialized
17
- # with the optional +headers+ hash, and an optional body.
16
+ # `command` name, a {OnStomp::Components::FrameHeaders headers} collection initialized
17
+ # with the optional `headers` hash, and an optional body.
18
18
  def initialize(command=nil, headers={}, body=nil)
19
19
  @command = command
20
20
  @headers = OnStomp::Components::FrameHeaders.new(headers)
@@ -26,7 +26,7 @@ class OnStomp::Components::Frame
26
26
  #
27
27
  # @param [Object] name the header name associated with the desired value
28
28
  # @return [String] the value associated with the requested header name
29
- # @see OnStomp::Headers#[]
29
+ # @see OnStomp::Components::FrameHeaders#[]
30
30
  # @example
31
31
  # frame['content-type'] #=> 'text/plain'
32
32
  def [](name); @headers[name]; end
@@ -37,7 +37,7 @@ class OnStomp::Components::Frame
37
37
  # @param [Object] name the header name to associate with the supplied value
38
38
  # @param [Object] val the value to associate with the supplied header name
39
39
  # @return [String] the supplied value as a string, or `nil` if `nil` was supplied as the value.
40
- # @see OnStomp::Headers#[]=
40
+ # @see OnStomp::Components::FrameHeaders#[]=
41
41
  # @example
42
42
  # frame['content-type'] = 'text/plain' #=> 'text/plain'
43
43
  # frame['other header'] = 42 #=> '42'
@@ -52,9 +52,9 @@ class OnStomp::Components::Frame
52
52
 
53
53
  # If a +content-type+ header is set, splits it into three parts: type,
54
54
  # subtype and charset. If any component of the +content-type+ is missing,
55
- # its value will be +nil+ in the returned triple. If the +content-type+
55
+ # its value will be `nil` in the returned triple. If the +content-type+
56
56
  # header is not set or does not match {OnStomp::Components::Frame::CONTENT_TYPE_REG}
57
- # all values in the triple will be +nil+.
57
+ # all values in the triple will be `nil`.
58
58
  # @return [Array<String,nil>]
59
59
  def content_type
60
60
  @headers[:'content-type'] =~ CONTENT_TYPE_REG ? [$1, $2, $3] : [nil, nil, nil]
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  # A specialized container for storing header name / value pairs for a
4
- # {OnStomp::Components::Frame frame}. This container behaves much like a +Hash+, but
4
+ # {OnStomp::Components::Frame frame}. This container behaves much like a `Hash`, but
5
5
  # is specialized for the Stomp protocol. Header names are always converted
6
- # into +String+s through the use of +to_s+ and may have more than one value
6
+ # into `String`s through the use of `to_s` and may have more than one value
7
7
  # associated with them.
8
8
  class OnStomp::Components::FrameHeaders
9
9
  include Enumerable
@@ -19,7 +19,7 @@ class OnStomp::Components::FrameHeaders
19
19
  end
20
20
 
21
21
  # Merges a hash into this collection of headers. All of the keys used
22
- # in the hash must be convertable to Symbols through +to_sym+.
22
+ # in the hash must be convertable to Symbols through `to_sym`.
23
23
  # @note With Ruby 1.8.7, the order of hash keys may not be preserved
24
24
  # @param [Hash] hash
25
25
  def merge!(hash)
@@ -29,7 +29,7 @@ class OnStomp::Components::FrameHeaders
29
29
  # Reverse merges a hash into this collection of headers. The hash keys and
30
30
  # values are included only if the headers collection does not already have
31
31
  # a matching key. All of the keys used
32
- # in the hash must be convertable to Symbols through +to_sym+.
32
+ # in the hash must be convertable to Symbols through `to_sym`.
33
33
  # @note With Ruby 1.8.7, the order of hash keys may not be preserved
34
34
  # @param [Hash] hash
35
35
  def reverse_merge!(hash)
@@ -48,7 +48,7 @@ class OnStomp::Components::FrameHeaders
48
48
  end
49
49
 
50
50
  # Returns true if a header value has been set for the supplied header, and
51
- # the value is neither +nil+ nor an empty string.
51
+ # the value is neither `nil` nor an empty string.
52
52
  # @param [#to_sym] name the header name to test
53
53
  # @return [Boolean]
54
54
  # @example
@@ -68,7 +68,7 @@ class OnStomp::Components::FrameHeaders
68
68
  # element of the array will be the principle value of the supplied
69
69
  # header name.
70
70
  #
71
- # @param [#to_sym] name the header name associated with the desired values (will be converted using +to_sym+)
71
+ # @param [#to_sym] name the header name associated with the desired values (will be converted using `to_sym`)
72
72
  # @return [Array] the array of values associated with the header name.
73
73
  # @example
74
74
  # headers.all_values('content-type') #=> [ 'text/plain' ]
@@ -83,8 +83,8 @@ class OnStomp::Components::FrameHeaders
83
83
  # principle value. This method is used internally when constructing
84
84
  # frames sent by the broker to capture repeated header names.
85
85
  #
86
- # @param [#to_sym] name the header name to associate with the supplied value (will be converted using +to_s+)
87
- # @param [#to_s] val the header value to associate with the supplied name (will be converted using +to_s+)
86
+ # @param [#to_sym] name the header name to associate with the supplied value (will be converted using `to_s`)
87
+ # @param [#to_s] val the header value to associate with the supplied name (will be converted using `to_s`)
88
88
  # @return [String] the supplied value as a string.
89
89
  # @example
90
90
  # headers.append(:'new header', 'first value') #=> 'first value'
@@ -104,11 +104,11 @@ class OnStomp::Components::FrameHeaders
104
104
  end
105
105
 
106
106
  # Deletes all of the header values associated with the header name and
107
- # removes the header name itself. This is analogous to the +delete+
107
+ # removes the header name itself. This is analogous to the `delete`
108
108
  # method found in Hash objects.
109
109
  #
110
- # @param [#to_sym] name the header name to remove from this collection (will be converted using +to_sym+)
111
- # @return [Array] the array of values associated with the deleted header, or +nil+ if the header name did not exist
110
+ # @param [#to_sym] name the header name to remove from this collection (will be converted using `to_sym`)
111
+ # @return [Array] the array of values associated with the deleted header, or `nil` if the header name did not exist
112
112
  # @example
113
113
  # headers.delete(:'content-type') #=> [ 'text/html' ]
114
114
  # headers.delete('no such header') #=> nil
@@ -121,11 +121,11 @@ class OnStomp::Components::FrameHeaders
121
121
  end
122
122
 
123
123
  # Gets the principle header value paired with the supplied header name. The name will
124
- # be converted to a Symbol, so must respond to the +to_sym+ method. The
124
+ # be converted to a Symbol, so must respond to the `to_sym` method. The
125
125
  # Stomp 1.1 protocol specifies that in the event of a repeated header name,
126
126
  # the first value encountered serves as the principle value.
127
127
  #
128
- # @param [#to_sym] name the header name paired with the desired value (will be converted using +to_sym+)
128
+ # @param [#to_sym] name the header name paired with the desired value (will be converted using `to_sym`)
129
129
  # @return [String] the value associated with the requested header name
130
130
  # @return [nil] if no value has been set for the associated header name
131
131
  # @example
@@ -136,12 +136,12 @@ class OnStomp::Components::FrameHeaders
136
136
  end
137
137
 
138
138
  # Sets the header value paired with the supplied header name. The name
139
- # will be converted to a Symbol and must respond to +to_sym+; meanwhile,
140
- # the value will be converted to a String so must respond to +to_s+.
139
+ # will be converted to a Symbol and must respond to `to_sym`; meanwhile,
140
+ # the value will be converted to a String so must respond to `to_s`.
141
141
  # Setting a header value in this fashion will overwrite any repeated header values.
142
142
  #
143
- # @param [#to_sym] name the header name to associate with the supplied value (will be converted using +to_sym+)
144
- # @param [#to_s] val the value to pair with the supplied name (will be converted using +to_s+)
143
+ # @param [#to_sym] name the header name to associate with the supplied value (will be converted using `to_sym`)
144
+ # @param [#to_s] val the value to pair with the supplied name (will be converted using `to_s`)
145
145
  # @return [String] the supplied value as a string.
146
146
  # @example
147
147
  # headers['content-type'] = 'image/png' #=> 'image/png'
@@ -155,7 +155,7 @@ class OnStomp::Components::FrameHeaders
155
155
  val
156
156
  end
157
157
 
158
- # Returns a new +Hash+ object associating symbolized header names and their
158
+ # Returns a new `Hash` object associating symbolized header names and their
159
159
  # principle values.
160
160
  # @return [Hash]
161
161
  def to_hash
@@ -8,7 +8,7 @@
8
8
  class OnStomp::Components::Scopes::TransactionScope
9
9
  include OnStomp::Interfaces::FrameMethods
10
10
 
11
- # The id of the current transaction. This may be +nil+ if the transaction
11
+ # The id of the current transaction. This may be `nil` if the transaction
12
12
  # has not been started with {#begin} or if the transaction has been completed
13
13
  # by a call to either {#abort} or {#commit}.
14
14
  # @return [String,nil]
@@ -18,7 +18,7 @@ class OnStomp::Components::Scopes::TransactionScope
18
18
  # @return [OnStomp::Client]
19
19
  attr_reader :client
20
20
 
21
- # A reference to +self+ to trick {OnStomp::Interfaces::FrameMethods} into
21
+ # A reference to `self` to trick {OnStomp::Interfaces::FrameMethods} into
22
22
  # creating frames on this object instead of the client's actual
23
23
  # {OnStomp::Client#connection connection}.
24
24
  # @return [self]
@@ -89,9 +89,9 @@ class OnStomp::Components::Scopes::TransactionScope
89
89
 
90
90
  # Overrides the {OnStomp::Connections::Stomp_1#send_frame send_frame} method
91
91
  # of the {OnStomp::Client#connection client's connection}, setting a
92
- # +transaction+ header to match the current transaction if it has been
92
+ # `transaction` header to match the current transaction if it has been
93
93
  # started.
94
- # @param [arg1, arg2, ...] args arguments to connection's +send_frame+ method
94
+ # @param [arg1, arg2, ...] args arguments to connection's `send_frame` method
95
95
  # @return [OnStomp::Components::Frame] SEND frame
96
96
  def send_frame *args, &blk
97
97
  client.connection.send_frame(*args,&blk).tap do |f|
@@ -101,9 +101,9 @@ class OnStomp::Components::Scopes::TransactionScope
101
101
 
102
102
  # Overrides the {OnStomp::Connections::Stomp_1_0#ack_frame ack_frame} method
103
103
  # of the client's {OnStomp::Client#connection connection}, setting a
104
- # +transaction+ header to match the current transaction if it has been
104
+ # `transaction` header to match the current transaction if it has been
105
105
  # started.
106
- # @param [arg1, arg2, ...] args arguments to connection's +ack_frame+ method
106
+ # @param [arg1, arg2, ...] args arguments to connection's `ack_frame` method
107
107
  # @return [OnStomp::Components::Frame] ACK frame
108
108
  def ack_frame *args
109
109
  client.connection.ack_frame(*args).tap do |f|
@@ -113,9 +113,9 @@ class OnStomp::Components::Scopes::TransactionScope
113
113
 
114
114
  # Overrides the {OnStomp::Connections::Stomp_1_1#nack_frame nack_frame} method
115
115
  # of the {OnStomp::Client#connection client's connection}, setting a
116
- # +transaction+ header to match the current transaction if it has been
116
+ # `transaction` header to match the current transaction if it has been
117
117
  # started.
118
- # @param [arg1, arg2, ...] args arguments to connection's +nack_frame+ method
118
+ # @param [arg1, arg2, ...] args arguments to connection's `nack_frame` method
119
119
  # @return [OnStomp::Components::Frame] NACK frame
120
120
  def nack_frame *args
121
121
  client.connection.ack_frame(*args).tap do |f|
@@ -123,13 +123,13 @@ class OnStomp::Components::Scopes::TransactionScope
123
123
  end
124
124
  end
125
125
 
126
- # If the name of the missing method ends with +_frame+, the method is passed
126
+ # If the name of the missing method ends with `_frame`, the method is passed
127
127
  # along to the client's {OnStomp::Client#connection connection} so that it
128
128
  # might build the appropriate (non-transactional) frame.
129
129
  # @return [OnStomp::Components::Frame]
130
130
  # @raise [OnStomp::UnsupportedCommandError] if the connection does not
131
131
  # support the requested frame command.
132
- # @raise [NoMethodError] if the method name does not end in +_frame+
132
+ # @raise [NoMethodError] if the method name does not end in `_frame`
133
133
  def method_missing meth, *args, &block
134
134
  if meth.to_s =~ /^(.*)_frame$/
135
135
  client.connection.__send__(meth, *args, &block)
@@ -154,7 +154,7 @@ class OnStomp::Components::Scopes::TransactionScope
154
154
  # @return [self]
155
155
  # @raise [Exception] if supplied block raises an exception
156
156
  # @yield [t] block of frames to transmit transactionally
157
- # @yieldparam [OnStomp::Components::Scopes::TransactionScope] t +self+
157
+ # @yieldparam [OnStomp::Components::Scopes::TransactionScope] t `self`
158
158
  def perform
159
159
  begin
160
160
  self.begin unless @started
@@ -12,10 +12,10 @@ class OnStomp::Components::Subscription
12
12
  @frame = fr
13
13
  @callback = cb
14
14
  end
15
- # Returns the +id+ header of the associated SUBSCRIBE frame
15
+ # Returns the `id` header of the associated SUBSCRIBE frame
16
16
  # @return [String]
17
17
  def id; frame[:id]; end
18
- # Returns the +destination+ header of the associated SUBSCRIBE frame
18
+ # Returns the `destination` header of the associated SUBSCRIBE frame
19
19
  # @return [String]
20
20
  def destination; frame[:destination]; end
21
21
  # Invokes the {#callback}, passing along the supplied MESSAGE frame
@@ -47,7 +47,7 @@ class OnStomp::Components::ThreadedProcessor
47
47
  end
48
48
  end
49
49
 
50
- # Causes the thread this method was invoked in to +pass+ until the
50
+ # Causes the thread this method was invoked in to `pass` until the
51
51
  # processor is no longer {#running? running}.
52
52
  # @return [self]
53
53
  def join
@@ -23,7 +23,7 @@ module OnStomp::Components::URI
23
23
  end
24
24
  end
25
25
 
26
- # Add the new URI classes to +URI+'s set of known schemes.
26
+ # Add the new URI classes to `URI`'s set of known schemes.
27
27
  module ::URI
28
28
  @@schemes['STOMP'] = OnStomp::Components::URI::STOMP
29
29
  @@schemes['STOMP+SSL'] = OnStomp::Components::URI::STOMP_SSL
@@ -13,9 +13,9 @@ class OnStomp::Connections::Base
13
13
  MAX_BYTES_PER_READ = 1024 * 4
14
14
 
15
15
  # Creates a new connection using the given {#socket} object and
16
- # {OnStomp::Client client}. The {#socket} object will generally be a +TCPSocket+
17
- # or an +OpenSSL::SSL::SSLSocket+ and must support the methods +read_nonblock+
18
- # +write_nonblock+, and +close+.
16
+ # {OnStomp::Client client}. The {#socket} object will generally be a `TCPSocket`
17
+ # or an +OpenSSL::SSL::SSLSocket+ and must support the methods `read_nonblock`
18
+ # `write_nonblock`, and `close`.
19
19
  # @param [TCPSocket,OpenSSL::SSL::SSLSocket] socket
20
20
  # @param [OnStomp::Client] client
21
21
  def initialize socket, client
@@ -29,7 +29,7 @@ class OnStomp::Connections::Base
29
29
  end
30
30
 
31
31
  # Performs any necessary configuration of the connection from the CONNECTED
32
- # frame sent by the broker and a +Hash+ of pending callbacks. This method
32
+ # frame sent by the broker and a `Hash` of pending callbacks. This method
33
33
  # is called after the protocol negotiation has taken place between client
34
34
  # and broker, and the connection that receives it will be the connection
35
35
  # used by the client for the duration of the session.
@@ -46,7 +46,7 @@ class OnStomp::Connections::Base
46
46
  !socket.closed?
47
47
  end
48
48
 
49
- # Closes the {#socket}. If +blocking+ is true, the socket will be closed
49
+ # Closes the {#socket}. If `blocking` is true, the socket will be closed
50
50
  # immediately, otherwies the socket will remain open until {#io_process_write}
51
51
  # has finished writing all of its buffered data. Once this method has been
52
52
  # invoked, {#write_frame_nonblock} will not enqueue any additional frames
@@ -53,14 +53,14 @@ module OnStomp::Connections::Heartbeating
53
53
  end
54
54
 
55
55
  # Number of milliseconds since data was last transmitted to the broker or
56
- # +nil+ if no data has been transmitted when the method is called.
56
+ # `nil` if no data has been transmitted when the method is called.
57
57
  # @return [Fixnum, nil]
58
58
  def duration_since_transmitted
59
59
  last_transmitted_at && ((Time.now - last_transmitted_at)*1000).to_i
60
60
  end
61
61
 
62
62
  # Number of milliseconds since data was last received from the broker or
63
- # +nil+ if no data has been received when the method is called.
63
+ # `nil` if no data has been received when the method is called.
64
64
  # @return [Fixnum, nil]
65
65
  def duration_since_received
66
66
  last_received_at && ((Time.now - last_received_at)*1000).to_i
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- # Classes that mix this in must define +split_header+ and +prepare_parsed_frame+
4
- # The method +frame_to_string_base+ is provided as a factoring out of the
3
+ # Classes that mix this in must define `split_header` and `prepare_parsed_frame`
4
+ # The method `frame_to_string_base` is provided as a factoring out of the
5
5
  # common tasks of serializing a frame for STOMP 1.0 and STOMP 1.1.
6
6
  module OnStomp::Connections::Serializers::Stomp_1
7
7
  # Resets the parser that converts byte strings to {OnStomp::Components::Frame frames}
@@ -72,7 +72,7 @@ module OnStomp::Connections::Serializers::Stomp_1
72
72
  end
73
73
 
74
74
  # Adds the substring +data[0...idx]+ to the parser's accumulator,
75
- # unshifts the remaining data back onto the buffer, and calls +meth+
75
+ # unshifts the remaining data back onto the buffer, and calls `meth`
76
76
  # with the parser's accumulated string.
77
77
  # @param [Array<String>] buffer
78
78
  # @param [String] data
@@ -117,7 +117,7 @@ module OnStomp::Connections::Serializers::Stomp_1
117
117
 
118
118
  # Called when a frame's body has been fully read from the buffer. This
119
119
  # method will set the frame's {OnStomp::Components::Frame#body body}
120
- # attribute, call +prepare_parsed_frame+ with the "current frame",
120
+ # attribute, call `prepare_parsed_frame` with the "current frame",
121
121
  # and tell the parser to move on to the next state.
122
122
  # @param [String] body
123
123
  def finish_body body
@@ -150,14 +150,14 @@ module OnStomp::Connections::Serializers::Stomp_1
150
150
  end
151
151
 
152
152
  if RUBY_VERSION >= "1.9"
153
- # Takes the result of +frame_to_string+ and forces it to use a binary
153
+ # Takes the result of `frame_to_string` and forces it to use a binary
154
154
  # encoding
155
155
  # @return [String] string serialization of frame with 'ASCII-8BIT' encoding
156
156
  def frame_to_bytes frame
157
157
  frame_to_string(frame).tap { |s| s.force_encoding('ASCII-8BIT') }
158
158
  end
159
159
  else
160
- # Takes the result of +frame_to_string+ and passes it along. Ruby 1.8.7
160
+ # Takes the result of `frame_to_string` and passes it along. Ruby 1.8.7
161
161
  # treats strings as a collection of bytes, so we don't need to do any
162
162
  # further work.
163
163
  # @return [String]
@@ -94,7 +94,7 @@ class OnStomp::Connections::Serializers::Stomp_1_1
94
94
  f.body.force_encoding(charset)
95
95
  f
96
96
  end
97
- # Set an appropriate +content-type+ header with +charset+ parameter for
97
+ # Set an appropriate +content-type+ header with `charset` parameter for
98
98
  # frames with a text body
99
99
  # @note No-op for Ruby 1.8.x
100
100
  # @param [OnStomp::Components::Frame] f
@@ -124,7 +124,7 @@ class OnStomp::Connections::Serializers::Stomp_1_1
124
124
  # @param [OnStomp::Components::Frame] f
125
125
  # @return [OnStomp::Components::Frame]
126
126
  def force_body_encoding(f); f; end
127
- # Set an appropriate +content-type+ header with +charset+ parameter for
127
+ # Set an appropriate +content-type+ header with `charset` parameter for
128
128
  # frames with a text body
129
129
  # @note No-op for Ruby 1.8.x
130
130
  # @param [OnStomp::Components::Frame] f