punchblock 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a847554d66bf45ee14cc93803271b60890cfff96
4
- data.tar.gz: 43d698af41a3b374c3b39bacdf29dbce822020bc
3
+ metadata.gz: 9e6afe18610ec58e92290615347d829d84df0f35
4
+ data.tar.gz: 67ab1a85edc0cb9603f47739e661a6cd5f13492e
5
5
  SHA512:
6
- metadata.gz: 6c9373c2cb2e3831e1938924197c8c141fda152423a4f985e9f3c84c38f099185cdeaeed8275f8e111c2d9f77dd39c4caad635b9031fe63786b09eb3fb53d6df
7
- data.tar.gz: 6474dd87f25053eb002212c18744f2c216cc153c4d9df1b7938f4e45faa224988b6f5ff296b4729bbd0c538887e43897aac1c9fff83f3eccc995fc726793a313
6
+ metadata.gz: 204717279e74f4f6c892c2a832e2e81ac947473011e2249a7b5fc3cf7847dc133ea3eb7dccf61523898a9c79ef3e913f96562414b48477c2e668d52b67b9b17e
7
+ data.tar.gz: a7465ef83df1050746b6eb1c6e47b04ca8d9f68fdf29a51ebc96958940e69b868410a9459535b6e961c4206277764f0fe9bc9cfa903fb7c3dc68f1934cf40c76
data/.travis.yml CHANGED
@@ -1,15 +1,13 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.2
4
3
  - 1.9.3
5
4
  - 2.0.0
6
5
  - 2.1.0
7
- - jruby-19mode
6
+ - jruby
8
7
  - rbx-2.1.1
9
8
  - ruby-head
10
9
  matrix:
11
10
  allow_failures:
12
- - rvm: 1.9.2
13
11
  - rvm: ruby-head
14
12
  - rvm: rbx-2.1.1
15
13
  notifications:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # [develop](https://github.com/adhearsion/punchblock)
2
2
 
3
+ # [v2.3.1](https://github.com/adhearsion/punchblock/compare/v2.3.0...v2.3.1) - [2014-02-13](https://rubygems.org/gems/punchblock/versions/2.3.1)
4
+ * Bugfix: Ensure commands can be associated on the wire even before they're executed
5
+ * Bugfix: Ensure a command is always transitioned to is requested state prior to receiving a response
6
+
3
7
  # [v2.3.0](https://github.com/adhearsion/punchblock/compare/v2.2.2...v2.3.0) - [2014-01-30](https://rubygems.org/gems/punchblock/versions/2.3.0)
4
8
  * Feature: Add input-timers-started event
5
9
  * Feature: Allow client to send XMPP messages through Blather
data/Gemfile CHANGED
@@ -2,4 +2,3 @@ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
4
  gem 'bluecloth' unless RUBY_PLATFORM =~ /java/
5
- gem 'activesupport', '~> 3.0' if RUBY_VERSION == "1.9.2"
@@ -4,6 +4,8 @@ require 'state_machine'
4
4
  module Punchblock
5
5
  class CommandNode < RayoNode
6
6
 
7
+ attribute :request_id, String, default: ->(*) { Punchblock.new_request_id }
8
+
7
9
  def initialize(*args)
8
10
  super
9
11
  @response = FutureResource.new
@@ -31,6 +33,9 @@ module Punchblock
31
33
  return if @response.set_yet?
32
34
  @response.resource = other
33
35
  execute!
36
+ rescue StateMachine::InvalidTransition => e
37
+ e.message << " for command #{self}"
38
+ raise e
34
39
  rescue FutureResource::ResourceAlreadySetException
35
40
  end
36
41
  end # CommandNode
@@ -53,6 +53,9 @@ module Punchblock
53
53
  client.delete_component_registration self if client
54
54
  complete!
55
55
  @complete_event_resource.resource = other
56
+ rescue StateMachine::InvalidTransition => e
57
+ e.message << " for component #{self}"
58
+ raise e
56
59
  end
57
60
 
58
61
  ##
@@ -45,6 +45,7 @@ module Punchblock
45
45
 
46
46
  def write(command, options = {})
47
47
  iq = prep_command_for_execution command, options
48
+ command.request!
48
49
  client.write_with_handler iq do |response|
49
50
  if response.result?
50
51
  handle_iq_result response, command
@@ -52,7 +53,6 @@ module Punchblock
52
53
  handle_error response, command
53
54
  end
54
55
  end
55
- command.request!
56
56
  end
57
57
 
58
58
  def prep_command_for_execution(command, options = {})
@@ -64,7 +64,7 @@ module Punchblock
64
64
  if command.is_a?(Command::Join) && command.mixer_name
65
65
  @joined_mixers << command.mixer_name
66
66
  end
67
- create_iq(jid_for_command(command)).tap do |iq|
67
+ create_iq(jid_for_command(command), command.request_id).tap do |iq|
68
68
  command.to_rayo(iq)
69
69
  end
70
70
  end
@@ -183,8 +183,8 @@ module Punchblock
183
183
  end
184
184
  end
185
185
 
186
- def create_iq(jid = nil)
187
- Blather::Stanza::Iq.new :set, jid || @call_id
186
+ def create_iq(jid, id)
187
+ Blather::Stanza::Iq.new :set, jid, id
188
188
  end
189
189
  end
190
190
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Punchblock
4
- VERSION = "2.3.0"
4
+ VERSION = "2.3.1"
5
5
  end
data/lib/punchblock.rb CHANGED
@@ -61,6 +61,10 @@ module Punchblock
61
61
  SecureRandom.uuid
62
62
  end
63
63
 
64
+ def new_request_id
65
+ new_uuid
66
+ end
67
+
64
68
  def jruby?
65
69
  @jruby ||= !!(RUBY_PLATFORM =~ /java/)
66
70
  end
data/punchblock.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.required_rubygems_version = Gem::Requirement.new(">= 1.3.7") if s.respond_to? :required_rubygems_version=
24
24
 
25
25
  s.add_runtime_dependency %q<nokogiri>, ["~> 1.5", ">= 1.5.6"]
26
- s.add_runtime_dependency %q<blather>, [">= 0.7.0"]
26
+ s.add_runtime_dependency %q<blather>, ["~> 1.0"]
27
27
  s.add_runtime_dependency %q<activesupport>, [">= 3.0.0", "< 5.0.0"]
28
28
  s.add_runtime_dependency %q<state_machine>, ["~> 1.0"]
29
29
  s.add_runtime_dependency %q<future-resource>, ["~> 1.0"]
@@ -11,6 +11,7 @@ module Punchblock
11
11
  end
12
12
 
13
13
  its(:state_name) { should be == :new }
14
+ its(:request_id) { should be == @uuid }
14
15
 
15
16
  describe "#new" do
16
17
  describe "with a call/component ID" do
@@ -104,8 +104,35 @@ module Punchblock
104
104
  output.component_id.should be == 'fgh4590'
105
105
  end
106
106
 
107
+ let(:client) { connection.send :client }
108
+ before { client.stub :write }
109
+
110
+ describe "sending a command" do
111
+ let(:command) { Punchblock::Command::Answer.new request_id: 'fooobarrr', target_call_id: 'foo', domain: 'bar.com' }
112
+
113
+ it "should write an IQ containing the command to the socket" do
114
+ client.should_receive(:write).once.with do |stanza|
115
+ stanza.should be_a Blather::Stanza::Iq
116
+ stanza.to.should be == 'foo@bar.com'
117
+ stanza.type.should be == :set
118
+ end
119
+ connection.write command
120
+ end
121
+
122
+ it "should put the command in a requested state" do
123
+ connection.write command
124
+ command.should be_requested
125
+ end
126
+
127
+ it "should use the command's request_id as the ID id" do
128
+ client.should_receive(:write).once.with do |stanza|
129
+ stanza.id.should be == 'fooobarrr'
130
+ end
131
+ connection.write command
132
+ end
133
+ end
134
+
107
135
  it 'should send a "Chat" presence when ready' do
108
- client = connection.send :client
109
136
  client.should_receive(:write).once.with do |stanza|
110
137
  stanza.to.should be == 'rayo.net'
111
138
  stanza.should be_a Blather::Stanza::Presence::Status
@@ -115,7 +142,6 @@ module Punchblock
115
142
  end
116
143
 
117
144
  it 'should send a "Do Not Disturb" presence when not_ready' do
118
- client = connection.send :client
119
145
  client.should_receive(:write).once.with do |stanza|
120
146
  stanza.to.should be == 'rayo.net'
121
147
  stanza.should be_a Blather::Stanza::Presence::Status
@@ -126,7 +152,6 @@ module Punchblock
126
152
 
127
153
  describe '#send_message' do
128
154
  it 'should send a "normal" message to the given user and domain' do
129
- client = connection.send :client
130
155
  client.should_receive(:write).once.with do |stanza|
131
156
  stanza.to.should be == 'someone@example.org'
132
157
  stanza.should be_a Blather::Stanza::Message
@@ -138,7 +163,6 @@ module Punchblock
138
163
  end
139
164
 
140
165
  it 'should default to the root domain' do
141
- client = connection.send :client
142
166
  client.should_receive(:write).once.with do |stanza|
143
167
  stanza.to.should be == 'someone@rayo.net'
144
168
  end
@@ -146,7 +170,6 @@ module Punchblock
146
170
  end
147
171
 
148
172
  it 'should send a message with the given subject' do
149
- client = connection.send :client
150
173
  client.should_receive(:write).once.with do |stanza|
151
174
  stanza.subject.should be == "Important Message"
152
175
  end
@@ -350,7 +373,7 @@ module Punchblock
350
373
  describe "receiving events from a mixer" do
351
374
  context "after joining the mixer" do
352
375
  before do
353
- subject.send(:client).should_receive :write_with_handler
376
+ client.should_receive :write_with_handler
354
377
  subject.write Command::Join.new(:mixer_name => 'foomixer')
355
378
  end
356
379
 
data/spec/spec_helper.rb CHANGED
@@ -24,6 +24,11 @@ RSpec.configure do |config|
24
24
  Punchblock.logger.define_singleton_method :trace, Punchblock.logger.method(:debug)
25
25
  end
26
26
 
27
+ config.before do
28
+ @uuid = SecureRandom.uuid
29
+ Punchblock.stub new_request_id: @uuid
30
+ end
31
+
27
32
  config.after :each do
28
33
  if defined?(:Celluloid)
29
34
  Celluloid.shutdown
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: punchblock
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Goecke
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-01-30 00:00:00.000000000 Z
13
+ date: 2014-02-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -36,16 +36,16 @@ dependencies:
36
36
  name: blather
37
37
  requirement: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 0.7.0
41
+ version: '1.0'
42
42
  type: :runtime
43
43
  prerelease: false
44
44
  version_requirements: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 0.7.0
48
+ version: '1.0'
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: activesupport
51
51
  requirement: !ruby/object:Gem::Requirement