adhearsion-asterisk 1.2.0 → 1.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.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # develop
2
2
 
3
+ # v1.2.1
4
+ * Feature: added play_tone for DTMF in-call generation
5
+ * Bugfix: "code is an undefined method" errors on executing AMI methods directly (issue #6)
6
+
3
7
  # v1.2.0
4
8
  * Feature: Added helper to execute AMI actions easily
5
9
 
data/README.md CHANGED
@@ -25,6 +25,7 @@ Dialplan methods
25
25
  * play_time
26
26
  * play_numeric
27
27
  * play_soundfile
28
+ * play_tones
28
29
  * enable_feature
29
30
  * disable_feature
30
31
 
@@ -5,8 +5,8 @@ require "adhearsion/asterisk/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "adhearsion-asterisk"
7
7
  s.version = Adhearsion::Asterisk::VERSION
8
- s.authors = ["Ben Langfeld", "Taylor Carpenter"]
9
- s.email = ["blangfeld@adhearsion.com", "taylor@codecafe.com"]
8
+ s.authors = ["Ben Langfeld", "Taylor Carpenter", "Luca Pradovera"]
9
+ s.email = ["blangfeld@adhearsion.com", "taylor@codecafe.com", "lpradovera@mojolingo.com"]
10
10
  s.homepage = "http://adhearsion.com"
11
11
  s.summary = %q{Asterisk specific features for Adhearsion}
12
12
  s.description = %q{An Adhearsion Plugin providing Asterisk-specific dialplan methods, AMI access, and access to Asterisk configuration}
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_runtime_dependency %q<adhearsion>, ["~> 2.0"]
22
22
  s.add_runtime_dependency %q<activesupport>, [">= 3.0.10"]
23
+ s.add_runtime_dependency %q<jruby-openssl> if RUBY_PLATFORM == 'java'
23
24
 
24
25
  s.add_development_dependency %q<bundler>, [">= 1.0.0"]
25
26
  s.add_development_dependency %q<rspec>, [">= 2.5.0"]
@@ -31,5 +32,6 @@ Gem::Specification.new do |s|
31
32
  s.add_development_dependency %q<mocha>, [">= 0"]
32
33
  s.add_development_dependency %q<bones>
33
34
  s.add_development_dependency %q<guard-rspec>
34
- s.add_development_dependency 'ruby_gntp'
35
+ s.add_development_dependency %q<ruby_gntp>
36
+ s.add_development_dependency %q<thor>, ["~> 0.14.0"]
35
37
  end
@@ -18,6 +18,7 @@ module Adhearsion
18
18
  component = Punchblock::Component::Asterisk::AGI::Command.new :name => name, :params => params
19
19
  execute_component_and_await_completion component
20
20
  complete_reason = component.complete_event.reason
21
+ raise Adhearsion::Call::Hangup if complete_reason.is_a?(Punchblock::Event::Complete::Hangup)
21
22
  [:code, :result, :data].map { |p| complete_reason.send p }
22
23
  end
23
24
 
@@ -360,10 +361,25 @@ module Adhearsion
360
361
  #Executes SayNumber with the passed argument.
361
362
  #
362
363
  # @param [Numeric|String] Numeric argument, or a string contanining numbers.
363
- # @return [Boolean] Returns false if the argument could not be played.
364
364
  def play_numeric(argument)
365
- if argument.kind_of?(Numeric) || argument =~ /^\d+$/
366
- execute "SayNumber", argument
365
+ execute "SayNumber", argument
366
+ end
367
+
368
+ #Executes SayDigits with the passed argument.
369
+ #
370
+ # @param [Numeric|String] Numeric argument, or a string contanining numbers.
371
+ def play_digits(argument)
372
+ execute "SayDigits", argument
373
+ end
374
+
375
+ #Executes Playtones with the passed argument.
376
+ #
377
+ # @param [String|Array] Array or comma-separated string of tones.
378
+ # @param [Boolean] Whether to wait for the tones to finish (defaults to false).
379
+ def play_tones(argument, wait = false)
380
+ tones = [*argument].join(",")
381
+ execute("Playtones", tones).tap do
382
+ sleep tones.scan(/(?<=\/)\d+/).map(&:to_i).sum.to_f / 1000 if wait
367
383
  end
368
384
  end
369
385
 
@@ -1,5 +1,5 @@
1
1
  module Adhearsion
2
2
  module Asterisk
3
- VERSION = "1.2.0"
3
+ VERSION = "1.2.1"
4
4
  end
5
5
  end
@@ -19,13 +19,26 @@ module Adhearsion::Asterisk
19
19
  end
20
20
  end
21
21
 
22
- it 'should execute an AGI command with the specified name and parameters and return the response code, response and data' do
23
- Punchblock::Component::Asterisk::AGI::Command.any_instance.stubs :complete_event => complete_event
22
+ before { Punchblock::Component::Asterisk::AGI::Command.any_instance.stubs :complete_event => complete_event }
24
23
 
24
+ it 'should execute an AGI command with the specified name and parameters and return the response code, response and data' do
25
25
  subject.expects(:execute_component_and_await_completion).once.with expected_agi_command
26
26
  values = subject.agi 'Dial', '4044754842', 15
27
27
  values.should == [200, 1, 'foobar']
28
28
  end
29
+
30
+ context 'when AGI terminates because of a hangup' do
31
+ let :complete_event do
32
+ Punchblock::Event::Complete.new.tap do |c|
33
+ c.reason = Punchblock::Event::Complete::Hangup.new
34
+ end
35
+ end
36
+
37
+ it 'should raise Adhearsion::Call::Hangup' do
38
+ subject.expects(:execute_component_and_await_completion).once.with expected_agi_command
39
+ lambda { subject.agi 'Dial', '4044754842', 15 }.should raise_error(Adhearsion::Call::Hangup)
40
+ end
41
+ end
29
42
  end
30
43
 
31
44
  describe '#execute' do
@@ -436,6 +449,35 @@ module Adhearsion::Asterisk
436
449
  end
437
450
  end
438
451
 
452
+ describe "#play_digits" do
453
+ let(:numeric) { 20 }
454
+ it "should send the correct command SayDigits playing a numeric argument" do
455
+ subject.expects(:execute).once.with("SayDigits", numeric)
456
+ subject.play_digits(numeric)
457
+ end
458
+ end
459
+
460
+ describe "#play_tones" do
461
+ context "should send the correct command Playtones playing tones" do
462
+ before do
463
+ subject.expects(:execute).once.with("Playtones", "!950/330,!1400/330,!1800/330,0")
464
+ end
465
+
466
+ it "given as a string" do
467
+ subject.play_tones("!950/330,!1400/330,!1800/330,0")
468
+ end
469
+
470
+ it "given as an array" do
471
+ subject.play_tones(["!950/330","!1400/330","!1800/330","0"])
472
+ end
473
+
474
+ it "and sleep for the duration when instructed" do
475
+ subject.expects(:sleep).once.with(0.99)
476
+ subject.play_tones("!950/330,!1400/330,!1800/330,0", true)
477
+ end
478
+ end
479
+ end
480
+
439
481
  describe "#play_soundfile" do
440
482
  let(:audiofile) { "tt-monkeys" }
441
483
  it "should send the correct command Playback playing an audio file" do
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'adhearsion/asterisk/config_generator/voicemail'
3
+ require 'ostruct'
3
4
 
4
5
  describe 'Basic requirements of the Voicemail config generator' do
5
6
  attr_reader :config
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adhearsion-asterisk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Langfeld
9
9
  - Taylor Carpenter
10
+ - Luca Pradovera
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2012-04-30 00:00:00.000000000 Z
14
+ date: 2012-06-22 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: adhearsion
@@ -220,11 +221,28 @@ dependencies:
220
221
  - - ! '>='
221
222
  - !ruby/object:Gem::Version
222
223
  version: '0'
224
+ - !ruby/object:Gem::Dependency
225
+ name: thor
226
+ requirement: !ruby/object:Gem::Requirement
227
+ none: false
228
+ requirements:
229
+ - - ~>
230
+ - !ruby/object:Gem::Version
231
+ version: 0.14.0
232
+ type: :development
233
+ prerelease: false
234
+ version_requirements: !ruby/object:Gem::Requirement
235
+ none: false
236
+ requirements:
237
+ - - ~>
238
+ - !ruby/object:Gem::Version
239
+ version: 0.14.0
223
240
  description: An Adhearsion Plugin providing Asterisk-specific dialplan methods, AMI
224
241
  access, and access to Asterisk configuration
225
242
  email:
226
243
  - blangfeld@adhearsion.com
227
244
  - taylor@codecafe.com
245
+ - lpradovera@mojolingo.com
228
246
  executables: []
229
247
  extensions: []
230
248
  extra_rdoc_files: []
@@ -280,7 +298,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
280
298
  version: '0'
281
299
  segments:
282
300
  - 0
283
- hash: -1875001914852062926
301
+ hash: -489585779242727687
284
302
  required_rubygems_version: !ruby/object:Gem::Requirement
285
303
  none: false
286
304
  requirements:
@@ -289,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
289
307
  version: '0'
290
308
  segments:
291
309
  - 0
292
- hash: -1875001914852062926
310
+ hash: -489585779242727687
293
311
  requirements: []
294
312
  rubyforge_project: adhearsion-asterisk
295
313
  rubygems_version: 1.8.21
@@ -310,3 +328,4 @@ test_files:
310
328
  - spec/has_agi_context.rb
311
329
  - spec/spec_helper.rb
312
330
  - spec/support/the_following_code.rb
331
+ has_rdoc: