punchblock 1.9.0 → 1.9.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: 64729c9456c13c6897d13dbac65657a51951f67a
4
- data.tar.gz: aa7522da6cf77ebfbbb044865e7c43b79a1939d3
3
+ metadata.gz: 2afefcb37df1adbbdbd78069ace76a6e7a90ff6a
4
+ data.tar.gz: 19c35819dbc195978dc642e89171e8ce2369cb9c
5
5
  SHA512:
6
- metadata.gz: d39f61aaa9ffb224dfa32e9bd898fadc359a9ec6881682e709ee3d0df36afff2c26854baa30e0fc99794a73c18309e8f4922c17d065cb2f5402573947dfabba1
7
- data.tar.gz: 5c93e10769dbbd141b71732f163783bf7ff653faa30d3886f382a87c5a3402c5e6bcd8784701d7b55adbfdf1a728f3841a0093d455c1a16e10e94e161473b902
6
+ metadata.gz: 424af09c594e3ef4f26ae02452ebae5bdaf7b7c1f3df1b2235914e3397360468c9135905bb61e352a0b09097e4958538dec4645778413dcd61d5740a41e6b70b
7
+ data.tar.gz: 809aa86ad8b9e5c211c774279f27d7f853a05802bb7c52b2c95f5d23477e8ff4f6c708d5f678c3c770821692727375748a2510d6ab284c5d7906910c45539986
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # [develop](https://github.com/adhearsion/punchblock)
2
2
 
3
+ # [v1.9.1](https://github.com/adhearsion/punchblock/compare/v1.9.0...v1.9.1) - [2013-05-08](https://rubygems.org/gems/punchblock/versions/1.9.1)
4
+ * Bugfix: AMI errors indicating dead channels were not being handled correctly
5
+ * Bugfix: We were broken on Celluloid 0.14 due to changes in block execution semantics between actors
6
+
3
7
  # [v1.9.0](https://github.com/adhearsion/punchblock/compare/v1.8.2...v1.9.0) - [2013-05-03](https://rubygems.org/gems/punchblock/versions/1.9.0)
4
8
  * Feature: Use RubyAMI 2.0 with a single AMI connection.
5
9
  * Feature: Cache channel variables on Asterisk calls.
data/lib/punchblock.rb CHANGED
@@ -13,6 +13,7 @@
13
13
  module Punchblock
14
14
  extend ActiveSupport::Autoload
15
15
 
16
+ autoload :ActorHasGuardedHandlers
16
17
  autoload :Client
17
18
  autoload :Command
18
19
  autoload :CommandNode
@@ -0,0 +1,7 @@
1
+ module Punchblock
2
+ module ActorHasGuardedHandlers
3
+ def execute_guarded_handlers_on_receiver
4
+ execute_block_on_receiver :register_handler, :register_tmp_handler, :register_handler_with_priority
5
+ end
6
+ end
7
+ end
@@ -8,6 +8,9 @@ module Punchblock
8
8
  include Celluloid
9
9
  include DeadActorSafety
10
10
 
11
+ extend ActorHasGuardedHandlers
12
+ execute_guarded_handlers_on_receiver
13
+
11
14
  attr_reader :id, :channel, :translator, :agi_env, :direction
12
15
 
13
16
  HANGUP_CAUSE_TO_END_REASON = Hash.new { :error }
@@ -215,7 +218,12 @@ module Punchblock
215
218
  command.response = ProtocolError.new.setup 'command-not-acceptable', "Did not understand command for call #{id}", id
216
219
  end
217
220
  rescue RubyAMI::Error => e
218
- command.response = ProtocolError.new.setup 'error', e.message
221
+ command.response = case e.message
222
+ when 'No such channel'
223
+ ProtocolError.new.setup :item_not_found, "Could not find a call with ID #{id}", id
224
+ else
225
+ ProtocolError.new.setup 'error', e.message, id
226
+ end
219
227
  rescue Celluloid::DeadActorError
220
228
  command.response = ProtocolError.new.setup :item_not_found, "Could not find a component with ID #{command.component_id} for call #{id}", id, command.component_id
221
229
  end
@@ -10,6 +10,9 @@ module Punchblock
10
10
  include HasGuardedHandlers
11
11
  include DeadActorSafety
12
12
 
13
+ extend ActorHasGuardedHandlers
14
+ execute_guarded_handlers_on_receiver
15
+
13
16
  extend ActiveSupport::Autoload
14
17
 
15
18
  autoload :Call
@@ -8,6 +8,9 @@ module Punchblock
8
8
  include Celluloid
9
9
  include DeadActorSafety
10
10
 
11
+ extend ActorHasGuardedHandlers
12
+ execute_guarded_handlers_on_receiver
13
+
11
14
  HANGUP_CAUSE_TO_END_REASON = Hash.new :error
12
15
 
13
16
  HANGUP_CAUSE_TO_END_REASON['USER_BUSY'] = :busy
@@ -18,6 +18,9 @@ module Punchblock
18
18
  include DeadActorSafety
19
19
  include HasGuardedHandlers
20
20
 
21
+ extend ActorHasGuardedHandlers
22
+ execute_guarded_handlers_on_receiver
23
+
21
24
  attr_reader :id, :call, :call_id
22
25
 
23
26
  def initialize(component_node, call = nil)
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Punchblock
4
- VERSION = "1.9.0"
4
+ VERSION = "1.9.1"
5
5
  end
data/punchblock.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
29
29
  s.add_runtime_dependency %q<state_machine>, ["~> 1.0"]
30
30
  s.add_runtime_dependency %q<future-resource>, ["~> 1.0"]
31
31
  s.add_runtime_dependency %q<has-guarded-handlers>, ["~> 1.5"]
32
- s.add_runtime_dependency %q<celluloid>, ["~> 0.13"]
32
+ s.add_runtime_dependency %q<celluloid>, ["~> 0.14"]
33
33
  s.add_runtime_dependency %q<ruby_ami>, ["~> 2.0"]
34
34
  s.add_runtime_dependency %q<ruby_fs>, ["~> 1.0"]
35
35
  s.add_runtime_dependency %q<ruby_speech>, ["~> 1.0"]
@@ -851,6 +851,27 @@ module Punchblock
851
851
  subject.execute_command command
852
852
  command.response(0.5).should be true
853
853
  end
854
+
855
+ context "when the AMI commannd raises an error" do
856
+ let(:message) { 'Some error' }
857
+ let(:error) { RubyAMI::Error.new.tap { |e| e.message = message } }
858
+
859
+ before { subject.wrapped_object.should_receive(:execute_agi_command).and_raise error }
860
+
861
+ it "should return an error with the message" do
862
+ subject.execute_command command
863
+ command.response(0.5).should be == ProtocolError.new.setup('error', message, subject.id)
864
+ end
865
+
866
+ context "with message 'No such channel'" do
867
+ let(:message) { 'No such channel' }
868
+
869
+ it "should return an :item_not_found event for the call" do
870
+ subject.execute_command command
871
+ command.response(0.5).should be == ProtocolError.new.setup(:item_not_found, "Could not find a call with ID #{subject.id}", subject.id)
872
+ end
873
+ end
874
+ end
854
875
  end
855
876
 
856
877
  context 'with a reject command' do
@@ -876,6 +897,27 @@ module Punchblock
876
897
  subject.execute_command command
877
898
  command.response(0.5).should be true
878
899
  end
900
+
901
+ context "when the AMI commannd raises an error" do
902
+ let(:message) { 'Some error' }
903
+ let(:error) { RubyAMI::Error.new.tap { |e| e.message = message } }
904
+
905
+ before { subject.wrapped_object.should_receive(:execute_agi_command).and_raise error }
906
+
907
+ it "should return an error with the message" do
908
+ subject.execute_command command
909
+ command.response(0.5).should be == ProtocolError.new.setup('error', message, subject.id)
910
+ end
911
+
912
+ context "with message 'No such channel'" do
913
+ let(:message) { 'No such channel' }
914
+
915
+ it "should return an :item_not_found event for the call" do
916
+ subject.execute_command command
917
+ command.response(0.5).should be == ProtocolError.new.setup(:item_not_found, "Could not find a call with ID #{subject.id}", subject.id)
918
+ end
919
+ end
920
+ end
879
921
  end
880
922
 
881
923
  context 'with an answer command' do
@@ -886,6 +928,27 @@ module Punchblock
886
928
  subject.execute_command command
887
929
  command.response(0.5).should be true
888
930
  end
931
+
932
+ context "when the AMI commannd raises an error" do
933
+ let(:message) { 'Some error' }
934
+ let(:error) { RubyAMI::Error.new.tap { |e| e.message = message } }
935
+
936
+ before { subject.wrapped_object.should_receive(:execute_agi_command).and_raise error }
937
+
938
+ it "should return an error with the message" do
939
+ subject.execute_command command
940
+ command.response(0.5).should be == ProtocolError.new.setup('error', message, subject.id)
941
+ end
942
+
943
+ context "with message 'No such channel'" do
944
+ let(:message) { 'No such channel' }
945
+
946
+ it "should return an :item_not_found event for the call" do
947
+ subject.execute_command command
948
+ command.response(0.5).should be == ProtocolError.new.setup(:item_not_found, "Could not find a call with ID #{subject.id}", subject.id)
949
+ end
950
+ end
951
+ end
889
952
  end
890
953
 
891
954
  context 'with a hangup command' do
@@ -896,6 +959,27 @@ module Punchblock
896
959
  subject.execute_command command
897
960
  command.response(0.5).should be true
898
961
  end
962
+
963
+ context "when the AMI commannd raises an error" do
964
+ let(:message) { 'Some error' }
965
+ let(:error) { RubyAMI::Error.new.tap { |e| e.message = message } }
966
+
967
+ before { ami_client.should_receive(:send_action).and_raise error }
968
+
969
+ it "should return an error with the message" do
970
+ subject.execute_command command
971
+ command.response(0.5).should be == ProtocolError.new.setup('error', message, subject.id)
972
+ end
973
+
974
+ context "with message 'No such channel'" do
975
+ let(:message) { 'No such channel' }
976
+
977
+ it "should return an :item_not_found event for the call" do
978
+ subject.execute_command command
979
+ command.response(0.5).should be == ProtocolError.new.setup(:item_not_found, "Could not find a call with ID #{subject.id}", subject.id)
980
+ end
981
+ end
982
+ end
899
983
  end
900
984
 
901
985
  context 'with an AGI command component' do
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: 1.9.0
4
+ version: 1.9.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: 2013-05-04 00:00:00.000000000 Z
13
+ date: 2013-05-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: niceogiri
@@ -122,14 +122,14 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: '0.13'
125
+ version: '0.14'
126
126
  type: :runtime
127
127
  prerelease: false
128
128
  version_requirements: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ~>
131
131
  - !ruby/object:Gem::Version
132
- version: '0.13'
132
+ version: '0.14'
133
133
  - !ruby/object:Gem::Dependency
134
134
  name: ruby_ami
135
135
  requirement: !ruby/object:Gem::Requirement
@@ -316,6 +316,7 @@ files:
316
316
  - README.markdown
317
317
  - Rakefile
318
318
  - lib/punchblock.rb
319
+ - lib/punchblock/actor_has_guarded_handlers.rb
319
320
  - lib/punchblock/client.rb
320
321
  - lib/punchblock/client/component_registry.rb
321
322
  - lib/punchblock/command.rb