freeswitcher 0.5.9 → 0.5.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ require "fsr/app"
2
+ module FSR
3
+ module Cmd
4
+ class SchedHangup < Command
5
+ DEFAULTS = {when: 1, cause: "UNKNOWN"}
6
+ def initialize(fs_socket = nil, args = {})
7
+ @fs_socket = fs_socket # FSR::CommandSocket obj
8
+ args = DEFAULTS.merge(args)
9
+ @when, @uuid, @cause = args.values_at(:when, :uuid, :cause)
10
+ raise(ArgumentError, "No uuid given") unless @uuid
11
+ end
12
+
13
+ # Send the command to the event socket, using bgapi by default.
14
+ def run(api_method = :api)
15
+ orig_command = "%s %s" % [api_method, raw]
16
+ Log.debug "saying #{orig_command}"
17
+ @fs_socket.say(orig_command)
18
+ end
19
+
20
+ # This method builds the API command to send to the freeswitch event socket
21
+ def raw
22
+ orig_command = "sched_hangup +#{@when} #{@uuid} #{@cause.dump}"
23
+ end
24
+ end
25
+
26
+ register(:sched_hangup, SchedHangup)
27
+ end
28
+ end
data/lib/fsr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module FSR
2
- VERSION = "0.5.9"
2
+ VERSION = "0.5.10"
3
3
  end
@@ -0,0 +1,35 @@
1
+ require './spec/helper'
2
+ require "fsr/cmd"
3
+ FSR::Cmd.load_command("sched_hangup")
4
+
5
+ describe "Testing FSR::Cmd::Callcenter" do
6
+ ## Scheduled Hangup ##
7
+ it "FSR::Cmd::SchedHangup should schedule a hangup with default " do
8
+ cmd = FSR::Cmd::SchedHangup.new nil, uuid: 1234
9
+ cmd.raw.should == 'sched_hangup +1 1234 "UNKNOWN"'
10
+ end
11
+
12
+ it "FSR::Cmd::SchedHangup should schedule a hangup with user-supplied time " do
13
+ cmd = FSR::Cmd::SchedHangup.new nil, uuid: 1234, when: 60
14
+ cmd.raw.should == 'sched_hangup +60 1234 "UNKNOWN"'
15
+ end
16
+
17
+ it "FSR::Cmd::SchedHangup should schedule a hangup with user-supplied cause " do
18
+ cmd = FSR::Cmd::SchedHangup.new nil, uuid: 1234, cause: "No Reason"
19
+ cmd.raw.should == 'sched_hangup +1 1234 "No Reason"'
20
+ end
21
+
22
+ it "FSR::Cmd::SchedHangup should schedule a hangup with user-supplied cause " do
23
+ cmd = FSR::Cmd::SchedHangup.new nil, uuid: 1234, cause: "No Reason"
24
+ cmd.raw.should == 'sched_hangup +1 1234 "No Reason"'
25
+ end
26
+
27
+ it "FSR::Cmd::SchedHangup should schedule a hangup with user-supplied cause containing quote" do
28
+ cmd = FSR::Cmd::SchedHangup.new nil, uuid: 1234, cause: 'Say "WHAT?"'
29
+ cmd.raw.should == 'sched_hangup +1 1234 "Say \"WHAT?\""'
30
+ end
31
+
32
+ it "FSR::Cmd::SchedHangup should raise " do
33
+ lambda { cmd = FSR::Cmd::SchedHangup.new nil, cause: "No Reason" }.should.raise ArgumentError
34
+ end
35
+ end
data/spec/fsr/loading.rb CHANGED
@@ -16,7 +16,7 @@ describe "Testing FSR module loading methods" do
16
16
 
17
17
  # When you add commands you must modify the expected cmds_loaded behavior
18
18
  it "Loads all commands" do
19
- all_commands = [:uuid_dump, :originate, :sofia, :fsctl, :sofia_contact, :status, :calls, :call_center, :channels, :enum] # If you add a command add it to this set
19
+ all_commands = [:uuid_dump, :originate, :sofia, :fsctl, :sofia_contact, :status, :calls, :call_center, :channels, :enum, :sched_hangup] # If you add a command add it to this set
20
20
  cmds_loaded = FSR.load_all_commands
21
21
  cmds_loaded.kind_of?(Array).should == true
22
22
  all_commands.each do |cmd|
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 9
9
- version: 0.5.9
8
+ - 10
9
+ version: 0.5.10
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jayson Vaughn
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-02-16 00:00:00 -06:00
20
+ date: 2011-02-17 00:00:00 -06:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -85,6 +85,7 @@ files:
85
85
  - lib/fsr/cmd/enum.rb
86
86
  - lib/fsr/cmd/fsctl.rb
87
87
  - lib/fsr/cmd/originate.rb
88
+ - lib/fsr/cmd/sched_hangup.rb
88
89
  - lib/fsr/cmd/sofia.rb
89
90
  - lib/fsr/cmd/sofia/profile.rb
90
91
  - lib/fsr/cmd/sofia/status.rb
@@ -153,6 +154,7 @@ files:
153
154
  - spec/fsr/cmd/channels.rb
154
155
  - spec/fsr/cmd/enum.rb
155
156
  - spec/fsr/cmd/originate.rb
157
+ - spec/fsr/cmd/sched_hangup.rb
156
158
  - spec/fsr/cmd/sofia.rb
157
159
  - spec/fsr/cmd/sofia/profile.rb
158
160
  - spec/fsr/cmd/uuid_dump.rb
@@ -398,6 +400,7 @@ test_files:
398
400
  - spec/fsr/cmd/channels.rb
399
401
  - spec/fsr/cmd/enum.rb
400
402
  - spec/fsr/cmd/originate.rb
403
+ - spec/fsr/cmd/sched_hangup.rb
401
404
  - spec/fsr/cmd/sofia.rb
402
405
  - spec/fsr/cmd/sofia/profile.rb
403
406
  - spec/fsr/cmd/uuid_dump.rb