freeswitcher 0.6.13 → 0.6.14
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fsr/cmd/channels.rb +10 -7
- data/lib/fsr/version.rb +1 -1
- data/spec/fsr/cmd/channels.rb +10 -3
- metadata +1 -1
data/lib/fsr/cmd/channels.rb
CHANGED
@@ -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
|
16
|
+
@filter = nil if (@filter === true || @filter === false)
|
17
17
|
@fs_socket = fs_socket # FSR::CommandSocket obj
|
18
18
|
end
|
19
19
|
|
@@ -29,18 +29,21 @@ module FSR
|
|
29
29
|
channels = CSV.parse(call_info)
|
30
30
|
headers = channels[0]
|
31
31
|
@channels = channels[1 .. -1].map { |c| FSR::Model::Channel.new(headers ,*c) }
|
32
|
-
if @filter
|
33
|
-
return @channels.select { |f| f.match @filter }
|
34
|
-
else
|
35
|
-
return @channels
|
36
|
-
end
|
37
32
|
end
|
38
33
|
[]
|
39
34
|
end
|
40
35
|
|
41
36
|
# This method builds the API command to send to the freeswitch event socket
|
42
37
|
def raw
|
43
|
-
|
38
|
+
if @filter.nil?
|
39
|
+
'show channels'
|
40
|
+
elsif @filter.is_a?(Fixnum)
|
41
|
+
'show channels %d' % @filter
|
42
|
+
elsif @filter.is_a?(String)
|
43
|
+
'show channels like "%s"' % @filter
|
44
|
+
else
|
45
|
+
'show channels'
|
46
|
+
end
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
data/lib/fsr/version.rb
CHANGED
data/spec/fsr/cmd/channels.rb
CHANGED
@@ -8,16 +8,23 @@ describe "Testing FSR::Cmd::Channels" do
|
|
8
8
|
it "FSR::Cmd::Channels (false as the filter) should send show channels" do
|
9
9
|
sofia = FSR::Cmd::Channels.new(nil, false)
|
10
10
|
sofia.raw.should == "show channels"
|
11
|
+
sofia.instance_variable_get("@filter").should.be.nil
|
11
12
|
end
|
12
13
|
|
13
14
|
it "FSR::Cmd::Channels (true as the filter) should send show channels" do
|
14
15
|
sofia = FSR::Cmd::Channels.new(nil, true)
|
15
16
|
sofia.raw.should == "show channels"
|
17
|
+
sofia.instance_variable_get("@filter").should.be.nil
|
16
18
|
end
|
17
19
|
|
18
|
-
it "FSR::Cmd::Channels (
|
19
|
-
sofia = FSR::Cmd::Channels.new(nil,
|
20
|
-
sofia.raw.should ==
|
20
|
+
it "FSR::Cmd::Channels (string as the filter) should add the filter" do
|
21
|
+
sofia = FSR::Cmd::Channels.new(nil, 'something')
|
22
|
+
sofia.raw.should == 'show channels like "something"'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "FSR::Cmd::Channels (number as the filter) should just limit the calls to that number" do
|
26
|
+
sofia = FSR::Cmd::Channels.new(nil, 3)
|
27
|
+
sofia.raw.should == "show channels 3"
|
21
28
|
end
|
22
29
|
|
23
30
|
end
|