ruby-asterisk 0.2.0 → 1.0.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.
- checksums.yaml +5 -5
- data/.claude/skills/ruby-asterisk-agi/SKILL.md +317 -0
- data/.claude/skills/ruby-asterisk-ami/SKILL.md +187 -0
- data/.claude/skills/ruby-asterisk-ari/SKILL.md +174 -0
- data/.claude/skills/ruby-asterisk-ari-websocket/SKILL.md +148 -0
- data/.github/workflows/ci.yml +79 -0
- data/.gitignore +48 -4
- data/.rubocop.yml +84 -0
- data/CHANGELOG.md +52 -0
- data/Gemfile +3 -1
- data/README.md +410 -108
- data/Rakefile +3 -5
- data/lib/ruby-asterisk/agi/protocol.rb +160 -0
- data/lib/ruby-asterisk/agi/server.rb +108 -0
- data/lib/ruby-asterisk/agi/session.rb +187 -0
- data/lib/ruby-asterisk/ami/client.rb +135 -0
- data/lib/ruby-asterisk/ami/commands/channel.rb +55 -0
- data/lib/ruby-asterisk/ami/commands/conference.rb +37 -0
- data/lib/ruby-asterisk/ami/commands/extension.rb +17 -0
- data/lib/ruby-asterisk/ami/commands/mailbox.rb +21 -0
- data/lib/ruby-asterisk/ami/commands/monitor.rb +33 -0
- data/lib/ruby-asterisk/ami/commands/queue.rb +39 -0
- data/lib/ruby-asterisk/ami/commands/sip.rb +25 -0
- data/lib/ruby-asterisk/ami/commands/system.rb +50 -0
- data/lib/ruby-asterisk/ami/event.rb +22 -0
- data/lib/ruby-asterisk/ami/event_list_aggregation.rb +82 -0
- data/lib/ruby-asterisk/ami/parser.rb +60 -0
- data/lib/ruby-asterisk/ami/promise.rb +108 -0
- data/lib/ruby-asterisk/ami/reactor.rb +162 -0
- data/lib/ruby-asterisk/ari/client.rb +94 -0
- data/lib/ruby-asterisk/ari/resources/base.rb +23 -0
- data/lib/ruby-asterisk/ari/resources/bridge.rb +22 -0
- data/lib/ruby-asterisk/ari/resources/channel.rb +26 -0
- data/lib/ruby-asterisk/ari/resources/collection.rb +27 -0
- data/lib/ruby-asterisk/ari/resources/endpoint.rb +22 -0
- data/lib/ruby-asterisk/ari/resources/playback.rb +18 -0
- data/lib/ruby-asterisk/ari/websocket/connection.rb +143 -0
- data/lib/ruby-asterisk/ari/websocket/event_handlers.rb +80 -0
- data/lib/ruby-asterisk/ari/websocket/heartbeat.rb +65 -0
- data/lib/ruby-asterisk/ari/websocket/reconnect.rb +54 -0
- data/lib/ruby-asterisk/ari/websocket/socket_adapter.rb +23 -0
- data/lib/ruby-asterisk/ari/websocket.rb +155 -0
- data/lib/ruby-asterisk/compat.rb +7 -0
- data/lib/ruby-asterisk/error.rb +10 -0
- data/lib/ruby-asterisk/parsing_constants.rb +71 -69
- data/lib/ruby-asterisk/request.rb +33 -14
- data/lib/ruby-asterisk/response.rb +43 -16
- data/lib/ruby-asterisk/response_builder.rb +18 -0
- data/lib/ruby-asterisk/response_parser.rb +10 -9
- data/lib/ruby-asterisk/version.rb +4 -2
- data/lib/ruby-asterisk.rb +5 -222
- data/ruby-asterisk.gemspec +23 -17
- data/spec/ruby-asterisk/agi/protocol_spec.rb +239 -0
- data/spec/ruby-asterisk/agi/server_spec.rb +199 -0
- data/spec/ruby-asterisk/agi/session_spec.rb +293 -0
- data/spec/ruby-asterisk/ami/async_client_spec.rb +256 -0
- data/spec/ruby-asterisk/ami/multi_event_spec.rb +57 -0
- data/spec/ruby-asterisk/ami/parser_spec.rb +190 -0
- data/spec/ruby-asterisk/ami/reactor_spec.rb +290 -0
- data/spec/ruby-asterisk/ami_client_spec.rb +68 -0
- data/spec/ruby-asterisk/ari/client_spec.rb +168 -0
- data/spec/ruby-asterisk/ari/resources/bridge_spec.rb +42 -0
- data/spec/ruby-asterisk/ari/resources/channel_spec.rb +57 -0
- data/spec/ruby-asterisk/ari/resources/collection_spec.rb +66 -0
- data/spec/ruby-asterisk/ari/resources/endpoint_spec.rb +30 -0
- data/spec/ruby-asterisk/ari/resources/playback_spec.rb +33 -0
- data/spec/ruby-asterisk/ari/websocket_integration_spec.rb +86 -0
- data/spec/ruby-asterisk/ari/websocket_spec.rb +374 -0
- data/spec/ruby-asterisk/immutability_spec.rb +148 -0
- data/spec/ruby-asterisk/request_spec.rb +29 -9
- data/spec/ruby-asterisk/response_spec.rb +46 -47
- data/spec/spec_helper.rb +12 -0
- data/spec/support/mock_ami_server.rb +50 -0
- data/spec/support/mock_ari_websocket_server.rb +114 -0
- metadata +138 -18
- data/CHANGELOG +0 -3
- data/spec/ruby-asterisk/ruby_asterisk_spec.rb +0 -192
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require 'spec_helper'
|
|
3
|
-
describe RubyAsterisk do
|
|
4
|
-
|
|
5
|
-
def mock_request(stubs={})
|
|
6
|
-
(@mock_request ||= mock_model(RubyAsterisk::Request).as_null_object).tap do |request|
|
|
7
|
-
request.stub(stubs) unless stubs.empty?
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
before :each do
|
|
12
|
-
@session = RubyAsterisk::AMI.new("127.0.0.1",5038)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
after :each do
|
|
16
|
-
@session.disconnect
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
describe ".new" do
|
|
20
|
-
it "initialize session with host" do
|
|
21
|
-
@session.host.should eq("127.0.0.1")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "initialize session with host" do
|
|
25
|
-
@session.port.should eq(5038)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "should start the session as disconnected" do
|
|
29
|
-
@session.connected.should_not be_true
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
describe ".connect" do
|
|
34
|
-
it "should return true if everything is ok" do
|
|
35
|
-
@session.connect.should be_true
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "should return false if everything if something went wrong" do
|
|
39
|
-
@session.port = 666
|
|
40
|
-
@session.connect.should_not be_true
|
|
41
|
-
@session.port = 5038
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "should change state to session as connected" do
|
|
45
|
-
@session.connect
|
|
46
|
-
@session.connected.should be_true
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
describe ".disconnect" do
|
|
51
|
-
it "should return true if everything is ok" do
|
|
52
|
-
@session.disconnect.should be_true
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "should change state to session as disconnected" do
|
|
56
|
-
@session.disconnect
|
|
57
|
-
@session.connected.should_not be_true
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe ".login" do
|
|
62
|
-
it "should return a response object" do
|
|
63
|
-
@session.login("mark","mysecret").should be_kind_of(RubyAsterisk::Response)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it "should return a response with type Login" do
|
|
67
|
-
@session.login("mark","mysecret").type.should eq("Login")
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
describe "if everything is ok" do
|
|
71
|
-
it "should return a successfull response" do
|
|
72
|
-
@session.login("mark","mysecret").success.should be_true
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it "should fill the ActionID" do
|
|
76
|
-
@session.login("mark","mysecret").action_id.should_not be_nil
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
it "should fill the Message" do
|
|
80
|
-
@session.login("mark","mysecret").message.should_not be_nil
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
describe "if credentials are wrong" do
|
|
85
|
-
it "should not return a successfull response" do
|
|
86
|
-
@session.login("mark","wrong").success.should be_false
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
describe ".core_show_channels" do
|
|
92
|
-
it "should return a response object" do
|
|
93
|
-
@session.login("mark","mysecret")
|
|
94
|
-
@session.core_show_channels.should be_kind_of(RubyAsterisk::Response)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it "should contain additional data about channels" do
|
|
98
|
-
@session.login("mark","mysecret")
|
|
99
|
-
@session.core_show_channels.data[:channels].should_not be_nil
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
describe ".parked_calls" do
|
|
104
|
-
it "should return a response object" do
|
|
105
|
-
@session.login("mark","mysecret")
|
|
106
|
-
@session.parked_calls.should be_kind_of(RubyAsterisk::Response)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
it "should contain additional data about parked calls" do
|
|
110
|
-
@session.login("mark","mysecret")
|
|
111
|
-
@session.parked_calls.data[:calls].should_not be_nil
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
describe ".originate" do
|
|
116
|
-
it "should return a response object" do
|
|
117
|
-
@session.login("mark","mysecret")
|
|
118
|
-
@session.originate("SIP/9100","OUTGOING","123456","1","queue=SIP/1000&SIP/1001").should be_kind_of(RubyAsterisk::Response)
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
describe ".command" do
|
|
123
|
-
it "should return a response object" do
|
|
124
|
-
@session.login("mark","mysecret")
|
|
125
|
-
@session.command("meetme list").should be_kind_of(RubyAsterisk::Response)
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
describe ".meet_me_list" do
|
|
130
|
-
it "should return a response object" do
|
|
131
|
-
@session.login("mark","mysecret")
|
|
132
|
-
@session.meet_me_list.should be_kind_of(RubyAsterisk::Response)
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
describe ".extension_state" do
|
|
137
|
-
it "should return a response object" do
|
|
138
|
-
@session.login("mark","mysecret")
|
|
139
|
-
@session.extension_state("9100","HINT").should be_kind_of(RubyAsterisk::Response)
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
describe ".sip_peers" do
|
|
144
|
-
it "should return a response object" do
|
|
145
|
-
@session.login("mark","mysecret")
|
|
146
|
-
@session.sip_peers.should be_kind_of(RubyAsterisk::Response)
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
describe ".wait_event" do
|
|
151
|
-
it "should return a response object" do
|
|
152
|
-
@session.login("mark","mysecret")
|
|
153
|
-
@session.wait_event(1).should be_kind_of(RubyAsterisk::Response)
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
describe ".monitor" do
|
|
158
|
-
it "should return a response object" do
|
|
159
|
-
@session.login("mark","mysecret")
|
|
160
|
-
@session.monitor("SIP/9100").should be_kind_of(RubyAsterisk::Response)
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
describe ".stop_monitor" do
|
|
165
|
-
it "should return a response object" do
|
|
166
|
-
@session.login("mark","mysecret")
|
|
167
|
-
@session.stop_monitor("SIP/9100").should be_kind_of(RubyAsterisk::Response)
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
describe ".pause_monitor" do
|
|
172
|
-
it "should return a response object" do
|
|
173
|
-
@session.login("mark","mysecret")
|
|
174
|
-
@session.pause_monitor("SIP/9100").should be_kind_of(RubyAsterisk::Response)
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
describe ".unpause_monitor" do
|
|
179
|
-
it "should return a response object" do
|
|
180
|
-
@session.login("mark","mysecret")
|
|
181
|
-
@session.unpause_monitor("SIP/9100").should be_kind_of(RubyAsterisk::Response)
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
describe ".change_monitor" do
|
|
186
|
-
it "should return a response object" do
|
|
187
|
-
@session.login("mark","mysecret")
|
|
188
|
-
@session.change_monitor("SIP/9100","first-sip-9100").should be_kind_of(RubyAsterisk::Response)
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
end
|