freeswitcher 0.6.17 → 0.6.18

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.
@@ -13,7 +13,7 @@ module FSR
13
13
 
14
14
  def initialize(fs_socket = nil, filter = nil)
15
15
  @filter = filter
16
- @filter = nil if (@filter === true || @filter === false)
16
+ @filter = nil if @filter === false
17
17
  @fs_socket = fs_socket # FSR::CommandSocket obj
18
18
  end
19
19
 
@@ -22,21 +22,28 @@ module FSR
22
22
  orig_command = "%s %s" % [api_method, raw]
23
23
  Log.debug "saying #{orig_command}"
24
24
  resp = @fs_socket.say(orig_command)
25
- unless resp["body"] == "0 total."
26
- call_info, count = resp["body"].split("\n\n")
27
- require "fsr/model/channel"
28
- require "csv"
29
- channels = CSV.parse(call_info)
30
- headers = channels[0]
31
- @channels = channels[1 .. -1].map { |c| FSR::Model::Channel.new(headers ,*c) }
32
- return @channels
25
+ if resp["body"] =~ /USAGE/
26
+ Log.warn "This server does not support #{raw}, trying Calls"
27
+ return Calls.new(@fs_socket, :detailed).run
28
+ else
29
+ unless resp["body"] == "0 total."
30
+ call_info, count = resp["body"].split("\n\n")
31
+ require "fsr/model/channel"
32
+ require "csv"
33
+ channels = CSV.parse(call_info)
34
+ headers = channels[0]
35
+ @channels = channels[1 .. -1].map { |c| FSR::Model::Channel.new(headers ,*c) }
36
+ return @channels
37
+ end
38
+ []
33
39
  end
34
- []
35
40
  end
36
41
 
37
42
  # This method builds the API command to send to the freeswitch event socket
38
43
  def raw
39
- if @filter.nil?
44
+ if @filter === true
45
+ 'show distinct_channels'
46
+ elsif @filter.nil?
40
47
  'show channels'
41
48
  elsif @filter.is_a?(Fixnum)
42
49
  'show channels %d' % @filter
@@ -1,3 +1,3 @@
1
1
  module FSR
2
- VERSION = "0.6.17"
2
+ VERSION = "0.6.18"
3
3
  end
@@ -13,8 +13,8 @@ describe "Testing FSR::Cmd::Channels" do
13
13
 
14
14
  it "FSR::Cmd::Channels (true as the filter) should send show channels" do
15
15
  sofia = FSR::Cmd::Channels.new(nil, true)
16
- sofia.raw.should == "show channels"
17
- sofia.instance_variable_get("@filter").should.be.nil
16
+ sofia.raw.should == "show distinct_channels"
17
+ sofia.instance_variable_get("@filter").should === true
18
18
  end
19
19
 
20
20
  it "FSR::Cmd::Channels (string as the filter) should add the filter" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: freeswitcher
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.17
5
+ version: 0.6.18
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jayson Vaughn