adhearsion 2.2.0 → 2.2.1

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.
Files changed (33) hide show
  1. data/.travis.yml +6 -3
  2. data/CHANGELOG.md +6 -0
  3. data/CONTRIBUTING.md +3 -0
  4. data/lib/adhearsion.rb +7 -13
  5. data/lib/adhearsion/call.rb +0 -4
  6. data/lib/adhearsion/call_controller.rb +2 -0
  7. data/lib/adhearsion/call_controller/dial.rb +2 -0
  8. data/lib/adhearsion/call_controller/output/abstract_player.rb +2 -0
  9. data/lib/adhearsion/call_controller/output/formatter.rb +2 -0
  10. data/lib/adhearsion/call_controller/utility.rb +2 -0
  11. data/lib/adhearsion/configuration.rb +2 -0
  12. data/lib/adhearsion/initializer.rb +1 -1
  13. data/lib/adhearsion/outbound_call.rb +1 -2
  14. data/lib/adhearsion/plugin.rb +2 -0
  15. data/lib/adhearsion/router/route.rb +2 -9
  16. data/lib/adhearsion/statistics.rb +35 -37
  17. data/lib/adhearsion/version.rb +1 -1
  18. data/spec/adhearsion/call_controller/dial_spec.rb +3 -3
  19. data/spec/adhearsion/call_controller/input_spec.rb +1 -0
  20. data/spec/adhearsion/call_controller/output/async_player_spec.rb +1 -0
  21. data/spec/adhearsion/call_controller/output/formatter_spec.rb +1 -0
  22. data/spec/adhearsion/call_controller/output/player_spec.rb +4 -4
  23. data/spec/adhearsion/call_controller/output_spec.rb +1 -0
  24. data/spec/adhearsion/call_controller/record_spec.rb +1 -0
  25. data/spec/adhearsion/call_controller/utility_spec.rb +1 -0
  26. data/spec/adhearsion/call_controller_spec.rb +2 -2
  27. data/spec/adhearsion/configuration_spec.rb +1 -0
  28. data/spec/adhearsion/plugin_spec.rb +1 -0
  29. data/spec/adhearsion/punchblock_plugin_spec.rb +2 -2
  30. data/spec/adhearsion/statistics_spec.rb +8 -1
  31. data/spec/adhearsion_spec.rb +4 -0
  32. data/spec/spec_helper.rb +4 -6
  33. metadata +5 -4
@@ -3,9 +3,12 @@ script: bundle exec rake --trace
3
3
  rvm:
4
4
  - 1.9.2
5
5
  - 1.9.3
6
- # - jruby-19mode # JRuby in 1.9 mode
7
- # - rbx-19mode # currently in active development, may or may not work for your project
8
- # - ruby-head
6
+ - jruby-19mode
7
+ - rbx-19mode
8
+ - ruby-head
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: rbx-19mode
9
12
  env: ARUBA_TIMEOUT=120 RAILS_ENV=development AHN_ENV=development
10
13
  notifications:
11
14
  irc: "irc.freenode.org#adhearsion"
@@ -1,5 +1,11 @@
1
1
  # [develop](https://github.com/adhearsion/adhearsion)
2
2
 
3
+ # [2.2.1](https://github.com/adhearsion/adhearsion/compare/v2.2.0...v2.2.1) - [2013-01-06](https://rubygems.org/gems/adhearsion/versions/2.2.1)
4
+ * Bugfix: No longer crash logging randomly
5
+ * Bugfix: Correctly route outbound calls
6
+ * Bugfix: Handle calls when daemonized correctly
7
+ * Bugfix: Test suites now pass on JRuby and Ruby 2.0.0
8
+
3
9
  # [2.2.0](https://github.com/adhearsion/adhearsion/compare/v2.1.3...v2.2.0) - [2012-12-17](https://rubygems.org/gems/adhearsion/versions/2.2.0)
4
10
  * Feature: Statistics API providing counts of calls dialed, offered, rejected, routed and active
5
11
 
@@ -0,0 +1,3 @@
1
+ # Contributing
2
+
3
+ Please refer to [the contribution guidelines](http://adhearsion.com/docs/contributing).
@@ -1,13 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
- abort "ERROR: You are running Adhearsion on an unsupported version of Ruby (Ruby #{RUBY_VERSION} #{RUBY_RELEASE_DATE})! Please upgrade to at least Ruby v1.9.2, JRuby 1.6.5 or Rubinius 2.0." if RUBY_VERSION < "1.9.2"
3
+ abort "ERROR: You are running Adhearsion on an unsupported version of Ruby (Ruby #{RUBY_VERSION} #{RUBY_RELEASE_DATE})! Please upgrade to at least Ruby v1.9.2, JRuby 1.7.0 or Rubinius 2.0." if RUBY_VERSION < "1.9.2"
4
4
 
5
5
  %w{
6
6
  active_support/all
7
7
  punchblock
8
- ruby_speech
9
- countdownlatch
10
- loquacious
11
8
  celluloid
12
9
 
13
10
  adhearsion/version
@@ -99,21 +96,18 @@ module Adhearsion
99
96
  end
100
97
 
101
98
  def active_calls
102
- if instance_variable_defined?(:@calls) && @calls.alive?
103
- @calls
104
- else
105
- @calls = Calls.new
106
- end
99
+ Celluloid::Actor[:active_calls] || Calls.supervise_as(:active_calls)
100
+ Celluloid::Actor[:active_calls]
107
101
  end
108
102
 
109
103
  #
110
104
  # @return [Adhearsion::Statistics] a statistics aggregator object capable of producing stats dumps
111
105
  def statistics
112
- if instance_variable_defined?(:@statistics) && @statistics.alive?
113
- @statistics
114
- else
115
- @statistics = Statistics.new.tap(&:setup_event_handlers)
106
+ unless Celluloid::Actor[:statistics]
107
+ Statistics.supervise_as :statistics
108
+ Statistics.setup_event_handlers
116
109
  end
110
+ Celluloid::Actor[:statistics]
117
111
  end
118
112
 
119
113
  def status
@@ -140,10 +140,6 @@ module Adhearsion
140
140
  end
141
141
  end
142
142
 
143
- def finalize
144
- ::Logging::Repository.reset
145
- end
146
-
147
143
  ##
148
144
  # Registers a callback for when this call is joined to another call or a mixer
149
145
  #
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'countdownlatch'
4
+
3
5
  module Adhearsion
4
6
  class CallController
5
7
  extend ActiveSupport::Autoload
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'countdownlatch'
4
+
3
5
  module Adhearsion
4
6
  class CallController
5
7
  module Dial
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'ruby_speech'
4
+
3
5
  module Adhearsion
4
6
  class CallController
5
7
  module Output
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'ruby_speech'
4
+
3
5
  module Adhearsion
4
6
  class CallController
5
7
  module Output
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'ruby_speech'
4
+
3
5
  module Adhearsion
4
6
  class CallController
5
7
  module Utility
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'loquacious'
4
+
3
5
  module Adhearsion
4
6
  class Configuration
5
7
 
@@ -38,12 +38,12 @@ module Adhearsion
38
38
  end
39
39
 
40
40
  def start
41
- Adhearsion.statistics
42
41
  resolve_pid_file_path
43
42
  load_lib_folder
44
43
  load_config_file
45
44
  initialize_log_paths
46
45
  daemonize! if should_daemonize?
46
+ Adhearsion.statistics
47
47
  start_logging
48
48
  debugging_log
49
49
  launch_console if need_console?
@@ -76,8 +76,7 @@ module Adhearsion
76
76
 
77
77
  def run_router
78
78
  catching_standard_errors do
79
- dispatcher = Adhearsion.router.handle current_actor
80
- dispatcher.call current_actor
79
+ Adhearsion.router.handle current_actor
81
80
  end
82
81
  end
83
82
 
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'loquacious'
4
+
3
5
  module Adhearsion
4
6
 
5
7
  # Plugin is the core of extension of Adhearsion framework and provides the easiest
@@ -8,6 +8,7 @@ module Adhearsion
8
8
  include HasGuardedHandlers
9
9
 
10
10
  attr_reader :name, :target, :guards
11
+ attr_accessor :controller_metadata
11
12
 
12
13
  def initialize(name, target = nil, *guards, &block)
13
14
  @name = name
@@ -17,6 +18,7 @@ module Adhearsion
17
18
  @target, @guards = target, guards
18
19
  end
19
20
  @guards.compact!
21
+ @controller_metadata = {}
20
22
  end
21
23
 
22
24
  def match?(call)
@@ -47,15 +49,6 @@ module Adhearsion
47
49
  }
48
50
  end
49
51
 
50
- def controller_metadata=(metadata)
51
- @controller_metadata = metadata
52
- end
53
-
54
- def controller_metadata
55
- return {} unless instance_variable_defined?(:@controller_metadata)
56
- @controller_metadata
57
- end
58
-
59
52
  def evented?
60
53
  false
61
54
  end
@@ -6,6 +6,41 @@ module Adhearsion
6
6
 
7
7
  exclusive
8
8
 
9
+ # @private
10
+ def self.setup_event_handlers
11
+ Events.punchblock(Punchblock::Event::Offer) do
12
+ begin
13
+ Celluloid::Actor[:statistics].register_call_offered
14
+ ensure
15
+ throw :pass
16
+ end
17
+ end
18
+
19
+ Events.call_dialed do
20
+ begin
21
+ Celluloid::Actor[:statistics].register_call_dialed
22
+ ensure
23
+ throw :pass
24
+ end
25
+ end
26
+
27
+ Events.call_rejected do
28
+ begin
29
+ Celluloid::Actor[:statistics].register_call_rejected
30
+ ensure
31
+ throw :pass
32
+ end
33
+ end
34
+
35
+ Events.call_routed do |data|
36
+ begin
37
+ Celluloid::Actor[:statistics].register_call_routed data
38
+ ensure
39
+ throw :pass
40
+ end
41
+ end
42
+ end
43
+
9
44
  def initialize
10
45
  @calls_dialed = @calls_offered = @calls_routed = @calls_rejected = 0
11
46
  @calls_by_route = Hash.new { |h,k| h[k] = 0 }
@@ -40,43 +75,6 @@ module Adhearsion
40
75
  @calls_rejected += 1
41
76
  end
42
77
 
43
- # @private
44
- def setup_event_handlers
45
- stats = current_actor
46
-
47
- Events.punchblock(Punchblock::Event::Offer) do
48
- begin
49
- stats.register_call_offered
50
- rescue Celluloid::DeadActorError
51
- end
52
- throw :pass
53
- end
54
-
55
- Events.call_dialed do
56
- begin
57
- stats.register_call_dialed
58
- rescue Celluloid::DeadActorError
59
- end
60
- throw :pass
61
- end
62
-
63
- Events.call_rejected do
64
- begin
65
- stats.register_call_rejected
66
- rescue Celluloid::DeadActorError
67
- end
68
- throw :pass
69
- end
70
-
71
- Events.call_routed do |data|
72
- begin
73
- stats.register_call_routed data
74
- rescue Celluloid::DeadActorError
75
- end
76
- throw :pass
77
- end
78
- end
79
-
80
78
  def to_s
81
79
  "#<#{self.class} dump=#{dump}>"
82
80
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Adhearsion
4
- VERSION = '2.2.0'
4
+ VERSION = '2.2.1'
5
5
  end
@@ -9,11 +9,11 @@ module Adhearsion
9
9
 
10
10
  let(:to) { 'sip:foo@bar.com' }
11
11
  let(:other_call_id) { new_uuid }
12
- let(:other_mock_call) { flexmock OutboundCall.new, :id => other_call_id }
12
+ let(:other_mock_call) { flexmock OutboundCall.new, :id => other_call_id, :write_command => true }
13
13
 
14
14
  let(:second_to) { 'sip:baz@bar.com' }
15
15
  let(:second_other_call_id) { new_uuid }
16
- let(:second_other_mock_call) { flexmock OutboundCall.new, :id => second_other_call_id }
16
+ let(:second_other_mock_call) { flexmock OutboundCall.new, :id => second_other_call_id, :write_command => true }
17
17
 
18
18
  let(:mock_answered) { Punchblock::Event::Answered.new }
19
19
 
@@ -349,7 +349,7 @@ module Adhearsion
349
349
 
350
350
  context "when a call is answered and joined, and the other ends with an error" do
351
351
  it "has an overall dial status of :answer" do
352
- flexmock(call).should_receive(:answer).once
352
+ flexmock(call).should_receive(:answer).once
353
353
  flexmock(other_mock_call).should_receive(:join).once.with(call)
354
354
  flexmock(second_other_mock_call).should_receive(:hangup).once
355
355
 
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
+ require 'ruby_speech'
4
5
 
5
6
  module Adhearsion
6
7
  class CallController
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
+ require 'ruby_speech'
4
5
 
5
6
  module Adhearsion
6
7
  class CallController
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
+ require 'ruby_speech'
4
5
 
5
6
  module Adhearsion
6
7
  class CallController
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
+ require 'ruby_speech'
4
5
 
5
6
  module Adhearsion
6
7
  class CallController
@@ -44,10 +45,9 @@ module Adhearsion
44
45
  lambda { subject.output content }.should raise_error(PlaybackError)
45
46
  end
46
47
 
47
- it "raises a Playback Error if the component ends due to an error" do
48
- e = Call::Hangup.new
49
- expect_component_execution Punchblock::Component::Output.new(:ssml => content), e
50
- lambda { subject.output content }.should raise_error(e)
48
+ it "raises a Call::Hangup exception if the component ends due to an error" do
49
+ expect_component_execution Punchblock::Component::Output.new(:ssml => content), Call::Hangup
50
+ lambda { subject.output content }.should raise_error(Call::Hangup)
51
51
  end
52
52
  end
53
53
 
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
+ require 'ruby_speech'
4
5
 
5
6
  module Adhearsion
6
7
  class CallController
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
+ require 'ruby_speech'
4
5
 
5
6
  module Adhearsion
6
7
  class CallController
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
+ require 'ruby_speech'
4
5
 
5
6
  module Adhearsion
6
7
  class CallController
@@ -299,10 +299,10 @@ module Adhearsion
299
299
  before { subject.pause! }
300
300
 
301
301
  it "should unblock when the controller is unpaused" do
302
- t1 = t2 = nil
302
+ t2 = nil
303
303
  latch = CountDownLatch.new 1
304
+ t1 = Time.now
304
305
  Thread.new do
305
- t1 = Time.now
306
306
  subject.block_until_resumed
307
307
  t2 = Time.now
308
308
  latch.countdown!
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
+ require 'loquacious'
4
5
 
5
6
  describe Adhearsion::Configuration do
6
7
 
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
+ require 'loquacious'
4
5
 
5
6
  include InitializerStubs
6
7
 
@@ -32,13 +32,13 @@ module Adhearsion
32
32
  it "blocks until a response is received" do
33
33
  slow_command = Punchblock::Command::Dial.new
34
34
  slow_command.request!
35
+ starting_time = Time.now
35
36
  Thread.new do
36
37
  sleep 0.5
37
38
  slow_command.response = response
38
39
  end
39
- starting_time = Time.now
40
40
  PunchblockPlugin.execute_component slow_command
41
- (Time.now - starting_time).should >= 0.5
41
+ (Time.now - starting_time).should >= 0.4
42
42
  end
43
43
 
44
44
  describe "with a successful response" do
@@ -3,12 +3,19 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Adhearsion::Statistics do
6
+ before(:all) do
7
+ Adhearsion::Statistics.setup_event_handlers
8
+ end
9
+
10
+ subject { Celluloid::Actor[:statistics] }
11
+
6
12
  before do
7
- subject.setup_event_handlers
13
+ Celluloid::Actor[:statistics] = described_class.new
8
14
  flexmock(Adhearsion.active_calls).should_receive(:count).and_return 0
9
15
  end
10
16
 
11
17
  after do
18
+ Celluloid::Actor.clear_registry
12
19
  Adhearsion.router = nil
13
20
  end
14
21
 
@@ -86,6 +86,8 @@ describe Adhearsion do
86
86
  original.terminate
87
87
  original.should_not be_alive
88
88
 
89
+ sleep 0.25
90
+
89
91
  current = Adhearsion.active_calls
90
92
  current.should be_alive
91
93
  current.should_not be original
@@ -106,6 +108,8 @@ describe Adhearsion do
106
108
  original.terminate
107
109
  original.should_not be_alive
108
110
 
111
+ sleep 0.25
112
+
109
113
  current = Adhearsion.statistics
110
114
  current.should be_alive
111
115
  current.should_not be original
@@ -40,12 +40,12 @@ RSpec.configure do |config|
40
40
  config.run_all_when_everything_filtered = true
41
41
  config.color_enabled = true
42
42
 
43
- config.before :each do
44
- Adhearsion.router = nil
43
+ config.before :suite do
44
+ Adhearsion::Logging.start Adhearsion::Logging.default_appenders, :trace, Adhearsion.config.platform.logging.formatter
45
45
  end
46
46
 
47
- config.after :each do
48
- Celluloid.shutdown
47
+ config.before :each do
48
+ Adhearsion.router = nil
49
49
  end
50
50
  end
51
51
 
@@ -54,8 +54,6 @@ Adhearsion::Events.exeption do |e|
54
54
  puts e.backtrace.join("\n")
55
55
  end
56
56
 
57
- Adhearsion::Logging.silence!
58
-
59
57
  # Test modules for #mixin methods
60
58
  module TestBiscuit
61
59
  def throwadogabone
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adhearsion
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-12-17 00:00:00.000000000 Z
15
+ date: 2013-01-06 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
@@ -464,6 +464,7 @@ files:
464
464
  - .travis.yml
465
465
  - .yardopts
466
466
  - CHANGELOG.md
467
+ - CONTRIBUTING.md
467
468
  - Gemfile
468
469
  - Guardfile
469
470
  - LICENSE
@@ -636,7 +637,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
636
637
  version: '0'
637
638
  segments:
638
639
  - 0
639
- hash: -4557802099463492271
640
+ hash: 2773669927993814773
640
641
  required_rubygems_version: !ruby/object:Gem::Requirement
641
642
  none: false
642
643
  requirements:
@@ -645,7 +646,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
645
646
  version: '0'
646
647
  segments:
647
648
  - 0
648
- hash: -4557802099463492271
649
+ hash: 2773669927993814773
649
650
  requirements: []
650
651
  rubyforge_project:
651
652
  rubygems_version: 1.8.24