FreeSWITCHeR 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/License.txt +20 -0
- data/NEWS +3 -0
- data/README +85 -0
- data/Rakefile +82 -0
- data/bin/cmd_demo.rb +19 -0
- data/bin/ies_demo.rb +19 -0
- data/bin/ies_demo_with_hook.rb +27 -0
- data/bin/oes_demo.rb +22 -0
- data/lib/fsr.rb +86 -0
- data/lib/fsr/app.rb +72 -0
- data/lib/fsr/app/answer.rb +21 -0
- data/lib/fsr/app/bridge.rb +33 -0
- data/lib/fsr/app/conference.rb +29 -0
- data/lib/fsr/app/fifo.rb +38 -0
- data/lib/fsr/app/fs_break.rb +21 -0
- data/lib/fsr/app/fs_sleep.rb +24 -0
- data/lib/fsr/app/hangup.rb +22 -0
- data/lib/fsr/app/log.rb +24 -0
- data/lib/fsr/app/playback.rb +23 -0
- data/lib/fsr/app/set.rb +22 -0
- data/lib/fsr/app/speak.rb +25 -0
- data/lib/fsr/app/transfer.rb +24 -0
- data/lib/fsr/cmd.rb +57 -0
- data/lib/fsr/cmd/fsctl.rb +41 -0
- data/lib/fsr/cmd/originate.rb +46 -0
- data/lib/fsr/cmd/sofia.rb +40 -0
- data/lib/fsr/cmd/sofia/profile.rb +75 -0
- data/lib/fsr/cmd/sofia/status.rb +39 -0
- data/lib/fsr/cmd/sofia_contact.rb +31 -0
- data/lib/fsr/cmd/status.rb +25 -0
- data/lib/fsr/command_socket.rb +29 -0
- data/lib/fsr/database.rb +7 -0
- data/lib/fsr/database/call_limit.rb +21 -0
- data/lib/fsr/database/core.rb +30 -0
- data/lib/fsr/database/sofia_reg_external.rb +0 -0
- data/lib/fsr/database/sofia_reg_internal.rb +0 -0
- data/lib/fsr/database/voicemail_default.rb +0 -0
- data/lib/fsr/event_socket.rb +41 -0
- data/lib/fsr/fake_socket.rb +68 -0
- data/lib/fsr/listener.rb +10 -0
- data/lib/fsr/listener/header_and_content_response.rb +21 -0
- data/lib/fsr/listener/inbound.rb +61 -0
- data/lib/fsr/listener/inbound/event.rb +42 -0
- data/lib/fsr/listener/outbound.rb +62 -0
- data/spec/fsr/app.rb +8 -0
- data/spec/fsr/app/bridge.rb +17 -0
- data/spec/fsr/app/conference.rb +12 -0
- data/spec/fsr/app/fifo.rb +29 -0
- data/spec/fsr/cmd.rb +8 -0
- data/spec/fsr/cmd/originate.rb +12 -0
- data/spec/fsr/cmd/sofia.rb +69 -0
- data/spec/fsr/cmd/sofia/profile.rb +58 -0
- data/spec/fsr/listener.rb +12 -0
- data/spec/fsr/listener/inbound.rb +19 -0
- data/spec/fsr/listener/outbound.rb +19 -0
- data/spec/fsr/loading.rb +27 -0
- data/spec/helper.rb +14 -0
- data/tasks/package.rake +29 -0
- data/tasks/spec.rake +59 -0
- metadata +224 -0
data/spec/fsr/loading.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe "Testing FSR module loading methods" do
|
5
|
+
# When you add applications you must modify the expected apps_loaded behavior
|
6
|
+
it "Loads all applications" do
|
7
|
+
all_apps = [:set, :transfer, :speak, :fs_sleep, :playback, :answer, :fifo, :bridge, :hangup, :conference, :fs_break, :log]
|
8
|
+
# Add any apps which will load to this set
|
9
|
+
apps_loaded = FSR.load_all_applications
|
10
|
+
apps_loaded.kind_of?(Array).should == true
|
11
|
+
all_apps.each do |app|
|
12
|
+
apps_loaded.delete(app).should == app
|
13
|
+
end
|
14
|
+
apps_loaded.size.should == 0
|
15
|
+
end
|
16
|
+
|
17
|
+
# When you add commands you must modify the expected cmds_loaded behavior
|
18
|
+
it "Loads all commands" do
|
19
|
+
all_commands = [:originate, :sofia, :fsctl, :sofia_contact, :status] # If you add a command add it to this set
|
20
|
+
cmds_loaded = FSR.load_all_commands
|
21
|
+
cmds_loaded.kind_of?(Array).should == true
|
22
|
+
all_commands.each do |cmd|
|
23
|
+
cmds_loaded.delete(cmd).should == cmd
|
24
|
+
end
|
25
|
+
cmds_loaded.size.should == 0
|
26
|
+
end
|
27
|
+
end
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
begin
|
2
|
+
require 'bacon'
|
3
|
+
rescue LoadError
|
4
|
+
puts <<-EOS
|
5
|
+
To run these tests you must install bacon.
|
6
|
+
Quick and easy install for gem:
|
7
|
+
gem install bacon
|
8
|
+
EOS
|
9
|
+
exit(0)
|
10
|
+
end
|
11
|
+
|
12
|
+
Bacon.summary_on_exit
|
13
|
+
|
14
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/fsr'))
|
data/tasks/package.rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
require 'rake'
|
3
|
+
require "lib/fsr"
|
4
|
+
namespace :pkg do
|
5
|
+
desc 'Build the gemspec'
|
6
|
+
task :build_gemspec do
|
7
|
+
require "erb"
|
8
|
+
unfiltered_files = Dir['**/*']
|
9
|
+
spec_files = unfiltered_files.reject do |filename|
|
10
|
+
filename.match(/^(?:spec|config|script|log|contrib)(?:\/|$)/) || File.basename(filename).match(/\.(?:gem|gemspec|swp|gemspec\.erb)$/) || File.basename(filename).match(/^(?:\.|RIDE)/)
|
11
|
+
end.inspect
|
12
|
+
|
13
|
+
spec_test_files = (["spec"] + Dir['spec/**/*']).inspect
|
14
|
+
spec_template = ERB.new(File.read("freeswitcher.gemspec.erb"))
|
15
|
+
version = FSR::VERSION
|
16
|
+
description = File.read("README")
|
17
|
+
File.open("freeswitcher.gemspec", "w+") { |specfile| specfile.puts spec_template.result(binding) }
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Make the gem'
|
22
|
+
task :gem => :build_gemspec do
|
23
|
+
output = %x{gem build freeswitcher.gemspec}
|
24
|
+
raise "Package did not build - #{output}" unless File.exists?("FreeSWITCHeR-#{FSR::VERSION}.gem")
|
25
|
+
puts output
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
data/tasks/spec.rake
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
desc 'Run all specs'
|
7
|
+
task :spec => :setup do
|
8
|
+
require 'open3'
|
9
|
+
|
10
|
+
specs = Dir['spec/fsr/**/*.rb']
|
11
|
+
# specs.delete_if{|f| f =~ /cache\/common\.rb/ }
|
12
|
+
|
13
|
+
some_failed = false
|
14
|
+
total = specs.size
|
15
|
+
len = specs.sort.last.size
|
16
|
+
left_format = "%4d/%d: %-#{len + 12}s"
|
17
|
+
red, green = "\e[31m%s\e[0m", "\e[32m%s\e[0m"
|
18
|
+
matcher = /(\d+) specifications \((\d+) requirements\), (\d+) failures, (\d+) errors/
|
19
|
+
tt = ta = tf = te = 0
|
20
|
+
|
21
|
+
specs.each_with_index do |spec, idx|
|
22
|
+
print(left_format % [idx + 1, total, spec])
|
23
|
+
unless RUBY_PLATFORM.include?("mswin32")
|
24
|
+
Open3.popen3("#{RUBY} -rubygems #{spec}") do |sin, sout, serr|
|
25
|
+
out = sout.read
|
26
|
+
err = serr.read
|
27
|
+
|
28
|
+
all = out.match(matcher).captures.map{|c| c.to_i }
|
29
|
+
tests, assertions, failures, errors = all
|
30
|
+
tt += tests; ta += assertions; tf += failures; te += errors
|
31
|
+
|
32
|
+
if tests == 0 || failures + errors > 0
|
33
|
+
some_failed = true
|
34
|
+
puts((red % "%5d tests, %d assertions, %d failures, %d errors") % all)
|
35
|
+
puts "", out, err, ""
|
36
|
+
else
|
37
|
+
puts((green % "%5d passed") % tests)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
else
|
41
|
+
out = %x{#{RUBY} -rubygems #{spec}}
|
42
|
+
error = ""
|
43
|
+
all = out.match(matcher).captures.map{|c| c.to_i }
|
44
|
+
tests, assertions, failures, errors = all
|
45
|
+
tt += tests; ta += assertions; tf += failures; te += errors
|
46
|
+
|
47
|
+
if tests == 0 || failures + errors > 0
|
48
|
+
some_failed = true
|
49
|
+
puts((red % "%5d tests, %d assertions, %d failures, %d errors") % all)
|
50
|
+
puts "", out, err, ""
|
51
|
+
else
|
52
|
+
puts((green % "%5d passed") % tests)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
puts "#{tt} specifications, (#{ta} requirements), #{tf} failures, #{te} errors"
|
58
|
+
exit 1 if some_failed
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: FreeSWITCHeR
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.8
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jayson Vaughn
|
8
|
+
- Michael Fellinger
|
9
|
+
- Kevin Berry
|
10
|
+
- TJ Vanderpoel
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
|
15
|
+
date: 2009-04-09 00:00:00 -05:00
|
16
|
+
default_executable:
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: eventmachine
|
20
|
+
type: :runtime
|
21
|
+
version_requirement:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: "0"
|
27
|
+
version:
|
28
|
+
description: "========================================================= FreeSWITCHeR Copyright (c) 2009 The Rubyists (Jayson Vaughn, Tj Vanderpoel, Michael Fellinger, Kevin Berry) Distributed under the terms of the MIT License. ========================================================== About ----- *** STILL UNDER HEAVY DEVELOPMENT *** A ruby library for interacting with the \"FreeSWITCH\" (http://www.freeswitch.org) opensource telephony platform *** STILL UNDER HEAVY DEVELOPMENT *** Requirements ------------ - ruby (>= 1.8) - eventmachine (If you wish to use Outbound and Inbound listener) Usage ----- Example of originating a new call in 'irb' using FSR::CommandSocket#originate: irb(main):001:0> require 'fsr' => true irb(main):002:0> FSR.load_all_commands => [:sofia, :originate] irb(main):003:0> sock = FSR::CommandSocket.new => #<FSR::CommandSocket:0xb7a89104 @server=\"127.0.0.1\", @socket=#<TCPSocket:0xb7a8908c>, @port=\"8021\", @auth=\"ClueCon\"> irb(main):007:0> sock.originate(:target => 'sofia/gateway/carlos/8179395222', :endpoint => FSR::App::Bridge.new(\"user/bougyman\")).run => {\"Job-UUID\"=>\"732075a4-7dd5-4258-b124-6284a82a5ae7\", \"body\"=>\"\", \"Content-Type\"=>\"command/reply\", \"Reply-Text\"=>\"+OK Job-UUID: 732075a4-7dd5-4258-b124-6284a82a5ae7\"} Example of creating an Outbound Eventsocket listener: #!/usr/bin/env ruby require 'fsr' require \"fsr/listener/outbound\" class OesDemo < FSR::Listener::Outbound def session_initiated(session) number = session.headers[:caller_caller_id_number] # Grab the inbound caller id FSR::Log.info \"*** Answering incoming call from #{number}\" answer # Answer the call set \"hangup_after_bridge=true\" # Set a variable speak 'Hello, This is your phone switch. Have a great day' # use mod_flite to speak hangup # Hangup the call end end FSR.start_oes!(OesDemo, :port => 1888, :host => \"localhost\") Example of creating an Inbound Eventsocket listener: #!/usr/bin/env ruby require 'fsr' require \"fsr/listener/inbound\" class IesDemo < FSR::Listener::Inbound def on_event(event) pp event.headers pp event.content[:event_name] end end FSR.start_ies!(IesDemo, :host => \"localhost\", :port => 8021) Support ------- Home page at http://code.rubyists.com/projects/fs #rubyists on FreeNode"
|
29
|
+
email: FreeSWITCHeR@rubyists.com
|
30
|
+
executables: []
|
31
|
+
|
32
|
+
extensions: []
|
33
|
+
|
34
|
+
extra_rdoc_files: []
|
35
|
+
|
36
|
+
files:
|
37
|
+
- License.txt
|
38
|
+
- NEWS
|
39
|
+
- README
|
40
|
+
- Rakefile
|
41
|
+
- bin
|
42
|
+
- bin/cmd_demo.rb
|
43
|
+
- bin/ies_demo.rb
|
44
|
+
- bin/ies_demo_with_hook.rb
|
45
|
+
- bin/oes_demo.rb
|
46
|
+
- lib
|
47
|
+
- lib/fsr
|
48
|
+
- lib/fsr/app
|
49
|
+
- lib/fsr/app/answer.rb
|
50
|
+
- lib/fsr/app/bridge.rb
|
51
|
+
- lib/fsr/app/conference.rb
|
52
|
+
- lib/fsr/app/fifo.rb
|
53
|
+
- lib/fsr/app/fs_break.rb
|
54
|
+
- lib/fsr/app/fs_sleep.rb
|
55
|
+
- lib/fsr/app/hangup.rb
|
56
|
+
- lib/fsr/app/log.rb
|
57
|
+
- lib/fsr/app/playback.rb
|
58
|
+
- lib/fsr/app/set.rb
|
59
|
+
- lib/fsr/app/speak.rb
|
60
|
+
- lib/fsr/app/transfer.rb
|
61
|
+
- lib/fsr/app.rb
|
62
|
+
- lib/fsr/cmd
|
63
|
+
- lib/fsr/cmd/fsctl.rb
|
64
|
+
- lib/fsr/cmd/originate.rb
|
65
|
+
- lib/fsr/cmd/sofia
|
66
|
+
- lib/fsr/cmd/sofia/profile.rb
|
67
|
+
- lib/fsr/cmd/sofia/status.rb
|
68
|
+
- lib/fsr/cmd/sofia.rb
|
69
|
+
- lib/fsr/cmd/sofia_contact.rb
|
70
|
+
- lib/fsr/cmd/status.rb
|
71
|
+
- lib/fsr/cmd.rb
|
72
|
+
- lib/fsr/command_socket.rb
|
73
|
+
- lib/fsr/database
|
74
|
+
- lib/fsr/database/call_limit.rb
|
75
|
+
- lib/fsr/database/core.rb
|
76
|
+
- lib/fsr/database/sofia_reg_external.rb
|
77
|
+
- lib/fsr/database/sofia_reg_internal.rb
|
78
|
+
- lib/fsr/database/voicemail_default.rb
|
79
|
+
- lib/fsr/database.rb
|
80
|
+
- lib/fsr/event_socket.rb
|
81
|
+
- lib/fsr/fake_socket.rb
|
82
|
+
- lib/fsr/listener
|
83
|
+
- lib/fsr/listener/header_and_content_response.rb
|
84
|
+
- lib/fsr/listener/inbound
|
85
|
+
- lib/fsr/listener/inbound/event.rb
|
86
|
+
- lib/fsr/listener/inbound.rb
|
87
|
+
- lib/fsr/listener/outbound.rb
|
88
|
+
- lib/fsr/listener.rb
|
89
|
+
- lib/fsr.rb
|
90
|
+
- tasks
|
91
|
+
- tasks/package.rake
|
92
|
+
- tasks/spec.rake
|
93
|
+
has_rdoc: false
|
94
|
+
homepage: http://code.rubyists.com/projects/fs
|
95
|
+
post_install_message: |
|
96
|
+
=========================================================
|
97
|
+
FreeSWITCHeR
|
98
|
+
Copyright (c) 2009 The Rubyists (Jayson Vaughn, Tj Vanderpoel, Michael Fellinger, Kevin Berry)
|
99
|
+
Distributed under the terms of the MIT License.
|
100
|
+
==========================================================
|
101
|
+
|
102
|
+
About
|
103
|
+
-----
|
104
|
+
*** STILL UNDER HEAVY DEVELOPMENT ***
|
105
|
+
|
106
|
+
A ruby library for interacting with the "FreeSWITCH" (http://www.freeswitch.org) opensource telephony platform
|
107
|
+
|
108
|
+
*** STILL UNDER HEAVY DEVELOPMENT ***
|
109
|
+
|
110
|
+
Requirements
|
111
|
+
------------
|
112
|
+
- ruby (>= 1.8)
|
113
|
+
- eventmachine (If you wish to use Outbound and Inbound listener)
|
114
|
+
|
115
|
+
Usage
|
116
|
+
-----
|
117
|
+
|
118
|
+
Example of originating a new call in 'irb' using FSR::CommandSocket#originate:
|
119
|
+
|
120
|
+
irb(main):001:0> require 'fsr'
|
121
|
+
=> true
|
122
|
+
|
123
|
+
irb(main):002:0> FSR.load_all_commands
|
124
|
+
=> [:sofia, :originate]
|
125
|
+
|
126
|
+
irb(main):003:0> sock = FSR::CommandSocket.new
|
127
|
+
=> #<FSR::CommandSocket:0xb7a89104 @server="127.0.0.1", @socket=#<TCPSocket:0xb7a8908c>, @port="8021", @auth="ClueCon">
|
128
|
+
|
129
|
+
irb(main):007:0> sock.originate(:target => 'sofia/gateway/carlos/8179395222', :endpoint => FSR::App::Bridge.new("user/bougyman")).run
|
130
|
+
=> {"Job-UUID"=>"732075a4-7dd5-4258-b124-6284a82a5ae7", "body"=>"", "Content-Type"=>"command/reply", "Reply-Text"=>"+OK Job-UUID: 732075a4-7dd5-4258-b124-6284a82a5ae7"}
|
131
|
+
|
132
|
+
|
133
|
+
Example of creating an Outbound Eventsocket listener:
|
134
|
+
|
135
|
+
#!/usr/bin/env ruby
|
136
|
+
|
137
|
+
require 'fsr'
|
138
|
+
require "fsr/listener/outbound"
|
139
|
+
|
140
|
+
class OesDemo < FSR::Listener::Outbound
|
141
|
+
|
142
|
+
def session_initiated(session)
|
143
|
+
number = session.headers[:caller_caller_id_number] # Grab the inbound caller id
|
144
|
+
FSR::Log.info "*** Answering incoming call from #{number}"
|
145
|
+
answer # Answer the call
|
146
|
+
set "hangup_after_bridge=true" # Set a variable
|
147
|
+
speak 'Hello, This is your phone switch. Have a great day' # use mod_flite to speak
|
148
|
+
hangup # Hangup the call
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
FSR.start_oes!(OesDemo, :port => 1888, :host => "localhost")
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
Example of creating an Inbound Eventsocket listener:
|
158
|
+
|
159
|
+
#!/usr/bin/env ruby
|
160
|
+
|
161
|
+
require 'fsr'
|
162
|
+
require "fsr/listener/inbound"
|
163
|
+
|
164
|
+
class IesDemo < FSR::Listener::Inbound
|
165
|
+
|
166
|
+
def on_event(event)
|
167
|
+
pp event.headers
|
168
|
+
pp event.content[:event_name]
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
FSR.start_ies!(IesDemo, :host => "localhost", :port => 8021)
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
Support
|
178
|
+
-------
|
179
|
+
Home page at http://code.rubyists.com/projects/fs
|
180
|
+
#rubyists on FreeNode
|
181
|
+
|
182
|
+
rdoc_options: []
|
183
|
+
|
184
|
+
require_paths:
|
185
|
+
- lib
|
186
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: "0"
|
191
|
+
version:
|
192
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - ">="
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: "0"
|
197
|
+
version:
|
198
|
+
requirements: []
|
199
|
+
|
200
|
+
rubyforge_project:
|
201
|
+
rubygems_version: 1.3.1
|
202
|
+
signing_key:
|
203
|
+
specification_version: 2
|
204
|
+
summary: A library for interacting with the "FreeSWITCH":http://freeswitch.org telephony platform
|
205
|
+
test_files:
|
206
|
+
- spec
|
207
|
+
- spec/fsr
|
208
|
+
- spec/fsr/app
|
209
|
+
- spec/fsr/app/bridge.rb
|
210
|
+
- spec/fsr/app/conference.rb
|
211
|
+
- spec/fsr/app/fifo.rb
|
212
|
+
- spec/fsr/app.rb
|
213
|
+
- spec/fsr/cmd
|
214
|
+
- spec/fsr/cmd/originate.rb
|
215
|
+
- spec/fsr/cmd/sofia
|
216
|
+
- spec/fsr/cmd/sofia/profile.rb
|
217
|
+
- spec/fsr/cmd/sofia.rb
|
218
|
+
- spec/fsr/cmd.rb
|
219
|
+
- spec/fsr/listener
|
220
|
+
- spec/fsr/listener/inbound.rb
|
221
|
+
- spec/fsr/listener/outbound.rb
|
222
|
+
- spec/fsr/listener.rb
|
223
|
+
- spec/fsr/loading.rb
|
224
|
+
- spec/helper.rb
|