rastman 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +15 -0
- data/README +23 -22
- data/lib/rastman.rb +20 -5
- metadata +41 -33
data/CHANGELOG
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
*0.1.5* (February 8th, 2008)
|
2
|
+
|
3
|
+
* fix the return value of ping! so it returns true in case of success [Franz Schwartau]
|
4
|
+
|
5
|
+
* add the getvar and getvar! commands [Franz Schwartau]
|
6
|
+
|
7
|
+
* allow to pass multiple variables to originate using a Hash [Franz Schwartau]
|
8
|
+
i.e.: rastman.originate([...], :variable => {"var1" => "val1", "var2" => "val2"})
|
9
|
+
|
10
|
+
|
11
|
+
*0.1.4* (June 28th, 2007)
|
12
|
+
|
13
|
+
* make it work for Asterisk 1.0.x
|
14
|
+
|
15
|
+
* fix a problem when the event content contains multi-lines
|
data/README
CHANGED
@@ -5,27 +5,28 @@
|
|
5
5
|
# and listens to events published by the server. The instance can also
|
6
6
|
# be used to send Manager API requests to the server.
|
7
7
|
#
|
8
|
-
# ==
|
9
|
-
#
|
10
|
-
# require "rubygems"
|
11
|
-
# require "rastman"
|
12
|
-
#
|
13
|
-
# rastman = Rastman::Manager.new("myuser", "secret")
|
14
|
-
#
|
15
|
-
# rastman.add_event_hook(:event) { |evt| puts "Event received: [#{evt.inspect}]"
|
16
|
-
#
|
17
|
-
# rastman.connect
|
18
|
-
#
|
19
|
-
# rastman.events(:eventmask => "user,call")
|
8
|
+
# == Download
|
20
9
|
#
|
21
|
-
# rastman
|
10
|
+
# You can download Rastman from the Rubyforge project page: http://rubyforge.org/projects/rastman
|
22
11
|
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
12
|
+
# == Example
|
13
|
+
#
|
14
|
+
# require "rubygems"
|
15
|
+
# require "rastman"
|
16
|
+
#
|
17
|
+
# rastman = Rastman::Manager.new("myuser", "secret")
|
18
|
+
#
|
19
|
+
# rastman.add_event_hook(:event) { |evt| puts "Event received: [#{evt.inspect}]"
|
20
|
+
#
|
21
|
+
# rastman.connect
|
22
|
+
#
|
23
|
+
# rastman.events(:eventmask => "user,call")
|
24
|
+
#
|
25
|
+
# rastman.ping
|
26
|
+
#
|
27
|
+
# rastman.originate :channel => "SIP/myphone@mydomain.com",
|
28
|
+
# :context => "default", :exten => "voicemail",
|
29
|
+
# :priority => 1
|
30
|
+
#
|
31
|
+
# rastman.logoff
|
32
|
+
#
|
data/lib/rastman.rb
CHANGED
@@ -87,7 +87,7 @@ module Rastman
|
|
87
87
|
|
88
88
|
COMMANDS = [:login, :logoff, :events, :originate, :originate!, :redirect,
|
89
89
|
:redirect!, :hangup, :hangup!, :ping, :ping!, :setvar, :setvar!,
|
90
|
-
:command, :command!]
|
90
|
+
:command, :command!, :getvar, :getvar!]
|
91
91
|
WAIT_FOR_ANSWER = 0.1
|
92
92
|
|
93
93
|
# Returns a Rastman::Manager object. The login and pwd parameters
|
@@ -140,6 +140,11 @@ module Rastman
|
|
140
140
|
@conn.close
|
141
141
|
$rnlog.debug("Rastman::Manager#disconnect: closed connection")
|
142
142
|
end
|
143
|
+
|
144
|
+
# Returns the connection object.
|
145
|
+
def connection
|
146
|
+
@conn
|
147
|
+
end
|
143
148
|
|
144
149
|
# Adds (or replaces) a block to be executed when the specified event occurs:
|
145
150
|
# * <tt>:event</tt>: an event was received
|
@@ -226,8 +231,14 @@ module Rastman
|
|
226
231
|
end
|
227
232
|
@conn_lock.synchronize do
|
228
233
|
action.each do |key, value|
|
229
|
-
|
230
|
-
|
234
|
+
name = key.to_s
|
235
|
+
$rnlog.debug("Rastman::Manager#send_action: write (#{name}: #{value}\\r\\n)")
|
236
|
+
case value
|
237
|
+
when Hash
|
238
|
+
value.each { |k, v| @conn.write("#{name}: #{k.to_s}=#{v}\r\n") }
|
239
|
+
else
|
240
|
+
@conn.write("#{name}: #{value}\r\n")
|
241
|
+
end
|
231
242
|
end
|
232
243
|
$rnlog.debug("Rastman::Manager#send_action: write (\\r\\n)")
|
233
244
|
@conn.write("\r\n")
|
@@ -242,11 +253,15 @@ module Rastman
|
|
242
253
|
answer << {}
|
243
254
|
end
|
244
255
|
end
|
245
|
-
|
256
|
+
success = case action[:action]
|
257
|
+
when "ping" then "Pong"
|
258
|
+
else "Success"
|
259
|
+
end
|
260
|
+
result = answer.first[:response] == success rescue false
|
246
261
|
end
|
247
262
|
return result
|
248
263
|
rescue Exception => ex
|
249
|
-
$rnlog.
|
264
|
+
$rnlog.warn("Rastman::Manager#send_action: exception caught (connection probably closed already): #{ex}")
|
250
265
|
end
|
251
266
|
|
252
267
|
def method_missing(meth, *args, &block) # :nodoc:
|
metadata
CHANGED
@@ -1,41 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.2
|
3
|
-
specification_version: 1
|
4
2
|
name: rastman
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2007-06-28 00:00:00 -07:00
|
8
|
-
summary: Asterisk Manager API interface for Ruby
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: mathieul@zlaj.org
|
12
|
-
homepage: http://rastman.rubyforge.org/
|
13
|
-
rubyforge_project:
|
14
|
-
description: Asterisk Manager API interface for Ruby
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 1.8.4
|
24
|
-
version:
|
4
|
+
version: 0.1.5
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Mathieu Lajugie
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-02-08 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Asterisk Manager API interface for Ruby
|
17
|
+
email: mathieul@zlaj.org
|
18
|
+
executables:
|
19
|
+
- rastman_mkcalls.rb
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
31
24
|
files:
|
32
25
|
- MIT-LICENSE
|
33
26
|
- README
|
34
27
|
- TODO
|
28
|
+
- CHANGELOG
|
35
29
|
- bin/rastman_mkcalls.rb
|
36
30
|
- lib/rastman.rb
|
37
|
-
|
38
|
-
|
31
|
+
has_rdoc: true
|
32
|
+
homepage: http://rastman.rubyforge.org/
|
33
|
+
post_install_message:
|
39
34
|
rdoc_options:
|
40
35
|
- --quiet
|
41
36
|
- --title
|
@@ -46,13 +41,26 @@ rdoc_options:
|
|
46
41
|
- --main
|
47
42
|
- README
|
48
43
|
- --inline-source
|
49
|
-
|
50
|
-
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 1.8.4
|
51
|
+
version:
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
55
58
|
requirements: []
|
56
59
|
|
57
|
-
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.0.1
|
62
|
+
signing_key:
|
63
|
+
specification_version: 2
|
64
|
+
summary: Asterisk Manager API interface for Ruby
|
65
|
+
test_files: []
|
58
66
|
|