punchblock 0.6.2 → 0.7.0
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/.gitignore +0 -1
- data/CHANGELOG.md +9 -0
- data/Guardfile +5 -0
- data/lib/punchblock/client.rb +2 -2
- data/lib/punchblock/component/component_node.rb +72 -0
- data/lib/punchblock/component/input.rb +14 -0
- data/lib/punchblock/component/stop.rb +7 -0
- data/lib/punchblock/component/tropo/conference.rb +2 -2
- data/lib/punchblock/component.rb +2 -63
- data/lib/punchblock/connection/asterisk.rb +1 -1
- data/lib/punchblock/translator/asterisk/call.rb +6 -5
- data/lib/punchblock/translator/asterisk.rb +10 -11
- data/lib/punchblock/version.rb +1 -1
- data/lib/punchblock.rb +0 -1
- data/punchblock.gemspec +3 -3
- data/spec/punchblock/{component_spec.rb → component/component_node_spec.rb} +32 -19
- data/spec/punchblock/component/input_spec.rb +4 -0
- data/spec/punchblock/connection/asterisk_spec.rb +5 -1
- data/spec/punchblock/connection/xmpp_spec.rb +1 -1
- data/spec/punchblock/translator/asterisk/call_spec.rb +26 -9
- data/spec/punchblock/translator/asterisk/component/asterisk/agi_command_spec.rb +1 -1
- data/spec/punchblock/translator/asterisk/component/asterisk/ami_action_spec.rb +4 -4
- data/spec/punchblock/translator/asterisk_spec.rb +34 -21
- metadata +55 -57
- data/bin/punchblock-console +0 -140
- data/lib/punchblock/core_ext/celluloid.rb +0 -11
- data/lib/punchblock/dsl.rb +0 -45
- data/log/.gitkeep +0 -0
|
@@ -6,18 +6,22 @@ module Punchblock
|
|
|
6
6
|
let(:ami_client) { mock 'RubyAMI::Client' }
|
|
7
7
|
let(:connection) { mock 'Connection::Asterisk' }
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
let(:translator) { Asterisk.new ami_client, connection }
|
|
10
|
+
|
|
11
|
+
subject { translator }
|
|
10
12
|
|
|
11
13
|
its(:ami_client) { should be ami_client }
|
|
12
14
|
its(:connection) { should be connection }
|
|
13
15
|
|
|
16
|
+
after { translator.terminate }
|
|
17
|
+
|
|
14
18
|
describe '#execute_command' do
|
|
15
19
|
describe 'with a call command' do
|
|
16
20
|
let(:command) { Command::Answer.new }
|
|
17
21
|
let(:call_id) { 'abc123' }
|
|
18
22
|
|
|
19
23
|
it 'executes the call command' do
|
|
20
|
-
subject.
|
|
24
|
+
subject.wrapped_object.expects(:execute_call_command).with do |c|
|
|
21
25
|
c.should be command
|
|
22
26
|
c.call_id.should == call_id
|
|
23
27
|
end
|
|
@@ -25,18 +29,16 @@ module Punchblock
|
|
|
25
29
|
end
|
|
26
30
|
end
|
|
27
31
|
|
|
28
|
-
describe 'with a component command' do
|
|
32
|
+
describe 'with a global component command' do
|
|
29
33
|
let(:command) { Component::Stop.new }
|
|
30
|
-
let(:call_id) { 'abc123' }
|
|
31
34
|
let(:component_id) { '123abc' }
|
|
32
35
|
|
|
33
36
|
it 'executes the component command' do
|
|
34
|
-
subject.
|
|
37
|
+
subject.wrapped_object.expects(:execute_component_command).with do |c|
|
|
35
38
|
c.should be command
|
|
36
|
-
c.call_id.should == call_id
|
|
37
39
|
c.component_id.should == component_id
|
|
38
40
|
end
|
|
39
|
-
subject.execute_command command, :
|
|
41
|
+
subject.execute_command command, :component_id => component_id
|
|
40
42
|
end
|
|
41
43
|
end
|
|
42
44
|
|
|
@@ -44,7 +46,7 @@ module Punchblock
|
|
|
44
46
|
let(:command) { Command::Dial.new }
|
|
45
47
|
|
|
46
48
|
it 'executes the command directly' do
|
|
47
|
-
subject.
|
|
49
|
+
subject.wrapped_object.expects(:execute_global_command).with command
|
|
48
50
|
subject.execute_command command
|
|
49
51
|
end
|
|
50
52
|
end
|
|
@@ -64,11 +66,21 @@ module Punchblock
|
|
|
64
66
|
subject.call_with_id(call_id).should be call
|
|
65
67
|
end
|
|
66
68
|
|
|
67
|
-
it 'should make the call accessible by
|
|
69
|
+
it 'should make the call accessible by channel' do
|
|
68
70
|
subject.call_for_channel(channel).should be call
|
|
69
71
|
end
|
|
70
72
|
end
|
|
71
73
|
|
|
74
|
+
describe '#register_component' do
|
|
75
|
+
let(:component_id) { 'abc123' }
|
|
76
|
+
let(:component) { mock 'Asterisk::Component::Asterisk::AMIAction', :id => component_id }
|
|
77
|
+
|
|
78
|
+
it 'should make the component accessible by ID' do
|
|
79
|
+
subject.register_component component
|
|
80
|
+
subject.component_with_id(component_id).should be component
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
72
84
|
describe '#execute_call_command' do
|
|
73
85
|
let(:call_id) { 'abc123' }
|
|
74
86
|
let(:call) { Translator::Asterisk::Call.new 'SIP/foo', subject }
|
|
@@ -86,18 +98,13 @@ module Punchblock
|
|
|
86
98
|
end
|
|
87
99
|
|
|
88
100
|
describe '#execute_component_command' do
|
|
89
|
-
let(:call_id) { 'abc123' }
|
|
90
|
-
let(:call) { Translator::Asterisk::Call.new 'SIP/foo', subject }
|
|
91
|
-
|
|
92
101
|
let(:component_id) { '123abc' }
|
|
93
102
|
let(:component) { mock 'Translator::Asterisk::Component', :id => component_id }
|
|
94
103
|
|
|
95
|
-
let(:command) { mock 'Component::Stop', :
|
|
104
|
+
let(:command) { mock 'Component::Stop', :component_id => component_id }
|
|
96
105
|
|
|
97
106
|
before do
|
|
98
|
-
|
|
99
|
-
call.register_component component
|
|
100
|
-
subject.register_call call
|
|
107
|
+
subject.register_component component
|
|
101
108
|
end
|
|
102
109
|
|
|
103
110
|
it 'sends the command to the component for execution' do
|
|
@@ -116,13 +123,19 @@ module Punchblock
|
|
|
116
123
|
Component::Asterisk::AMI::Action.new :name => 'Status', :params => { :channel => 'foo' }
|
|
117
124
|
end
|
|
118
125
|
|
|
119
|
-
let(:mock_action) {
|
|
126
|
+
let(:mock_action) { stub_everything 'Asterisk::Component::Asterisk::AMIAction' }
|
|
120
127
|
|
|
121
128
|
it 'should create a component actor and execute it asynchronously' do
|
|
122
129
|
Asterisk::Component::Asterisk::AMIAction.expects(:new).once.with(command, subject).returns mock_action
|
|
123
130
|
mock_action.expects(:execute!).once
|
|
124
131
|
subject.execute_global_command command
|
|
125
132
|
end
|
|
133
|
+
|
|
134
|
+
it 'registers the component' do
|
|
135
|
+
Asterisk::Component::Asterisk::AMIAction.expects(:new).once.with(command, subject).returns mock_action
|
|
136
|
+
subject.wrapped_object.expects(:register_component).with mock_action
|
|
137
|
+
subject.execute_global_command command
|
|
138
|
+
end
|
|
126
139
|
end
|
|
127
140
|
end
|
|
128
141
|
|
|
@@ -192,12 +205,12 @@ module Punchblock
|
|
|
192
205
|
end
|
|
193
206
|
end
|
|
194
207
|
|
|
195
|
-
before { subject.
|
|
208
|
+
before { subject.wrapped_object.stubs :handle_pb_event }
|
|
196
209
|
|
|
197
210
|
it 'should be able to look up the call by channel ID' do
|
|
198
211
|
subject.handle_ami_event ami_event
|
|
199
212
|
call_actor = subject.call_for_channel('SIP/1234-00000000')
|
|
200
|
-
call_actor.
|
|
213
|
+
call_actor.wrapped_object.should be_a Asterisk::Call
|
|
201
214
|
call_actor.agi_env.should be_a Hash
|
|
202
215
|
call_actor.agi_env[:agi_request].should == 'async'
|
|
203
216
|
end
|
|
@@ -227,12 +240,12 @@ module Punchblock
|
|
|
227
240
|
end
|
|
228
241
|
|
|
229
242
|
before do
|
|
230
|
-
subject.
|
|
243
|
+
subject.wrapped_object.stubs :handle_pb_event
|
|
231
244
|
subject.register_call call
|
|
232
245
|
end
|
|
233
246
|
|
|
234
247
|
it 'sends the AMI event to the call and to the connection as a PB event' do
|
|
235
|
-
subject.
|
|
248
|
+
subject.wrapped_object.expects(:handle_pb_event).once
|
|
236
249
|
call.expects(:process_ami_event!).once.with ami_event
|
|
237
250
|
subject.handle_ami_event ami_event
|
|
238
251
|
end
|
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: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -11,11 +11,11 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2011-11-
|
|
14
|
+
date: 2011-11-22 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: niceogiri
|
|
18
|
-
requirement: &
|
|
18
|
+
requirement: &2152241520 !ruby/object:Gem::Requirement
|
|
19
19
|
none: false
|
|
20
20
|
requirements:
|
|
21
21
|
- - ! '>='
|
|
@@ -23,10 +23,10 @@ dependencies:
|
|
|
23
23
|
version: 0.0.4
|
|
24
24
|
type: :runtime
|
|
25
25
|
prerelease: false
|
|
26
|
-
version_requirements: *
|
|
26
|
+
version_requirements: *2152241520
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: blather
|
|
29
|
-
requirement: &
|
|
29
|
+
requirement: &2152240540 !ruby/object:Gem::Requirement
|
|
30
30
|
none: false
|
|
31
31
|
requirements:
|
|
32
32
|
- - ! '>='
|
|
@@ -34,21 +34,10 @@ dependencies:
|
|
|
34
34
|
version: 0.5.7
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
|
-
version_requirements: *
|
|
38
|
-
- !ruby/object:Gem::Dependency
|
|
39
|
-
name: pry
|
|
40
|
-
requirement: &2156232040 !ruby/object:Gem::Requirement
|
|
41
|
-
none: false
|
|
42
|
-
requirements:
|
|
43
|
-
- - ! '>='
|
|
44
|
-
- !ruby/object:Gem::Version
|
|
45
|
-
version: 0.8.3
|
|
46
|
-
type: :runtime
|
|
47
|
-
prerelease: false
|
|
48
|
-
version_requirements: *2156232040
|
|
37
|
+
version_requirements: *2152240540
|
|
49
38
|
- !ruby/object:Gem::Dependency
|
|
50
39
|
name: activesupport
|
|
51
|
-
requirement: &
|
|
40
|
+
requirement: &2152237640 !ruby/object:Gem::Requirement
|
|
52
41
|
none: false
|
|
53
42
|
requirements:
|
|
54
43
|
- - ! '>='
|
|
@@ -56,10 +45,10 @@ dependencies:
|
|
|
56
45
|
version: 2.1.0
|
|
57
46
|
type: :runtime
|
|
58
47
|
prerelease: false
|
|
59
|
-
version_requirements: *
|
|
48
|
+
version_requirements: *2152237640
|
|
60
49
|
- !ruby/object:Gem::Dependency
|
|
61
50
|
name: state_machine
|
|
62
|
-
requirement: &
|
|
51
|
+
requirement: &2152235840 !ruby/object:Gem::Requirement
|
|
63
52
|
none: false
|
|
64
53
|
requirements:
|
|
65
54
|
- - ! '>='
|
|
@@ -67,10 +56,10 @@ dependencies:
|
|
|
67
56
|
version: 1.0.1
|
|
68
57
|
type: :runtime
|
|
69
58
|
prerelease: false
|
|
70
|
-
version_requirements: *
|
|
59
|
+
version_requirements: *2152235840
|
|
71
60
|
- !ruby/object:Gem::Dependency
|
|
72
61
|
name: future-resource
|
|
73
|
-
requirement: &
|
|
62
|
+
requirement: &2152460240 !ruby/object:Gem::Requirement
|
|
74
63
|
none: false
|
|
75
64
|
requirements:
|
|
76
65
|
- - ! '>='
|
|
@@ -78,10 +67,10 @@ dependencies:
|
|
|
78
67
|
version: 0.0.2
|
|
79
68
|
type: :runtime
|
|
80
69
|
prerelease: false
|
|
81
|
-
version_requirements: *
|
|
70
|
+
version_requirements: *2152460240
|
|
82
71
|
- !ruby/object:Gem::Dependency
|
|
83
72
|
name: has-guarded-handlers
|
|
84
|
-
requirement: &
|
|
73
|
+
requirement: &2152456100 !ruby/object:Gem::Requirement
|
|
85
74
|
none: false
|
|
86
75
|
requirements:
|
|
87
76
|
- - ! '>='
|
|
@@ -89,32 +78,32 @@ dependencies:
|
|
|
89
78
|
version: 0.1.0
|
|
90
79
|
type: :runtime
|
|
91
80
|
prerelease: false
|
|
92
|
-
version_requirements: *
|
|
81
|
+
version_requirements: *2152456100
|
|
93
82
|
- !ruby/object:Gem::Dependency
|
|
94
83
|
name: celluloid
|
|
95
|
-
requirement: &
|
|
84
|
+
requirement: &2152468640 !ruby/object:Gem::Requirement
|
|
96
85
|
none: false
|
|
97
86
|
requirements:
|
|
98
87
|
- - ! '>='
|
|
99
88
|
- !ruby/object:Gem::Version
|
|
100
|
-
version: 0.
|
|
89
|
+
version: 0.6.0
|
|
101
90
|
type: :runtime
|
|
102
91
|
prerelease: false
|
|
103
|
-
version_requirements: *
|
|
92
|
+
version_requirements: *2152468640
|
|
104
93
|
- !ruby/object:Gem::Dependency
|
|
105
94
|
name: ruby_ami
|
|
106
|
-
requirement: &
|
|
95
|
+
requirement: &2152466340 !ruby/object:Gem::Requirement
|
|
107
96
|
none: false
|
|
108
97
|
requirements:
|
|
109
98
|
- - ! '>='
|
|
110
99
|
- !ruby/object:Gem::Version
|
|
111
|
-
version: 0.1.
|
|
100
|
+
version: 0.1.3
|
|
112
101
|
type: :runtime
|
|
113
102
|
prerelease: false
|
|
114
|
-
version_requirements: *
|
|
103
|
+
version_requirements: *2152466340
|
|
115
104
|
- !ruby/object:Gem::Dependency
|
|
116
105
|
name: bundler
|
|
117
|
-
requirement: &
|
|
106
|
+
requirement: &2152477180 !ruby/object:Gem::Requirement
|
|
118
107
|
none: false
|
|
119
108
|
requirements:
|
|
120
109
|
- - ~>
|
|
@@ -122,10 +111,10 @@ dependencies:
|
|
|
122
111
|
version: 1.0.0
|
|
123
112
|
type: :development
|
|
124
113
|
prerelease: false
|
|
125
|
-
version_requirements: *
|
|
114
|
+
version_requirements: *2152477180
|
|
126
115
|
- !ruby/object:Gem::Dependency
|
|
127
116
|
name: rspec
|
|
128
|
-
requirement: &
|
|
117
|
+
requirement: &2152471200 !ruby/object:Gem::Requirement
|
|
129
118
|
none: false
|
|
130
119
|
requirements:
|
|
131
120
|
- - ! '>='
|
|
@@ -133,10 +122,10 @@ dependencies:
|
|
|
133
122
|
version: 2.5.0
|
|
134
123
|
type: :development
|
|
135
124
|
prerelease: false
|
|
136
|
-
version_requirements: *
|
|
125
|
+
version_requirements: *2152471200
|
|
137
126
|
- !ruby/object:Gem::Dependency
|
|
138
127
|
name: ci_reporter
|
|
139
|
-
requirement: &
|
|
128
|
+
requirement: &2152483240 !ruby/object:Gem::Requirement
|
|
140
129
|
none: false
|
|
141
130
|
requirements:
|
|
142
131
|
- - ! '>='
|
|
@@ -144,10 +133,10 @@ dependencies:
|
|
|
144
133
|
version: 1.6.3
|
|
145
134
|
type: :development
|
|
146
135
|
prerelease: false
|
|
147
|
-
version_requirements: *
|
|
136
|
+
version_requirements: *2152483240
|
|
148
137
|
- !ruby/object:Gem::Dependency
|
|
149
138
|
name: yard
|
|
150
|
-
requirement: &
|
|
139
|
+
requirement: &2152495500 !ruby/object:Gem::Requirement
|
|
151
140
|
none: false
|
|
152
141
|
requirements:
|
|
153
142
|
- - ~>
|
|
@@ -155,10 +144,10 @@ dependencies:
|
|
|
155
144
|
version: 0.6.0
|
|
156
145
|
type: :development
|
|
157
146
|
prerelease: false
|
|
158
|
-
version_requirements: *
|
|
147
|
+
version_requirements: *2152495500
|
|
159
148
|
- !ruby/object:Gem::Dependency
|
|
160
149
|
name: rcov
|
|
161
|
-
requirement: &
|
|
150
|
+
requirement: &2152493260 !ruby/object:Gem::Requirement
|
|
162
151
|
none: false
|
|
163
152
|
requirements:
|
|
164
153
|
- - ! '>='
|
|
@@ -166,10 +155,10 @@ dependencies:
|
|
|
166
155
|
version: '0'
|
|
167
156
|
type: :development
|
|
168
157
|
prerelease: false
|
|
169
|
-
version_requirements: *
|
|
158
|
+
version_requirements: *2152493260
|
|
170
159
|
- !ruby/object:Gem::Dependency
|
|
171
160
|
name: rake
|
|
172
|
-
requirement: &
|
|
161
|
+
requirement: &2152489000 !ruby/object:Gem::Requirement
|
|
173
162
|
none: false
|
|
174
163
|
requirements:
|
|
175
164
|
- - ! '>='
|
|
@@ -177,10 +166,10 @@ dependencies:
|
|
|
177
166
|
version: '0'
|
|
178
167
|
type: :development
|
|
179
168
|
prerelease: false
|
|
180
|
-
version_requirements: *
|
|
169
|
+
version_requirements: *2152489000
|
|
181
170
|
- !ruby/object:Gem::Dependency
|
|
182
171
|
name: mocha
|
|
183
|
-
requirement: &
|
|
172
|
+
requirement: &2152501500 !ruby/object:Gem::Requirement
|
|
184
173
|
none: false
|
|
185
174
|
requirements:
|
|
186
175
|
- - ! '>='
|
|
@@ -188,10 +177,10 @@ dependencies:
|
|
|
188
177
|
version: '0'
|
|
189
178
|
type: :development
|
|
190
179
|
prerelease: false
|
|
191
|
-
version_requirements: *
|
|
180
|
+
version_requirements: *2152501500
|
|
192
181
|
- !ruby/object:Gem::Dependency
|
|
193
182
|
name: i18n
|
|
194
|
-
requirement: &
|
|
183
|
+
requirement: &2152499180 !ruby/object:Gem::Requirement
|
|
195
184
|
none: false
|
|
196
185
|
requirements:
|
|
197
186
|
- - ! '>='
|
|
@@ -199,10 +188,21 @@ dependencies:
|
|
|
199
188
|
version: '0'
|
|
200
189
|
type: :development
|
|
201
190
|
prerelease: false
|
|
202
|
-
version_requirements: *
|
|
191
|
+
version_requirements: *2152499180
|
|
203
192
|
- !ruby/object:Gem::Dependency
|
|
204
193
|
name: countdownlatch
|
|
205
|
-
requirement: &
|
|
194
|
+
requirement: &2152495980 !ruby/object:Gem::Requirement
|
|
195
|
+
none: false
|
|
196
|
+
requirements:
|
|
197
|
+
- - ! '>='
|
|
198
|
+
- !ruby/object:Gem::Version
|
|
199
|
+
version: '0'
|
|
200
|
+
type: :development
|
|
201
|
+
prerelease: false
|
|
202
|
+
version_requirements: *2152495980
|
|
203
|
+
- !ruby/object:Gem::Dependency
|
|
204
|
+
name: guard-rspec
|
|
205
|
+
requirement: &2152510640 !ruby/object:Gem::Requirement
|
|
206
206
|
none: false
|
|
207
207
|
requirements:
|
|
208
208
|
- - ! '>='
|
|
@@ -210,12 +210,11 @@ dependencies:
|
|
|
210
210
|
version: '0'
|
|
211
211
|
type: :development
|
|
212
212
|
prerelease: false
|
|
213
|
-
version_requirements: *
|
|
213
|
+
version_requirements: *2152510640
|
|
214
214
|
description: Like Rack is to Rails and Sinatra, Punchblock provides a consistent API
|
|
215
215
|
on top of several underlying third-party call control protocols.
|
|
216
216
|
email: punchblock@adhearsion.com
|
|
217
|
-
executables:
|
|
218
|
-
- punchblock-console
|
|
217
|
+
executables: []
|
|
219
218
|
extensions: []
|
|
220
219
|
extra_rdoc_files: []
|
|
221
220
|
files:
|
|
@@ -224,6 +223,7 @@ files:
|
|
|
224
223
|
- .rspec
|
|
225
224
|
- CHANGELOG.md
|
|
226
225
|
- Gemfile
|
|
226
|
+
- Guardfile
|
|
227
227
|
- LICENSE.txt
|
|
228
228
|
- README.markdown
|
|
229
229
|
- Rakefile
|
|
@@ -232,7 +232,6 @@ files:
|
|
|
232
232
|
- assets/ozone/ozone-1.0.xsd
|
|
233
233
|
- assets/ozone/say-1.0.xsd
|
|
234
234
|
- assets/ozone/transfer-1.0.xsd
|
|
235
|
-
- bin/punchblock-console
|
|
236
235
|
- lib/punchblock.rb
|
|
237
236
|
- lib/punchblock/client.rb
|
|
238
237
|
- lib/punchblock/client/component_registry.rb
|
|
@@ -254,9 +253,11 @@ files:
|
|
|
254
253
|
- lib/punchblock/component/asterisk/agi/command.rb
|
|
255
254
|
- lib/punchblock/component/asterisk/ami.rb
|
|
256
255
|
- lib/punchblock/component/asterisk/ami/action.rb
|
|
256
|
+
- lib/punchblock/component/component_node.rb
|
|
257
257
|
- lib/punchblock/component/input.rb
|
|
258
258
|
- lib/punchblock/component/output.rb
|
|
259
259
|
- lib/punchblock/component/record.rb
|
|
260
|
+
- lib/punchblock/component/stop.rb
|
|
260
261
|
- lib/punchblock/component/tropo.rb
|
|
261
262
|
- lib/punchblock/component/tropo/ask.rb
|
|
262
263
|
- lib/punchblock/component/tropo/conference.rb
|
|
@@ -269,9 +270,7 @@ files:
|
|
|
269
270
|
- lib/punchblock/connection/xmpp.rb
|
|
270
271
|
- lib/punchblock/core_ext/blather/stanza.rb
|
|
271
272
|
- lib/punchblock/core_ext/blather/stanza/presence.rb
|
|
272
|
-
- lib/punchblock/core_ext/celluloid.rb
|
|
273
273
|
- lib/punchblock/core_ext/ruby.rb
|
|
274
|
-
- lib/punchblock/dsl.rb
|
|
275
274
|
- lib/punchblock/event.rb
|
|
276
275
|
- lib/punchblock/event/answered.rb
|
|
277
276
|
- lib/punchblock/event/asterisk.rb
|
|
@@ -300,7 +299,6 @@ files:
|
|
|
300
299
|
- lib/punchblock/translator/asterisk/component/asterisk/agi_command.rb
|
|
301
300
|
- lib/punchblock/translator/asterisk/component/asterisk/ami_action.rb
|
|
302
301
|
- lib/punchblock/version.rb
|
|
303
|
-
- log/.gitkeep
|
|
304
302
|
- punchblock.gemspec
|
|
305
303
|
- spec/punchblock/client/component_registry_spec.rb
|
|
306
304
|
- spec/punchblock/client_spec.rb
|
|
@@ -317,6 +315,7 @@ files:
|
|
|
317
315
|
- spec/punchblock/command_node_spec.rb
|
|
318
316
|
- spec/punchblock/component/asterisk/agi/command_spec.rb
|
|
319
317
|
- spec/punchblock/component/asterisk/ami/action_spec.rb
|
|
318
|
+
- spec/punchblock/component/component_node_spec.rb
|
|
320
319
|
- spec/punchblock/component/input_spec.rb
|
|
321
320
|
- spec/punchblock/component/output_spec.rb
|
|
322
321
|
- spec/punchblock/component/record_spec.rb
|
|
@@ -324,7 +323,6 @@ files:
|
|
|
324
323
|
- spec/punchblock/component/tropo/conference_spec.rb
|
|
325
324
|
- spec/punchblock/component/tropo/say_spec.rb
|
|
326
325
|
- spec/punchblock/component/tropo/transfer_spec.rb
|
|
327
|
-
- spec/punchblock/component_spec.rb
|
|
328
326
|
- spec/punchblock/connection/asterisk_spec.rb
|
|
329
327
|
- spec/punchblock/connection/xmpp_spec.rb
|
|
330
328
|
- spec/punchblock/event/answered_spec.rb
|
|
@@ -386,6 +384,7 @@ test_files:
|
|
|
386
384
|
- spec/punchblock/command_node_spec.rb
|
|
387
385
|
- spec/punchblock/component/asterisk/agi/command_spec.rb
|
|
388
386
|
- spec/punchblock/component/asterisk/ami/action_spec.rb
|
|
387
|
+
- spec/punchblock/component/component_node_spec.rb
|
|
389
388
|
- spec/punchblock/component/input_spec.rb
|
|
390
389
|
- spec/punchblock/component/output_spec.rb
|
|
391
390
|
- spec/punchblock/component/record_spec.rb
|
|
@@ -393,7 +392,6 @@ test_files:
|
|
|
393
392
|
- spec/punchblock/component/tropo/conference_spec.rb
|
|
394
393
|
- spec/punchblock/component/tropo/say_spec.rb
|
|
395
394
|
- spec/punchblock/component/tropo/transfer_spec.rb
|
|
396
|
-
- spec/punchblock/component_spec.rb
|
|
397
395
|
- spec/punchblock/connection/asterisk_spec.rb
|
|
398
396
|
- spec/punchblock/connection/xmpp_spec.rb
|
|
399
397
|
- spec/punchblock/event/answered_spec.rb
|
data/bin/punchblock-console
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
|
|
3
|
-
require 'rubygems'
|
|
4
|
-
require 'bundler/setup'
|
|
5
|
-
require 'punchblock'
|
|
6
|
-
require 'pry'
|
|
7
|
-
require 'logger'
|
|
8
|
-
require 'optparse'
|
|
9
|
-
|
|
10
|
-
puts <<-DEPRECATION
|
|
11
|
-
********************
|
|
12
|
-
WARNING: This utility is deprecated and will be removed from a future version of Punchblock without further notice. You should use the punchblock-console gem instead.
|
|
13
|
-
********************
|
|
14
|
-
DEPRECATION
|
|
15
|
-
|
|
16
|
-
include Punchblock
|
|
17
|
-
|
|
18
|
-
Thread.abort_on_exception = true
|
|
19
|
-
|
|
20
|
-
options = { :username => 'usera@127.0.0.1', :password => '1', :wire_log_file => 'log/rayo-wire.log', :transport_log_file => 'log/rayo-transport.log', :auto_reconnect => false }
|
|
21
|
-
|
|
22
|
-
connection_class = Connection::XMPP
|
|
23
|
-
|
|
24
|
-
option_parser = OptionParser.new do |opts|
|
|
25
|
-
opts.banner = "Usage: punchblock-console [-u usera@127.0.0.1] [-p abc123]"
|
|
26
|
-
opts.on("-u", "--username USERNAME", String, "Specify the XMPP JID to connect to") do |u|
|
|
27
|
-
options[:username] = u
|
|
28
|
-
end
|
|
29
|
-
opts.on("-p", "--password PASSWORD", String, "Specify the XMPP password to use") do |p|
|
|
30
|
-
options[:password] = p
|
|
31
|
-
end
|
|
32
|
-
opts.on("-d", "--rayo-domain DOMAIN", String, "Specify the domain Rayo is running on") do |d|
|
|
33
|
-
options[:rayo_domain] = d
|
|
34
|
-
end
|
|
35
|
-
opts.on("--wire-log-file log/wirelog.log", String, "Specify the file to which the wire log should be written") do |wlf|
|
|
36
|
-
options[:wire_log_file] = wlf
|
|
37
|
-
end
|
|
38
|
-
opts.on("--transport-log-file log/transportlog.log", String, "Specify the file to which the transport log should be written") do |tlf|
|
|
39
|
-
options[:transport_log_file] = tlf
|
|
40
|
-
end
|
|
41
|
-
opts.on("--asterisk", "Use Asterisk") do |tlf|
|
|
42
|
-
connection_class = Connection::Asterisk
|
|
43
|
-
options[:host] = '127.0.0.1'
|
|
44
|
-
options[:port] = 5038
|
|
45
|
-
end
|
|
46
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
|
47
|
-
puts opts
|
|
48
|
-
exit
|
|
49
|
-
end
|
|
50
|
-
opts.on_tail("-v", "--version", "Show version") do
|
|
51
|
-
puts VERSION
|
|
52
|
-
exit
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
begin
|
|
57
|
-
option_parser.parse!
|
|
58
|
-
rescue
|
|
59
|
-
puts $!
|
|
60
|
-
option_parser.parse '--help'
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
options[:wire_logger] = Logger.new options.delete(:wire_log_file)
|
|
64
|
-
options[:wire_logger].level = Logger::DEBUG
|
|
65
|
-
options[:wire_logger].debug "Starting up..."
|
|
66
|
-
options[:transport_logger] = Logger.new options.delete(:transport_log_file)
|
|
67
|
-
options[:transport_logger].level = Logger::DEBUG
|
|
68
|
-
options[:transport_logger].debug "Starting up..."
|
|
69
|
-
options[:logger] = options[:wire_logger]
|
|
70
|
-
|
|
71
|
-
connection = connection_class.new options
|
|
72
|
-
client = Client.new :connection => connection
|
|
73
|
-
|
|
74
|
-
[:INT, :TERM].each do |signal|
|
|
75
|
-
trap signal do
|
|
76
|
-
puts "Shutting down!"
|
|
77
|
-
client.stop
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
client_thread = Thread.new do
|
|
82
|
-
begin
|
|
83
|
-
client.run
|
|
84
|
-
rescue => e
|
|
85
|
-
puts "Exception in XMPP thread! #{e.message}"
|
|
86
|
-
puts e.backtrace.join("\t\n")
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
CALL_QUEUES = {}
|
|
91
|
-
|
|
92
|
-
### DISPATCHER THREAD
|
|
93
|
-
# This thread multiplexes the event stream from the underlying connection handler and routes them
|
|
94
|
-
# to the correct queue for each call. It also starts a call handler, the run_call method) after creating
|
|
95
|
-
# the queue.
|
|
96
|
-
Thread.new do
|
|
97
|
-
loop do
|
|
98
|
-
event = client.event_queue.pop
|
|
99
|
-
if event == Connection::Connected
|
|
100
|
-
puts event
|
|
101
|
-
puts "Waiting for a call..."
|
|
102
|
-
next
|
|
103
|
-
end
|
|
104
|
-
unless event.call_id
|
|
105
|
-
puts "Ad-hoc event: #{event.inspect}"
|
|
106
|
-
next
|
|
107
|
-
end
|
|
108
|
-
puts "#{event.class} event for call: #{event.call_id}"
|
|
109
|
-
case event
|
|
110
|
-
when Event::Offer
|
|
111
|
-
raise "Duplicate call ID for #{event.call_id}" if CALL_QUEUES.has_key?(event.call_id)
|
|
112
|
-
CALL_QUEUES[event.call_id] = Queue.new
|
|
113
|
-
CALL_QUEUES[event.call_id].push event
|
|
114
|
-
run_call client, event
|
|
115
|
-
when Event
|
|
116
|
-
CALL_QUEUES[event.call_id].push event
|
|
117
|
-
else
|
|
118
|
-
puts "Unknown event: #{event.inspect}"
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def run_call(client, offer)
|
|
124
|
-
### CALL THREAD
|
|
125
|
-
# One thread is spun up to handle each call.
|
|
126
|
-
Thread.new do
|
|
127
|
-
raise "Unknown call #{offer.call_id}" unless CALL_QUEUES.has_key?(offer.call_id)
|
|
128
|
-
queue = CALL_QUEUES[offer.call_id]
|
|
129
|
-
call = queue.pop
|
|
130
|
-
dsl = DSL.new client, offer.call_id, queue
|
|
131
|
-
|
|
132
|
-
puts "Incoming offer to #{offer.to} from #{offer.headers_hash[:from]} #{offer}"
|
|
133
|
-
dsl.pry
|
|
134
|
-
|
|
135
|
-
# Clean up the queue.
|
|
136
|
-
CALL_QUEUES[offer.call_id] = nil
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
client_thread.join
|
data/lib/punchblock/dsl.rb
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
##
|
|
2
|
-
# DO NOT USE THIS API!
|
|
3
|
-
# This file is temporary, to help make testing Punchblock easier.
|
|
4
|
-
# THIS IS IMPERMANENT AND WILL DISAPPEAR
|
|
5
|
-
module Punchblock
|
|
6
|
-
class DSL
|
|
7
|
-
def initialize(client, call_id, queue) # :nodoc:
|
|
8
|
-
@client, @call_id, @queue = client, call_id, queue
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def accept # :nodoc:
|
|
12
|
-
write Command::Accept.new
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def answer # :nodoc:
|
|
16
|
-
write Command::Answer.new
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def hangup # :nodoc:
|
|
20
|
-
write Command::Hangup.new
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def reject(reason = nil) # :nodoc:
|
|
24
|
-
write Command::Reject.new(:reason => reason)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def redirect(dest) # :nodoc:
|
|
28
|
-
write Command::Redirect.new(:to => dest)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def record(options = {})
|
|
32
|
-
write Component::Record.new(options)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def say(string, type = :text) # :nodoc:
|
|
36
|
-
component = Component::Tropo::Say.new(type => string)
|
|
37
|
-
write component
|
|
38
|
-
component.complete_event.resource
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def write(command) # :nodoc:
|
|
42
|
-
@client.execute_command command, :call_id => @call_id, :async => false
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
data/log/.gitkeep
DELETED
|
File without changes
|