ruby-asterisk 0.1.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.
Files changed (78) hide show
  1. checksums.yaml +5 -5
  2. data/.claude/skills/ruby-asterisk-agi/SKILL.md +317 -0
  3. data/.claude/skills/ruby-asterisk-ami/SKILL.md +187 -0
  4. data/.claude/skills/ruby-asterisk-ari/SKILL.md +174 -0
  5. data/.claude/skills/ruby-asterisk-ari-websocket/SKILL.md +148 -0
  6. data/.github/workflows/ci.yml +79 -0
  7. data/.gitignore +50 -3
  8. data/.rubocop.yml +84 -0
  9. data/CHANGELOG.md +52 -0
  10. data/Gemfile +3 -1
  11. data/LICENCE +21 -0
  12. data/README.md +454 -70
  13. data/Rakefile +3 -1
  14. data/lib/ruby-asterisk/agi/protocol.rb +160 -0
  15. data/lib/ruby-asterisk/agi/server.rb +108 -0
  16. data/lib/ruby-asterisk/agi/session.rb +187 -0
  17. data/lib/ruby-asterisk/ami/client.rb +135 -0
  18. data/lib/ruby-asterisk/ami/commands/channel.rb +55 -0
  19. data/lib/ruby-asterisk/ami/commands/conference.rb +37 -0
  20. data/lib/ruby-asterisk/ami/commands/extension.rb +17 -0
  21. data/lib/ruby-asterisk/ami/commands/mailbox.rb +21 -0
  22. data/lib/ruby-asterisk/ami/commands/monitor.rb +33 -0
  23. data/lib/ruby-asterisk/ami/commands/queue.rb +39 -0
  24. data/lib/ruby-asterisk/ami/commands/sip.rb +25 -0
  25. data/lib/ruby-asterisk/ami/commands/system.rb +50 -0
  26. data/lib/ruby-asterisk/ami/event.rb +22 -0
  27. data/lib/ruby-asterisk/ami/event_list_aggregation.rb +82 -0
  28. data/lib/ruby-asterisk/ami/parser.rb +60 -0
  29. data/lib/ruby-asterisk/ami/promise.rb +108 -0
  30. data/lib/ruby-asterisk/ami/reactor.rb +162 -0
  31. data/lib/ruby-asterisk/ari/client.rb +94 -0
  32. data/lib/ruby-asterisk/ari/resources/base.rb +23 -0
  33. data/lib/ruby-asterisk/ari/resources/bridge.rb +22 -0
  34. data/lib/ruby-asterisk/ari/resources/channel.rb +26 -0
  35. data/lib/ruby-asterisk/ari/resources/collection.rb +27 -0
  36. data/lib/ruby-asterisk/ari/resources/endpoint.rb +22 -0
  37. data/lib/ruby-asterisk/ari/resources/playback.rb +18 -0
  38. data/lib/ruby-asterisk/ari/websocket/connection.rb +143 -0
  39. data/lib/ruby-asterisk/ari/websocket/event_handlers.rb +80 -0
  40. data/lib/ruby-asterisk/ari/websocket/heartbeat.rb +65 -0
  41. data/lib/ruby-asterisk/ari/websocket/reconnect.rb +54 -0
  42. data/lib/ruby-asterisk/ari/websocket/socket_adapter.rb +23 -0
  43. data/lib/ruby-asterisk/ari/websocket.rb +155 -0
  44. data/lib/ruby-asterisk/compat.rb +7 -0
  45. data/lib/ruby-asterisk/error.rb +10 -0
  46. data/lib/ruby-asterisk/parsing_constants.rb +100 -0
  47. data/lib/ruby-asterisk/request.rb +38 -20
  48. data/lib/ruby-asterisk/response.rb +50 -137
  49. data/lib/ruby-asterisk/response_builder.rb +18 -0
  50. data/lib/ruby-asterisk/response_parser.rb +43 -0
  51. data/lib/ruby-asterisk/version.rb +4 -2
  52. data/lib/ruby-asterisk.rb +5 -147
  53. data/ruby-asterisk.gemspec +26 -17
  54. data/spec/ruby-asterisk/agi/protocol_spec.rb +239 -0
  55. data/spec/ruby-asterisk/agi/server_spec.rb +199 -0
  56. data/spec/ruby-asterisk/agi/session_spec.rb +293 -0
  57. data/spec/ruby-asterisk/ami/async_client_spec.rb +256 -0
  58. data/spec/ruby-asterisk/ami/multi_event_spec.rb +57 -0
  59. data/spec/ruby-asterisk/ami/parser_spec.rb +190 -0
  60. data/spec/ruby-asterisk/ami/reactor_spec.rb +290 -0
  61. data/spec/ruby-asterisk/ami_client_spec.rb +68 -0
  62. data/spec/ruby-asterisk/ari/client_spec.rb +168 -0
  63. data/spec/ruby-asterisk/ari/resources/bridge_spec.rb +42 -0
  64. data/spec/ruby-asterisk/ari/resources/channel_spec.rb +57 -0
  65. data/spec/ruby-asterisk/ari/resources/collection_spec.rb +66 -0
  66. data/spec/ruby-asterisk/ari/resources/endpoint_spec.rb +30 -0
  67. data/spec/ruby-asterisk/ari/resources/playback_spec.rb +33 -0
  68. data/spec/ruby-asterisk/ari/websocket_integration_spec.rb +86 -0
  69. data/spec/ruby-asterisk/ari/websocket_spec.rb +374 -0
  70. data/spec/ruby-asterisk/immutability_spec.rb +148 -0
  71. data/spec/ruby-asterisk/request_spec.rb +29 -9
  72. data/spec/ruby-asterisk/response_spec.rb +147 -148
  73. data/spec/spec_helper.rb +14 -0
  74. data/spec/support/mock_ami_server.rb +50 -0
  75. data/spec/support/mock_ari_websocket_server.rb +114 -0
  76. metadata +177 -21
  77. data/CHANGELOG +0 -3
  78. data/spec/ruby-asterisk/ruby_asterisk_spec.rb +0 -150
metadata CHANGED
@@ -1,87 +1,243 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-asterisk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emiliano Della Casa
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2013-11-07 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: async
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '2.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '2.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: faraday
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '1.0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: logger
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: websocket-driver
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0.8'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.8'
13
68
  - !ruby/object:Gem::Dependency
14
69
  name: rake
15
70
  requirement: !ruby/object:Gem::Requirement
16
71
  requirements:
17
- - - '>='
72
+ - - ">="
18
73
  - !ruby/object:Gem::Version
19
74
  version: '0'
20
75
  type: :development
21
76
  prerelease: false
22
77
  version_requirements: !ruby/object:Gem::Requirement
23
78
  requirements:
24
- - - '>='
79
+ - - ">="
25
80
  - !ruby/object:Gem::Version
26
81
  version: '0'
27
82
  - !ruby/object:Gem::Dependency
28
83
  name: rspec
29
84
  requirement: !ruby/object:Gem::Requirement
30
85
  requirements:
31
- - - '>='
86
+ - - ">="
32
87
  - !ruby/object:Gem::Version
33
88
  version: '0'
34
89
  type: :development
35
90
  prerelease: false
36
91
  version_requirements: !ruby/object:Gem::Requirement
37
92
  requirements:
38
- - - '>='
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rubocop
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rubocop-performance
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ - !ruby/object:Gem::Dependency
125
+ name: simplecov
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
39
136
  - !ruby/object:Gem::Version
40
137
  version: '0'
41
138
  description: Add support to your ruby or rails projects to Asterisk Manager Interface
42
139
  (AMI)
43
140
  email:
44
- - e.dellacasa@engim.eu
141
+ - emiliano.dellacasa@gmail.com
45
142
  executables: []
46
143
  extensions: []
47
144
  extra_rdoc_files: []
48
145
  files:
49
- - .gitignore
50
- - .rspec
51
- - CHANGELOG
146
+ - ".claude/skills/ruby-asterisk-agi/SKILL.md"
147
+ - ".claude/skills/ruby-asterisk-ami/SKILL.md"
148
+ - ".claude/skills/ruby-asterisk-ari-websocket/SKILL.md"
149
+ - ".claude/skills/ruby-asterisk-ari/SKILL.md"
150
+ - ".github/workflows/ci.yml"
151
+ - ".gitignore"
152
+ - ".rspec"
153
+ - ".rubocop.yml"
154
+ - CHANGELOG.md
52
155
  - Gemfile
156
+ - LICENCE
53
157
  - README.md
54
158
  - Rakefile
55
159
  - lib/ruby-asterisk.rb
160
+ - lib/ruby-asterisk/agi/protocol.rb
161
+ - lib/ruby-asterisk/agi/server.rb
162
+ - lib/ruby-asterisk/agi/session.rb
163
+ - lib/ruby-asterisk/ami/client.rb
164
+ - lib/ruby-asterisk/ami/commands/channel.rb
165
+ - lib/ruby-asterisk/ami/commands/conference.rb
166
+ - lib/ruby-asterisk/ami/commands/extension.rb
167
+ - lib/ruby-asterisk/ami/commands/mailbox.rb
168
+ - lib/ruby-asterisk/ami/commands/monitor.rb
169
+ - lib/ruby-asterisk/ami/commands/queue.rb
170
+ - lib/ruby-asterisk/ami/commands/sip.rb
171
+ - lib/ruby-asterisk/ami/commands/system.rb
172
+ - lib/ruby-asterisk/ami/event.rb
173
+ - lib/ruby-asterisk/ami/event_list_aggregation.rb
174
+ - lib/ruby-asterisk/ami/parser.rb
175
+ - lib/ruby-asterisk/ami/promise.rb
176
+ - lib/ruby-asterisk/ami/reactor.rb
177
+ - lib/ruby-asterisk/ari/client.rb
178
+ - lib/ruby-asterisk/ari/resources/base.rb
179
+ - lib/ruby-asterisk/ari/resources/bridge.rb
180
+ - lib/ruby-asterisk/ari/resources/channel.rb
181
+ - lib/ruby-asterisk/ari/resources/collection.rb
182
+ - lib/ruby-asterisk/ari/resources/endpoint.rb
183
+ - lib/ruby-asterisk/ari/resources/playback.rb
184
+ - lib/ruby-asterisk/ari/websocket.rb
185
+ - lib/ruby-asterisk/ari/websocket/connection.rb
186
+ - lib/ruby-asterisk/ari/websocket/event_handlers.rb
187
+ - lib/ruby-asterisk/ari/websocket/heartbeat.rb
188
+ - lib/ruby-asterisk/ari/websocket/reconnect.rb
189
+ - lib/ruby-asterisk/ari/websocket/socket_adapter.rb
190
+ - lib/ruby-asterisk/compat.rb
191
+ - lib/ruby-asterisk/error.rb
192
+ - lib/ruby-asterisk/parsing_constants.rb
56
193
  - lib/ruby-asterisk/request.rb
57
194
  - lib/ruby-asterisk/response.rb
195
+ - lib/ruby-asterisk/response_builder.rb
196
+ - lib/ruby-asterisk/response_parser.rb
58
197
  - lib/ruby-asterisk/version.rb
59
198
  - ruby-asterisk.gemspec
199
+ - spec/ruby-asterisk/agi/protocol_spec.rb
200
+ - spec/ruby-asterisk/agi/server_spec.rb
201
+ - spec/ruby-asterisk/agi/session_spec.rb
202
+ - spec/ruby-asterisk/ami/async_client_spec.rb
203
+ - spec/ruby-asterisk/ami/multi_event_spec.rb
204
+ - spec/ruby-asterisk/ami/parser_spec.rb
205
+ - spec/ruby-asterisk/ami/reactor_spec.rb
206
+ - spec/ruby-asterisk/ami_client_spec.rb
207
+ - spec/ruby-asterisk/ari/client_spec.rb
208
+ - spec/ruby-asterisk/ari/resources/bridge_spec.rb
209
+ - spec/ruby-asterisk/ari/resources/channel_spec.rb
210
+ - spec/ruby-asterisk/ari/resources/collection_spec.rb
211
+ - spec/ruby-asterisk/ari/resources/endpoint_spec.rb
212
+ - spec/ruby-asterisk/ari/resources/playback_spec.rb
213
+ - spec/ruby-asterisk/ari/websocket_integration_spec.rb
214
+ - spec/ruby-asterisk/ari/websocket_spec.rb
215
+ - spec/ruby-asterisk/immutability_spec.rb
60
216
  - spec/ruby-asterisk/request_spec.rb
61
217
  - spec/ruby-asterisk/response_spec.rb
62
- - spec/ruby-asterisk/ruby_asterisk_spec.rb
63
218
  - spec/spec_helper.rb
219
+ - spec/support/mock_ami_server.rb
220
+ - spec/support/mock_ari_websocket_server.rb
64
221
  homepage: http://github.com/emilianodellacasa/ruby-asterisk
65
- licenses: []
66
- metadata: {}
67
- post_install_message:
222
+ licenses:
223
+ - MIT
224
+ metadata:
225
+ rubygems_mfa_required: 'true'
68
226
  rdoc_options: []
69
227
  require_paths:
70
228
  - lib
71
229
  required_ruby_version: !ruby/object:Gem::Requirement
72
230
  requirements:
73
- - - '>='
231
+ - - ">="
74
232
  - !ruby/object:Gem::Version
75
- version: '0'
233
+ version: '3.1'
76
234
  required_rubygems_version: !ruby/object:Gem::Requirement
77
235
  requirements:
78
- - - '>='
236
+ - - ">="
79
237
  - !ruby/object:Gem::Version
80
238
  version: '0'
81
239
  requirements: []
82
- rubyforge_project: ruby-asterisk
83
- rubygems_version: 2.0.3
84
- signing_key:
240
+ rubygems_version: 3.6.9
85
241
  specification_version: 4
86
242
  summary: Asterisk Manager Interface in Ruby
87
243
  test_files: []
data/CHANGELOG DELETED
@@ -1,3 +0,0 @@
1
- ## v0.0.1
2
-
3
- * Initial release
@@ -1,150 +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
- end