bougyman-freeswitcher 0.4.1 → 0.4.2

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.
@@ -0,0 +1,22 @@
1
+ require File.join(File.expand_path("../", __FILE__), "../lib/fsr")
2
+ require FSR::ROOT/".."/:spec/:helper
3
+ require FSR::ROOT/:fsr/:listener/:outbound
4
+ gem "tmm1-em-spec"
5
+ require "em/spec"
6
+ require "fileutils"
7
+
8
+
9
+ # Shared contexts to make describing listener behavior easier
10
+ shared :fsr_listener do
11
+ def outbound_socket(listener, from, opts = {})
12
+ FSR::Log.outputters = Log4r::FileOutputter.new('spec', :filename => ($spec_log = "/tmp/fsr#{Time.now.to_i}_spec.log"), :level => Log4r::DEBUG)
13
+ FSR::Log.info "Spec Time #{Time.now} file: #{$spec_log}"
14
+ listener.receive_data("Content-Length: 0\nCaller-Caller-ID-Number: #{from}#{opts ? "\n" + opts.map{|k,v| "#{k}: #{v}" }.join("\n") : ""}\n\n")
15
+ yield
16
+ ensure
17
+ if (spec = Pathname($spec_log)).file?
18
+ puts "Socket Complete: Log Follows \n#{spec.read}"
19
+ Pathname($spec_log).delete
20
+ end
21
+ end
22
+ end
@@ -4,13 +4,21 @@ task :setup => :gem_installer do
4
4
  # core
5
5
  gem 'eventmachine'
6
6
 
7
- # spec
8
- gem 'bacon'
9
- gem 'rcov'
10
-
11
7
  # doc
12
8
  gem 'yard'
13
9
 
14
10
  setup
15
11
  end
16
12
  end
13
+
14
+ desc 'install all possible dependencies'
15
+ task :setup_spec => :setup do
16
+ GemInstaller.new do
17
+ # spec
18
+ gem 'bacon'
19
+
20
+ gem 'tmm1-em-spec', :lib => "em/spec"
21
+
22
+ setup
23
+ end
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bougyman-freeswitcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jayson Vaughn
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2009-06-03 00:00:00 -07:00
15
+ date: 2009-07-03 00:00:00 -07:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: "0"
27
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 ----- A ruby library for interacting with the \"FreeSWITCH\" (http://www.freeswitch.org) opensource telephony platform REQUIREMENTS ------------ * ruby (>= 1.8) * eventmachine (If you wish to use Outbound and Inbound listener) USAGE ----- An Outbound Event Listener Example that reads and returns DTMF input: -------------------------------------------------------------------- Simply just create a subclass of FSR::Listner::Outbound and all new calls/sessions will invoke the \"session_initiated\" callback method. <b>NOTE</b>: FSR uses blocks within the 'session_inititated' method to ensure that the next \"freeswich command\" is not executed until the previous \"Freeswitch command\" has finished. This is kicked off by \"answer do\" #!/usr/bin/ruby require 'fsr' require 'fsr/listener/outbound' class OutboundDemo < FSR::Listener::Outbound def session_initiated exten = @session.headers[:caller_caller_id_number] FSR::Log.info \"*** Answering incoming call from #{exten}\" answer do FSR::Log.info \"***Reading DTMF from #{exten}\" read(\"/home/freeswitch/freeswitch/sounds/music/8000/sweet.wav\", 4, 10, \"input\", 7000) do |read_var| FSR::Log.info \"***Success, grabbed #{read_var.strip} from #{exten}\" # Tell the caller what they entered speak(\"Got the DTMF of: #{read_var}\") do #Hangup the call hangup end end end end end FSR.start_oes! OutboundDemo, :port => 8084, :host => \"127.0.0.1\" An Inbound Event Socket Listener example using FreeSWITCHeR's hook system: -------------------------------------------------------------------------- #!/usr/bin/ruby require 'pp' require 'fsr' require \"fsr/listener/inbound\" # EXAMPLE 1 # This adds a hook on CHANNEL_CREATE events. You can also create a method to handle the event you're after. See the next example FSL::Inbound.add_event_hook(:CHANNEL_CREATE) {|event| FSR::Log.info \"*** [#{event.content[:unique_id]}] Channel created - greetings from the hook!\" } # EXAMPLE 2 # Define a method to handle CHANNEL_HANGUP events. def custom_channel_hangup_handler(event) FSR::Log.info \"*** [#{event.content[:unique_id]}] Channel hangup. The event:\" pp event end # This adds a hook for EXAMPLE 2 FSL::Inbound.add_event_hook(:CHANNEL_HANGUP) {|event| custom_channel_hangup_handler(event) } # Start FSR Inbound Listener FSR.start_ies!(FSL::Inbound, :host => \"localhost\", :port => 8021) An Inbound Event Socket Listener example using the on_event callback method instead of hooks: --------------------------------------------------------------------------------------------- #!/usr/bin/ruby require 'pp' 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) An example of using FSR::CommandSocket to originate a new call in irb: ---------------------------------------------------------------------- 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\"} SUPPORT ------- Home page at http://code.rubyists.com/projects/fs #rubyists on FreeNode"
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 ----- A ruby library for interacting with the \"FreeSWITCH\" (http://www.freeswitch.org) opensource telephony platform REQUIREMENTS ------------ * ruby (>= 1.8) * eventmachine (If you wish to use Outbound and Inbound listener) USAGE ----- An Outbound Event Listener Example that reads and returns DTMF input: -------------------------------------------------------------------- Simply just create a subclass of FSR::Listner::Outbound and all new calls/sessions will invoke the \"session_initiated\" callback method. <b>NOTE</b>: FSR uses blocks within the 'session_inititated' method to ensure that the next \"freeswich command\" is not executed until the previous \"Freeswitch command\" has finished. This is kicked off by \"answer do\" #!/usr/bin/ruby require 'fsr' require 'fsr/listener/outbound' class OutboundDemo < FSR::Listener::Outbound def session_initiated exten = @session.headers[:caller_caller_id_number] FSR::Log.info \"*** Answering incoming call from #{exten}\" answer do FSR::Log.info \"***Reading DTMF from #{exten}\" read(\"/home/freeswitch/freeswitch/sounds/music/8000/sweet.wav\", 4, 10, \"input\", 7000) do |read_var| FSR::Log.info \"***Success, grabbed #{read_var.strip} from #{exten}\" # Tell the caller what they entered speak(\"Got the DTMF of: #{read_var}\") do #Hangup the call hangup end end end end end FSR.start_oes! OutboundDemo, :port => 8084, :host => \"127.0.0.1\" An Inbound Event Socket Listener example using FreeSWITCHeR's hook system: -------------------------------------------------------------------------- #!/usr/bin/ruby require 'pp' require 'fsr' require \"fsr/listener/inbound\" # EXAMPLE 1 # This adds a hook on CHANNEL_CREATE events. You can also create a method to handle the event you're after. See the next example FSL::Inbound.add_event_hook(:CHANNEL_CREATE) {|event| FSR::Log.info \"*** [#{event.content[:unique_id]}] Channel created - greetings from the hook!\" } # EXAMPLE 2 # Define a method to handle CHANNEL_HANGUP events. def custom_channel_hangup_handler(event) FSR::Log.info \"*** [#{event.content[:unique_id]}] Channel hangup. The event:\" pp event end # This adds a hook for EXAMPLE 2 FSL::Inbound.add_event_hook(:CHANNEL_HANGUP) {|event| custom_channel_hangup_handler(event) } # Start FSR Inbound Listener FSR.start_ies!(FSL::Inbound, :host => \"localhost\", :port => 8021) An Inbound Event Socket Listener example using the on_event callback method instead of hooks: --------------------------------------------------------------------------------------------- #!/usr/bin/ruby require 'pp' 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, :auth => \"ClueCon\") An example of using FSR::CommandSocket to originate a new call in irb: ---------------------------------------------------------------------- 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\"} SUPPORT ------- Home page at http://code.rubyists.com/projects/fs #rubyists on FreeNode"
29
29
  email: FreeSWITCHeR@rubyists.com
30
30
  executables: []
31
31
 
@@ -75,6 +75,7 @@ files:
75
75
  - lib/fsr/cmd/sofia/status.rb
76
76
  - lib/fsr/cmd/sofia_contact.rb
77
77
  - lib/fsr/cmd/status.rb
78
+ - lib/fsr/cmd/uuid_dump.rb
78
79
  - lib/fsr/command_socket.rb
79
80
  - lib/fsr/database.rb
80
81
  - lib/fsr/database/call_limit.rb
@@ -88,6 +89,7 @@ files:
88
89
  - lib/fsr/listener/header_and_content_response.rb
89
90
  - lib/fsr/listener/inbound.rb
90
91
  - lib/fsr/listener/inbound/event.rb
92
+ - lib/fsr/listener/mock.rb
91
93
  - lib/fsr/listener/outbound.rb
92
94
  - lib/fsr/model/call.rb
93
95
  - lib/fsr/version.rb
@@ -99,13 +101,13 @@ files:
99
101
  - tasks/gem_installer.rake
100
102
  - tasks/install_dependencies.rake
101
103
  - tasks/manifest.rake
102
- - tasks/rcov.rake
103
104
  - tasks/release.rake
104
105
  - tasks/reversion.rake
105
106
  - tasks/setup.rake
106
107
  - tasks/spec.rake
107
108
  - tasks/yard.rake
108
109
  - spec/helper.rb
110
+ - spec/fsr_listener_helper.rb
109
111
  - spec/fsr/app.rb
110
112
  - spec/fsr/app/answer.rb
111
113
  - spec/fsr/app/bridge.rb
@@ -125,6 +127,7 @@ files:
125
127
  - spec/fsr/cmd/originate.rb
126
128
  - spec/fsr/cmd/sofia.rb
127
129
  - spec/fsr/cmd/sofia/profile.rb
130
+ - spec/fsr/cmd/uuid_dump.rb
128
131
  - spec/fsr/listener.rb
129
132
  - spec/fsr/listener/header_and_content_response.rb
130
133
  - spec/fsr/listener/inbound.rb
@@ -232,7 +235,7 @@ post_install_message: |
232
235
 
233
236
  end
234
237
 
235
- FSR.start_ies!(IesDemo, :host => "localhost", :port => 8021)
238
+ FSR.start_ies!(IesDemo, :host => "localhost", :port => 8021, :auth => "ClueCon")
236
239
 
237
240
 
238
241
  An example of using FSR::CommandSocket to originate a new call in irb:
@@ -300,6 +303,7 @@ test_files:
300
303
  - spec/fsr/cmd/originate.rb
301
304
  - spec/fsr/cmd/sofia.rb
302
305
  - spec/fsr/cmd/sofia/profile.rb
306
+ - spec/fsr/cmd/uuid_dump.rb
303
307
  - spec/fsr/listener.rb
304
308
  - spec/fsr/listener/header_and_content_response.rb
305
309
  - spec/fsr/listener/inbound.rb
@@ -1,23 +0,0 @@
1
- desc 'code coverage'
2
- task :rcov => :clean do
3
- specs = PROJECT_SPECS
4
-
5
- ignore = %w[ gem rack bacon ]
6
-
7
- if RUBY_VERSION >= '1.8.7'
8
- ignore << 'begin_with' << 'end_with'
9
- end
10
- if RUBY_VERSION < '1.9'
11
- ignore << 'fiber'
12
- end
13
-
14
- ignored = ignore.join(',')
15
-
16
- cmd = "rcov --aggregate coverage.data --sort coverage -t --%s -x '#{ignored}' %s"
17
-
18
- while spec = specs.shift
19
- puts '', "Gather coverage for #{spec} ..."
20
- html = specs.empty? ? 'html' : 'no-html'
21
- sh(cmd % [html, spec])
22
- end
23
- end