ruby_rabbitmq_janus 1.2.4 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47210929d2091a11e4fe5430763ba83bee5d5306
4
- data.tar.gz: 95733e7ac3ceac85f893f761440ba68447a1f51c
3
+ metadata.gz: 76490748dbcbce0d3606a8d84fefd42800e8d97e
4
+ data.tar.gz: 69035df3de8ca318aa87713b33dbfa59162b6b59
5
5
  SHA512:
6
- metadata.gz: efc53b14b7d13c1ce73c0f3da5e8c666a47c7e1f7065d529776c2c30e5d2680343311c1185826fe1372e8c0854c22d1c6e53301460aff704349dbabc3bd989c1
7
- data.tar.gz: c146be172fc950ae710b5e78725e11c8770ec58155856352c7b35355362a8ee8e4763802d92d06719260ab77340f965a0cc615bbbb7225a7c44f0cd9ff3cf458
6
+ metadata.gz: 24ad5159c111dfbe7bb519e1bd8fac05bd910a36ab0842bb913ba0c2fe1a7e336dfa902a133087a1d01f1b568362bef0a4a06568acf8372191edb784ea0fb773
7
+ data.tar.gz: 94a3ad0f6ba5eb0c3949b48f9b3a7cfb5b9332248a917ef59726fabd42714b45567ca10805788feb836fd17ddc88e48127b67db85fff7c386a56942466f387c0
data/lib/rrj/info.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  # Define constant to gem.
6
6
  module RubyRabbitmqJanus
7
7
  # Define version to gem
8
- VERSION = '1.2.4'
8
+ VERSION = '1.2.5'
9
9
 
10
10
  # Name to gem
11
11
  GEM_NAME = 'ruby_rabbitmq_janus'
data/lib/rrj/init.rb CHANGED
@@ -34,7 +34,7 @@ module RubyRabbitmqJanus
34
34
  #
35
35
  # @example Create a instance to this gem
36
36
  # @rrj = RubyRabbitmqJanus::RRJ.new
37
- # => #<RubyRabbitmqJanus::RRJ:0x007 @session=123, @transaction=nil>
37
+ # => #<RubyRabbitmqJanus::RRJ:0x007 @session=123>
38
38
  def initialize
39
39
  Tools::Log.instance
40
40
  Tools::Config.instance
@@ -43,8 +43,6 @@ module RubyRabbitmqJanus
43
43
  # Create an session while time opening
44
44
  @session = Janus::Concurrencies::Keepalive.instance.session
45
45
  Tools::Log.instance.info "Create an session janus with id : #{@session}"
46
-
47
- @transaction = nil
48
46
  rescue => error
49
47
  raise Errors::InstanciateGemFailed, error
50
48
  end
@@ -123,10 +121,11 @@ module RubyRabbitmqJanus
123
121
  #
124
122
  # @since 1.0.0
125
123
  def message_admin(type, options = { 'replace' => {}, 'add' => {} })
126
- @transaction = Janus::Transactions::Admin.new(@session,
127
- true,
128
- handle?(options))
129
- @transaction.connect { Janus::Messages::Admin.new(type, options) }
124
+ Janus::Transactions::Admin.new(@session,
125
+ true,
126
+ handle?(options)).connect do
127
+ Janus::Messages::Admin.new(type, options)
128
+ end
130
129
  rescue => error
131
130
  raise Errors::TransactionAdminFailed, error
132
131
  end
@@ -149,8 +148,9 @@ module RubyRabbitmqJanus
149
148
  # Give a object response to janus server
150
149
  #
151
150
  # @since 1.0.0
152
- def message_handle(type, options = { 'replace' => {}, 'add' => {} })
153
- @transaction.publish_message_handle(type, options)
151
+ def message_handle(type, transaction,
152
+ options = { 'replace' => {}, 'add' => {} })
153
+ transaction.publish_message_handle(type, options)
154
154
  rescue => error
155
155
  raise Errors::TransactionMessageFailed, error
156
156
  end
@@ -163,16 +163,16 @@ module RubyRabbitmqJanus
163
163
  # @yield Sending requests to Janus.
164
164
  #
165
165
  # @example Start a transaction with janus with a exclusive queue
166
- # @rrj.start_handle(true) do
167
- # @rrj.message_handle('peer:trickle')
166
+ # @rrj.start_handle(true) do |transaction|
167
+ # @rrj.message_handle('peer:trickle', transaction)
168
168
  # end
169
169
  #
170
170
  # @see #message_handle
171
171
  #
172
172
  # @since 1.0.0
173
173
  def start_handle(exclusive = false)
174
- @transaction = Janus::Transactions::Handle.new(@session, exclusive)
175
- @transaction.connect { yield }
174
+ transaction = Janus::Transactions::Handle.new(@session, exclusive)
175
+ transaction.connect { yield(transaction) }
176
176
  rescue => error
177
177
  raise Errors::TransactionHandleFailed, error
178
178
  end
@@ -202,18 +202,15 @@ module RubyRabbitmqJanus
202
202
  #
203
203
  # @since 1.0.0
204
204
  def handle_message_simple(type, options = { 'replace' => {}, 'add' => {} })
205
- @transaction = Janus::Transactions::Handle.new(session?(options),
206
- false,
207
- handle?(options))
208
- @transaction.connect { message_handle(type, options) }
205
+ transaction = Janus::Transactions::Handle.new(session?(options),
206
+ false, handle?(options))
207
+ transaction.connect { message_handle(type, transaction, options) }
209
208
  rescue => error
210
209
  raise Errors::TransactionHandleFailed, error
211
210
  end
212
211
 
213
212
  private
214
213
 
215
- attr_accessor :transaction
216
-
217
214
  def use_current_session?(option)
218
215
  { 'session_id' => @session } unless option.key?('session_id')
219
216
  end
@@ -36,24 +36,20 @@ end
36
36
 
37
37
  # Handle request
38
38
  shared_examples 'message_handle should match json schema' do
39
- let(:message) { @gateway.message_handle(@type, @options) }
40
-
41
39
  it do
42
- @gateway.start_handle(true) do
43
- expect(message.to_json).to match_json_schema(@type)
40
+ @gateway.start_handle(true) do |transaction|
41
+ m = @gateway.message_handle(@type, transaction, @options)
42
+ expect(m.to_json).to match_json_schema(@type)
44
43
  end
45
44
  end
46
45
  end
47
46
 
48
47
  shared_examples 'message_handle should match json empty' do
49
- let(:message) do
50
- options = options.nil? ? { replace: {}, add: {} } : options
51
- @gateway.message_handle(@type, options)
52
- end
53
-
54
48
  it do
55
- @gateway.start_handle(false) do
56
- expect(message.to_json).to eq('{}')
49
+ @gateway.start_handle(false) do |transaction|
50
+ options = options.nil? ? { replace: {}, add: {} } : options
51
+ m = @gateway.message_handle(@type, transaction, options)
52
+ expect(m.to_json).to eq('{}')
57
53
  end
58
54
  end
59
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_rabbitmq_janus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-18 00:00:00.000000000 Z
11
+ date: 2017-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler