adhearsion 2.0.0.alpha1 → 2.0.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +12 -0
- data/CHANGELOG.md +17 -0
- data/adhearsion.gemspec +4 -3
- data/features/app_generator.feature +3 -1
- data/features/cli.feature +7 -7
- data/features/support/env.rb +46 -0
- data/lib/adhearsion.rb +1 -2
- data/lib/adhearsion/call.rb +59 -19
- data/lib/adhearsion/call_controller.rb +20 -24
- data/lib/adhearsion/call_controller/dial.rb +18 -18
- data/lib/adhearsion/cli_commands.rb +26 -9
- data/lib/adhearsion/configuration.rb +39 -10
- data/lib/adhearsion/console.rb +61 -42
- data/lib/adhearsion/foundation/libc.rb +13 -0
- data/lib/adhearsion/generators/app/app_generator.rb +4 -1
- data/lib/adhearsion/generators/app/templates/{Gemfile → Gemfile.erb} +1 -1
- data/lib/adhearsion/generators/app/templates/Rakefile +3 -22
- data/lib/adhearsion/generators/app/templates/gitignore +7 -0
- data/lib/adhearsion/generators/app/templates/lib/simon_game.rb +1 -0
- data/lib/adhearsion/generators/app/templates/script/ahn +1 -0
- data/lib/adhearsion/initializer.rb +24 -12
- data/lib/adhearsion/linux_proc_name.rb +41 -0
- data/lib/adhearsion/outbound_call.rb +10 -5
- data/lib/adhearsion/plugin.rb +29 -132
- data/lib/adhearsion/process.rb +4 -1
- data/lib/adhearsion/punchblock_plugin.rb +14 -5
- data/lib/adhearsion/punchblock_plugin/initializer.rb +8 -1
- data/lib/adhearsion/router/route.rb +1 -3
- data/lib/adhearsion/tasks.rb +6 -12
- data/lib/adhearsion/tasks/configuration.rb +7 -24
- data/lib/adhearsion/tasks/environment.rb +12 -0
- data/lib/adhearsion/tasks/plugins.rb +9 -14
- data/lib/adhearsion/version.rb +1 -1
- data/spec/adhearsion/call_controller/dial_spec.rb +46 -22
- data/spec/adhearsion/call_controller_spec.rb +48 -13
- data/spec/adhearsion/call_spec.rb +144 -23
- data/spec/adhearsion/calls_spec.rb +8 -4
- data/spec/adhearsion/console_spec.rb +24 -0
- data/spec/adhearsion/initializer/logging_spec.rb +0 -3
- data/spec/adhearsion/initializer_spec.rb +52 -37
- data/spec/adhearsion/logging_spec.rb +0 -3
- data/spec/adhearsion/outbound_call_spec.rb +12 -2
- data/spec/adhearsion/plugin_spec.rb +74 -184
- data/spec/adhearsion/process_spec.rb +59 -26
- data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +3 -4
- data/spec/adhearsion/punchblock_plugin_spec.rb +11 -0
- data/spec/adhearsion/router/route_spec.rb +37 -6
- data/spec/adhearsion_spec.rb +31 -8
- data/spec/spec_helper.rb +14 -0
- data/spec/support/call_controller_test_helpers.rb +2 -2
- data/spec/support/logging_helpers.rb +2 -0
- metadata +85 -68
- data/lib/adhearsion/dialplan_controller.rb +0 -9
- data/lib/adhearsion/foundation/synchronized_hash.rb +0 -93
- data/lib/adhearsion/plugin/methods_container.rb +0 -6
- data/spec/adhearsion/dialplan_controller_spec.rb +0 -26
@@ -1,93 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# Implementation of a Thread-safe Hash. Works by delegating methods to a Hash behind-the-scenes after obtaining an exclusive # lock. Use exactly as you would a normal Hash.
|
3
|
-
#
|
4
|
-
class SynchronizedHash
|
5
|
-
|
6
|
-
def self.atomically_delegate(method_name)
|
7
|
-
class_eval(<<-RUBY, __FILE__, __LINE__)
|
8
|
-
def #{method_name}(*args, &block)
|
9
|
-
@lock.synchronize do
|
10
|
-
@delegate.send #{method_name.inspect}, *args, &block
|
11
|
-
end
|
12
|
-
end
|
13
|
-
RUBY
|
14
|
-
end
|
15
|
-
|
16
|
-
# Hash-related methods
|
17
|
-
atomically_delegate :[]
|
18
|
-
atomically_delegate :[]=
|
19
|
-
atomically_delegate :all?
|
20
|
-
atomically_delegate :any?
|
21
|
-
atomically_delegate :clear
|
22
|
-
atomically_delegate :collect
|
23
|
-
atomically_delegate :default
|
24
|
-
atomically_delegate :default=
|
25
|
-
atomically_delegate :delete
|
26
|
-
atomically_delegate :delete_if
|
27
|
-
atomically_delegate :detect
|
28
|
-
atomically_delegate :each
|
29
|
-
atomically_delegate :each_key
|
30
|
-
atomically_delegate :each_pair
|
31
|
-
atomically_delegate :each_value
|
32
|
-
atomically_delegate :each_with_index
|
33
|
-
atomically_delegate :empty?
|
34
|
-
atomically_delegate :entries
|
35
|
-
atomically_delegate :fetch
|
36
|
-
atomically_delegate :find
|
37
|
-
atomically_delegate :find_all
|
38
|
-
atomically_delegate :grep
|
39
|
-
atomically_delegate :has_key?
|
40
|
-
atomically_delegate :has_value?
|
41
|
-
atomically_delegate :include?
|
42
|
-
atomically_delegate :index
|
43
|
-
atomically_delegate :indexes
|
44
|
-
atomically_delegate :indices
|
45
|
-
atomically_delegate :inject
|
46
|
-
atomically_delegate :invert
|
47
|
-
atomically_delegate :key?
|
48
|
-
atomically_delegate :keys
|
49
|
-
atomically_delegate :length
|
50
|
-
atomically_delegate :map
|
51
|
-
atomically_delegate :max
|
52
|
-
atomically_delegate :member?
|
53
|
-
atomically_delegate :merge
|
54
|
-
atomically_delegate :merge!
|
55
|
-
atomically_delegate :min
|
56
|
-
atomically_delegate :partition
|
57
|
-
atomically_delegate :rehash
|
58
|
-
atomically_delegate :reject
|
59
|
-
atomically_delegate :reject!
|
60
|
-
atomically_delegate :replace
|
61
|
-
atomically_delegate :select
|
62
|
-
atomically_delegate :shift
|
63
|
-
atomically_delegate :size
|
64
|
-
atomically_delegate :sort
|
65
|
-
atomically_delegate :sort_by
|
66
|
-
atomically_delegate :store
|
67
|
-
atomically_delegate :to_hash
|
68
|
-
atomically_delegate :update
|
69
|
-
atomically_delegate :value?
|
70
|
-
atomically_delegate :values
|
71
|
-
atomically_delegate :values_at
|
72
|
-
atomically_delegate :zip
|
73
|
-
|
74
|
-
# Object-related methods
|
75
|
-
atomically_delegate :inspect
|
76
|
-
atomically_delegate :to_s
|
77
|
-
atomically_delegate :marshal_dump
|
78
|
-
|
79
|
-
def initialize(*args, &block)
|
80
|
-
@delegate = Hash.new *args, &block
|
81
|
-
@lock = Mutex.new
|
82
|
-
end
|
83
|
-
|
84
|
-
##
|
85
|
-
# If you need to do many operations atomically (a la transaction), you can call this method and access the yielded Hash
|
86
|
-
# which can be safely modified for the duration of your block.
|
87
|
-
#
|
88
|
-
# @yield [Hash] the Hash on which you can safely operate during your block.
|
89
|
-
#
|
90
|
-
def with_lock(&block)
|
91
|
-
@lock.synchronize { yield @delegate }
|
92
|
-
end
|
93
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Adhearsion
|
4
|
-
describe DialplanController do
|
5
|
-
include CallControllerTestHelpers
|
6
|
-
|
7
|
-
it { should be_a DialplanController }
|
8
|
-
it { should be_a CallController }
|
9
|
-
|
10
|
-
let :dialplan do
|
11
|
-
Proc.new { foo value }
|
12
|
-
end
|
13
|
-
|
14
|
-
before { subject.dialplan = dialplan }
|
15
|
-
|
16
|
-
its(:dialplan) { should be dialplan }
|
17
|
-
|
18
|
-
describe "running" do
|
19
|
-
it "should execute the dialplan in the context of the controller" do
|
20
|
-
flexmock subject, :value => :bar
|
21
|
-
subject.should_receive(:foo).once.with(:bar)
|
22
|
-
subject.run
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|