bougyman-freeswitcher 0.1.2 → 0.1.3

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.
data/lib/fsr.rb CHANGED
@@ -6,7 +6,7 @@ require 'pp'
6
6
  module FSR
7
7
  # Global configuration options
8
8
  #
9
- VERSION = '0.1.2'
9
+ VERSION = '0.1.3'
10
10
  FS_INSTALL_PATHS = ["/usr/local/freeswitch", "/opt/freeswitch", "/usr/freeswitch"]
11
11
  DEFAULT_CALLER_ID_NUMBER = '8675309'
12
12
  DEFAULT_CALLER_ID_NAME = "FSR"
@@ -0,0 +1,19 @@
1
+ require "fsr/app"
2
+ module FSR
3
+ module App
4
+ class Limit < Application
5
+
6
+ def initialize(id = nil, realm = "$${domain}", limit = 5)
7
+ @realm, @id, @limit = realm, id, limit
8
+ raise "Must supply a valid id" if @id.nil?
9
+ end
10
+
11
+ def arguments
12
+ [@realm, @id, @limit]
13
+ end
14
+
15
+ end
16
+
17
+ register(:limit, Limit)
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec/helper'
2
+ require "fsr/app"
3
+ FSR::App.load_application("limit")
4
+
5
+ describe "Testing FSR::App::Limit" do
6
+ ## Calls ##
7
+ # Interface to calls
8
+ it "FSR::App::Limit should send proper limit command only passing an id" do
9
+ limit = FSR::App::Limit.new("fsr_caller")
10
+ limit.raw.should == "limit($${domain} fsr_caller 5)"
11
+ limit.sendmsg.should == "call-command: execute\nexecute-app-name: limit\nexecute-app-arg: $${domain} fsr_caller 5\n\n"
12
+ end
13
+
14
+ it "FSR::App::Limit should send proper limit command passing id and realm" do
15
+ limit = FSR::App::Limit.new("fsr_caller", "foodomain")
16
+ limit.raw.should == "limit(foodomain fsr_caller 5)"
17
+ limit.sendmsg.should == "call-command: execute\nexecute-app-name: limit\nexecute-app-arg: foodomain fsr_caller 5\n\n"
18
+ end
19
+
20
+ it "FSR::App::Limit should send proper limit command passing id, realm, and limit" do
21
+ limit = FSR::App::Limit.new("fsr_caller", "foodomain", 10)
22
+ limit.raw.should == "limit(foodomain fsr_caller 10)"
23
+ limit.sendmsg.should == "call-command: execute\nexecute-app-name: limit\nexecute-app-arg: foodomain fsr_caller 10\n\n"
24
+ end
25
+
26
+ end
data/spec/fsr/loading.rb CHANGED
@@ -4,7 +4,7 @@ require 'spec/helper'
4
4
  describe "Testing FSR module loading methods" do
5
5
  # When you add applications you must modify the expected apps_loaded behavior
6
6
  it "Loads all applications" do
7
- all_apps = [:play_and_get_digits, :uuid_dump, :uuid_setvar, :uuid_getvar, :read, :set, :transfer, :speak, :fs_sleep, :playback, :answer, :fifo, :bridge, :hangup, :conference, :fs_break, :log]
7
+ all_apps = [:play_and_get_digits, :uuid_dump, :uuid_setvar, :uuid_getvar, :read, :set, :transfer, :speak, :fs_sleep, :playback, :answer, :fifo, :bridge, :hangup, :conference, :fs_break, :log, :limit]
8
8
  # Add any apps which will load to this set
9
9
  apps_loaded = FSR.load_all_applications
10
10
  apps_loaded.kind_of?(Array).should == true
@@ -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 = [:originate, :sofia, :fsctl, :sofia_contact, :status, :calls, :limit] # If you add a command add it to this set
19
+ all_commands = [:originate, :sofia, :fsctl, :sofia_contact, :status, :calls] # 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
@@ -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.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jayson Vaughn
@@ -60,6 +60,7 @@ files:
60
60
  - lib/fsr/app/fs_break.rb
61
61
  - lib/fsr/app/fs_sleep.rb
62
62
  - lib/fsr/app/hangup.rb
63
+ - lib/fsr/app/limit.rb
63
64
  - lib/fsr/app/log.rb
64
65
  - lib/fsr/app/play_and_get_digits.rb
65
66
  - lib/fsr/app/playback.rb
@@ -74,7 +75,6 @@ files:
74
75
  - lib/fsr/cmd
75
76
  - lib/fsr/cmd/calls.rb
76
77
  - lib/fsr/cmd/fsctl.rb
77
- - lib/fsr/cmd/limit.rb
78
78
  - lib/fsr/cmd/originate.rb
79
79
  - lib/fsr/cmd/sofia
80
80
  - lib/fsr/cmd/sofia/profile.rb
@@ -268,6 +268,7 @@ test_files:
268
268
  - spec/fsr/app/conference.rb
269
269
  - spec/fsr/app/fifo.rb
270
270
  - spec/fsr/app/hangup.rb
271
+ - spec/fsr/app/limit.rb
271
272
  - spec/fsr/app/log.rb
272
273
  - spec/fsr/app/play_and_get_digits.rb
273
274
  - spec/fsr/app/playback.rb
@@ -276,7 +277,6 @@ test_files:
276
277
  - spec/fsr/app.rb
277
278
  - spec/fsr/cmd
278
279
  - spec/fsr/cmd/calls.rb
279
- - spec/fsr/cmd/limit.rb
280
280
  - spec/fsr/cmd/originate.rb
281
281
  - spec/fsr/cmd/sofia
282
282
  - spec/fsr/cmd/sofia/profile.rb
data/lib/fsr/cmd/limit.rb DELETED
@@ -1,31 +0,0 @@
1
- require "fsr/app"
2
- module FSR
3
- module Cmd
4
- class Limit < Command
5
-
6
- def initialize(fs_socket = nil, id = nil, realm = "$${domain}", limit = 5)
7
- @fs_socket = fs_socket # FSR::CommandSocket obj
8
- @realm, @id, @limit = realm, id, limit
9
- raise "Must supply a valid id" if @id.nil?
10
- end
11
-
12
- # Send the command to the event socket, using bgapi by default.
13
- def run(api_method = :api)
14
- orig_command = "%s %s" % [api_method, raw]
15
- Log.debug "saying #{orig_command}"
16
- @fs_socket.say(orig_command)
17
- end
18
-
19
- def arguments
20
- [@realm, @id, @limit]
21
- end
22
-
23
- # This method builds the API command to send to the freeswitch event socket
24
- def raw
25
- orig_command = "limit %s %s %s" % arguments
26
- end
27
- end
28
-
29
- register(:limit, Limit)
30
- end
31
- end
@@ -1,23 +0,0 @@
1
- require 'spec/helper'
2
- require "fsr/cmd"
3
- FSR::Cmd.load_command("limit")
4
-
5
- describe "Testing FSR::Cmd::Limit" do
6
- ## Calls ##
7
- # Interface to calls
8
- it "FSR::Cmd::Limit should send proper limit command only passing an id" do
9
- limit = FSR::Cmd::Limit.new(nil, "fsr_caller")
10
- limit.raw.should == "limit $${domain} fsr_caller 5"
11
- end
12
-
13
- it "FSR::Cmd::Limit should send proper limit command passing id and realm" do
14
- limit = FSR::Cmd::Limit.new(nil, "fsr_caller", "foodomain")
15
- limit.raw.should == "limit foodomain fsr_caller 5"
16
- end
17
-
18
- it "FSR::Cmd::Limit should send proper limit command passing id, realm, and limit" do
19
- limit = FSR::Cmd::Limit.new(nil, "fsr_caller", "foodomain", 10)
20
- limit.raw.should == "limit foodomain fsr_caller 10"
21
- end
22
-
23
- end