bougyman-freeswitcher 0.1.1 → 0.1.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.
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.1'
9
+ VERSION = '0.1.2'
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,31 @@
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
@@ -0,0 +1,23 @@
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
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 = [:originate, :sofia, :fsctl, :sofia_contact, :status, :calls] # If you add a command add it to this set
19
+ all_commands = [:originate, :sofia, :fsctl, :sofia_contact, :status, :calls, :limit] # 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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jayson Vaughn
@@ -74,6 +74,7 @@ files:
74
74
  - lib/fsr/cmd
75
75
  - lib/fsr/cmd/calls.rb
76
76
  - lib/fsr/cmd/fsctl.rb
77
+ - lib/fsr/cmd/limit.rb
77
78
  - lib/fsr/cmd/originate.rb
78
79
  - lib/fsr/cmd/sofia
79
80
  - lib/fsr/cmd/sofia/profile.rb
@@ -275,6 +276,7 @@ test_files:
275
276
  - spec/fsr/app.rb
276
277
  - spec/fsr/cmd
277
278
  - spec/fsr/cmd/calls.rb
279
+ - spec/fsr/cmd/limit.rb
278
280
  - spec/fsr/cmd/originate.rb
279
281
  - spec/fsr/cmd/sofia
280
282
  - spec/fsr/cmd/sofia/profile.rb