ruby-asterisk 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -92,8 +92,8 @@ module RubyAsterisk
92
92
  Response.new("ParkedCalls",request.response_data)
93
93
  end
94
94
 
95
- def originate(caller,context,callee,priority)
96
- request = Request.new("Originate",{"Channel" => caller, "Context" => context, "Exten" => callee, "Priority" => priority, "Callerid" => caller, "Timeout" => "30000" })
95
+ def originate(caller,context,callee,priority,variable=nil)
96
+ request = Request.new("Originate",{"Channel" => caller, "Context" => context, "Exten" => callee, "Priority" => priority, "Callerid" => caller, "Timeout" => "30000", "Variable" => variable })
97
97
  request.commands.each do |command|
98
98
  @session.write(command)
99
99
  end
@@ -12,7 +12,7 @@ module RubyAsterisk
12
12
  def commands
13
13
  _commands=["Action: "+self.action+"\r\n","ActionID: "+self.action_id+"\r\n"]
14
14
  self.parameters.each do |key,value|
15
- _commands<<key+": "+value+"\r\n"
15
+ _commands<<key+": "+value+"\r\n" unless value.nil?
16
16
  end
17
17
  _commands[_commands.length-1]<<"\r\n"
18
18
  _commands
@@ -1,3 +1,3 @@
1
1
  module Rami
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ describe RubyAsterisk::Request do
4
+
5
+ describe "of type Originate" do
6
+ it "should set a Variable option if set" do
7
+ request = RubyAsterisk::Request.new("Originate",{"Channel" => "1234", "Context" => "test", "Exten" => "1", "Priority" => "1", "Callerid" => "1234", "Timeout" => "30000", "Variable" => "var1=15" })
8
+ request.commands.include?("Variable: var1=15\r\n").should_not be_nil
9
+ end
10
+
11
+ it "should not set a Variable option if not set" do
12
+ request = RubyAsterisk::Request.new("Originate",{"Channel" => "1234", "Context" => "test", "Exten" => "1", "Priority" => "1", "Callerid" => "1234", "Timeout" => "30000", "Variable" => nil })
13
+ request.commands.include?("Variable: var=15").should==false
14
+ end
15
+ end
16
+ end
17
+
@@ -115,7 +115,7 @@ describe RubyAsterisk do
115
115
  describe ".originate" do
116
116
  it "should return a response object" do
117
117
  @session.login("mark","mysecret")
118
- @session.originate("SIP/9100","OUTGOING","123456","1").should be_kind_of(RubyAsterisk::Response)
118
+ @session.originate("SIP/9100","OUTGOING","123456","1","queue=SIP/1000&SIP/1001").should be_kind_of(RubyAsterisk::Response)
119
119
  end
120
120
  end
121
121
 
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.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Emiliano Della Casa
@@ -55,6 +55,7 @@ files:
55
55
  - lib/ruby-asterisk/response.rb
56
56
  - lib/ruby-asterisk/version.rb
57
57
  - ruby-asterisk.gemspec
58
+ - spec/ruby-asterisk/request_spec.rb
58
59
  - spec/ruby-asterisk/response_spec.rb
59
60
  - spec/ruby-asterisk/ruby_asterisk_spec.rb
60
61
  - spec/spec_helper.rb