ruby-asterisk 0.0.1 → 0.0.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/README.md CHANGED
@@ -66,6 +66,25 @@ To start a new call use the following command
66
66
  @ami.originate("SIP/9100","OUTGOING","123456","1") # CALLER, CONTEXT, CALLEE, PRIORITY
67
67
  ```
68
68
 
69
+ ### COMMAND
70
+
71
+ To execute a cli command use the following code
72
+
73
+ ```ruby
74
+ @ami.command("core show channels")
75
+ ```
76
+
77
+ ### MEETME LIST
78
+
79
+ To get a list of all active conferences use the following command
80
+
81
+ ```ruby
82
+ @ami.meet_me_list
83
+ ```
84
+
85
+
86
+
87
+
69
88
 
70
89
  ### THE RESPONSE OBJECT
71
90
 
data/lib/ruby-asterisk.rb CHANGED
@@ -48,6 +48,17 @@ module RubyAsterisk
48
48
  Response.new("Login",request.response_data)
49
49
  end
50
50
 
51
+ def command(command)
52
+ request = Request.new("Command",{ "Command" => command })
53
+ request.commands.each do |command|
54
+ @session.write(command)
55
+ end
56
+ @session.waitfor("String" => "ActionID: "+request.action_id, "Timeout" => 3) do |data|
57
+ request.response_data << data
58
+ end
59
+ Response.new("Command",request.response_data)
60
+ end
61
+
51
62
  def core_show_channels
52
63
  request = Request.new("CoreShowChannels")
53
64
  request.commands.each do |command|
@@ -59,6 +70,17 @@ module RubyAsterisk
59
70
  Response.new("CoreShowChannels",request.response_data)
60
71
  end
61
72
 
73
+ def meet_me_list
74
+ request = Request.new("MeetMeList")
75
+ request.commands.each do |command|
76
+ @session.write(command)
77
+ end
78
+ @session.waitfor("String" => "ActionID: "+request.action_id, "Timeout" => 3) do |data|
79
+ request.response_data << data
80
+ end
81
+ Response.new("MeetMeList",request.response_data)
82
+ end
83
+
62
84
  def parked_calls
63
85
  request = Request.new("ParkedCalls")
64
86
  request.commands.each do |command|
@@ -41,11 +41,17 @@ module RubyAsterisk
41
41
  when "ParkedCalls"
42
42
  self._parse_data_parked_calls(response)
43
43
  when "Originate"
44
- self._parse_originate_calls(response)
44
+ self._parse_originate(response)
45
+ when "MeetMeList"
46
+ self._parse_meet_me_list(response)
45
47
  end
46
48
  end
47
49
 
48
- def _parse_originate_calls(response)
50
+ def _parse_meet_me_list(response)
51
+ self._parse_objects(response,:rooms,"Event: MeetmeList")
52
+ end
53
+
54
+ def _parse_originate(response)
49
55
  self._parse_objects(response,:dial,"Event: Dial")
50
56
  end
51
57
 
@@ -1,3 +1,3 @@
1
1
  module Rami
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -14,7 +14,7 @@ describe RubyAsterisk::Response do
14
14
  ChannelStateDesc: Up
15
15
  Application: Parked Call
16
16
  ApplicationData:
17
- CallerIDnum: 3335313510
17
+ CallerIDnum: 123456
18
18
  CallerIDname:
19
19
  ConnectedLineNum:
20
20
  ConnectedLineName:
@@ -31,7 +31,7 @@ describe RubyAsterisk::Response do
31
31
  Channel: SIP/195.62.226.2-00000026
32
32
  From: SIP/195.62.226.2-00000026
33
33
  Timeout: 3
34
- CallerIDNum: 3335313510
34
+ CallerIDNum: 123456
35
35
  CallerIDName:
36
36
  ConnectedLineNum:
37
37
  ConnectedLineName:
@@ -47,6 +47,23 @@ describe RubyAsterisk::Response do
47
47
  DialStatus: CHANUNAVAIL"
48
48
  end
49
49
 
50
+ def meet_me_list_response
51
+ "Event: MeetmeList
52
+ ActionID: 921
53
+ Conference: 1234
54
+ UserNumber: 1
55
+ CallerIDNum: 123456
56
+ CallerIDName: <no name>
57
+ ConnectedLineNum: <unknown>
58
+ ConnectedLineName: <no name>
59
+ Channel: SIP/195.62.226.18-0000000e
60
+ Admin: No
61
+ Role: Talk and listen
62
+ MarkedUser: No
63
+ Muted: No
64
+ Talking: Not monitored"
65
+ end
66
+
50
67
  describe ".new" do
51
68
 
52
69
  describe "receiving a Core Show Channels request" do
@@ -57,7 +74,7 @@ describe RubyAsterisk::Response do
57
74
 
58
75
  it "should correctly fill the fields" do
59
76
  @response = RubyAsterisk::Response.new("CoreShowChannels",core_show_channels_response)
60
- @response.data[:channels][0]["CallerIDnum"].should eq("3335313510")
77
+ @response.data[:channels][0]["CallerIDnum"].should eq("123456")
61
78
  end
62
79
  end
63
80
 
@@ -73,7 +90,7 @@ describe RubyAsterisk::Response do
73
90
  end
74
91
  end
75
92
 
76
- describe "resceiving a Originate request" do
93
+ describe "receiving a Originate request" do
77
94
  it "should parse correctly data coming from Asterisk about the call" do
78
95
  @response = RubyAsterisk::Response.new("Originate",originate_response)
79
96
  @response.data[:dial].should_not be_empty
@@ -84,5 +101,17 @@ describe RubyAsterisk::Response do
84
101
  @response.data[:dial][0]["UniqueID"].should eq("1335457364.68")
85
102
  end
86
103
  end
104
+
105
+ describe "receiving a MeetMeList request" do
106
+ it "should parse correctly data coming from Asterisk about the conference room" do
107
+ @response = RubyAsterisk::Response.new("MeetMeList",meet_me_list_response)
108
+ @response.data[:rooms].should_not be_empty
109
+ end
110
+
111
+ it "should correctly fill the fields" do
112
+ @response = RubyAsterisk::Response.new("MeetMeList",meet_me_list_response)
113
+ @response.data[:rooms][0]["Conference"].should eq("1234")
114
+ end
115
+ end
87
116
  end
88
117
  end
@@ -2,28 +2,6 @@
2
2
  require 'spec_helper'
3
3
  describe RubyAsterisk do
4
4
 
5
- def core_show_channels_response
6
- "Event: CoreShowChannel
7
- ActionID: 839
8
- Channel: SIP/195.62.226.4-00000025
9
- UniqueID: 1335448133.61
10
- Context: incoming
11
- Extension: s
12
- Priority: 1
13
- ChannelState: 6
14
- ChannelStateDesc: Up
15
- Application: Parked Call
16
- ApplicationData:
17
- CallerIDnum: 3335313510
18
- CallerIDname:
19
- ConnectedLineNum:
20
- ConnectedLineName:
21
- Duration: 00:00:05
22
- AccountCode:
23
- BridgedChannel:
24
- BridgedUniqueID:"
25
- end
26
-
27
5
  def mock_request(stubs={})
28
6
  (@mock_request ||= mock_model(RubyAsterisk::Request).as_null_object).tap do |request|
29
7
  request.stub(stubs) unless stubs.empty?
@@ -140,4 +118,18 @@ describe RubyAsterisk do
140
118
  @session.originate("SIP/9100","OUTGOING","123456","1").should be_kind_of(RubyAsterisk::Response)
141
119
  end
142
120
  end
121
+
122
+ describe ".command" do
123
+ it "should return a response object" do
124
+ @session.login("mark","mysecret")
125
+ @session.command("meetme list").should be_kind_of(RubyAsterisk::Response)
126
+ end
127
+ end
128
+
129
+ describe ".meet_me_list" do
130
+ it "should return a response object" do
131
+ @session.login("mark","mysecret")
132
+ @session.meet_me_list.should be_kind_of(RubyAsterisk::Response)
133
+ end
134
+ end
143
135
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ruby-asterisk
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Emiliano Della Casa
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-04-27 00:00:00 Z
13
+ date: 2012-05-02 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake