vxml-tools 1.0.0
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/MIT-LICENSE +20 -0
- data/README.rdoc +42 -0
- data/config/initializers/mime_types.rb +6 -0
- data/lib/generators/vxml/controller/controller_generator.rb +26 -0
- data/lib/generators/vxml/controller/templates/view.vxml.erb +4 -0
- data/lib/vxml-tools.rb +11 -0
- data/lib/vxml-tools/vxml.rb +96 -0
- data/lib/vxml_tools.rb +1 -0
- metadata +76 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 siddick.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
== VXML Tools
|
2
|
+
It contain library and Generator for the Rails 3 application.
|
3
|
+
|
4
|
+
=== Example
|
5
|
+
You can write VXML in Ruby.
|
6
|
+
First Method :-
|
7
|
+
vxml = VXML.new do|v|
|
8
|
+
v.block do |b|
|
9
|
+
b.prompt "Welcome to all"
|
10
|
+
b.if_cond "1==1" do |v|
|
11
|
+
v.prompt "Both are equal"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
render :xml => vxml.to_vxml
|
17
|
+
|
18
|
+
Second Method :-
|
19
|
+
v = VXML.new
|
20
|
+
b = v.block
|
21
|
+
b.prompt "Welcome to all"
|
22
|
+
cond = b.if_cond "1==1"
|
23
|
+
cond.prompt "Both are equal"
|
24
|
+
|
25
|
+
render :xml => v.to_vxml
|
26
|
+
|
27
|
+
=== Syntax
|
28
|
+
|
29
|
+
=== Create vxml view file .
|
30
|
+
|
31
|
+
Create vxml file with controller :-
|
32
|
+
rails g controller ivr hello_world -e vxml
|
33
|
+
|
34
|
+
Create vxml file only :-
|
35
|
+
rails g vxml:controller ivr hello_world
|
36
|
+
|
37
|
+
Configure the routes
|
38
|
+
get "hai/hello_world(.:format)"
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rails/generators/erb'
|
2
|
+
|
3
|
+
module Vxml
|
4
|
+
module Generators
|
5
|
+
class ControllerGenerator < Erb::Generators::Base
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
argument :actions, :type => :array, :default => [], :banner => "action action"
|
8
|
+
|
9
|
+
def copy_view_files
|
10
|
+
base_path = File.join("app/views", class_path, file_name)
|
11
|
+
empty_directory base_path
|
12
|
+
|
13
|
+
actions.each do |action|
|
14
|
+
@action = action
|
15
|
+
@path = File.join(base_path, filename_with_extensions(action))
|
16
|
+
template filename_with_extensions(:view), @path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def format
|
22
|
+
:vxml
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/vxml-tools.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# == VXML
|
2
|
+
# === Example
|
3
|
+
# vxml =
|
4
|
+
# VXML.new do |v|
|
5
|
+
# v.prompt "Welcome to All"
|
6
|
+
# v.if_cond "1==1" do |v|
|
7
|
+
# v.prompt "Both are equal"
|
8
|
+
# end
|
9
|
+
# end
|
10
|
+
# vxml.to_s
|
11
|
+
#
|
12
|
+
# ( or )
|
13
|
+
#
|
14
|
+
# vxml = VXML.new
|
15
|
+
# vxml.prompt "Welcome to All"
|
16
|
+
# ifbk = vxml.if_cond "1=="
|
17
|
+
# ifbk.prompt "Both are equal"
|
18
|
+
# vxml.to_s
|
19
|
+
#
|
20
|
+
class VXML
|
21
|
+
def initialize( tag = 'vxml', options = { :version => "2.0", :xmlns =>"http://www.w3.org/2001/vxml" }, &block )
|
22
|
+
@tag = tag
|
23
|
+
@options = options
|
24
|
+
@contents = []
|
25
|
+
if( block )
|
26
|
+
block.call(self)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def options
|
31
|
+
@options
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_s
|
35
|
+
"<#{@tag}#{process_options}>#{process_content}</#{@tag}>"
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_vxml
|
39
|
+
'<?xml version="1.0"?>' + self.to_s
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_xml
|
43
|
+
self.to_vxml
|
44
|
+
end
|
45
|
+
|
46
|
+
def process_options
|
47
|
+
if( @options.size > 0 )
|
48
|
+
" " + @options.collect{|key,val|
|
49
|
+
"#{key}=\"#{val}\""
|
50
|
+
}.join(" ")
|
51
|
+
else
|
52
|
+
""
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def process_content
|
57
|
+
@contents.collect{|cont|
|
58
|
+
cont.to_s
|
59
|
+
}.join("")
|
60
|
+
end
|
61
|
+
|
62
|
+
def string( str )
|
63
|
+
push( str )
|
64
|
+
end
|
65
|
+
|
66
|
+
def push( obj )
|
67
|
+
@contents.push( obj )
|
68
|
+
obj
|
69
|
+
end
|
70
|
+
|
71
|
+
def method_missing( key, *values, &block )
|
72
|
+
keys = key.to_s.split(/_/)
|
73
|
+
tag = keys.shift
|
74
|
+
options = {}
|
75
|
+
|
76
|
+
keys.each{|key|
|
77
|
+
options[key] = values.shift
|
78
|
+
}
|
79
|
+
|
80
|
+
v = VXML.new( tag, options )
|
81
|
+
values.each{|val|
|
82
|
+
if( val.is_a? Hash )
|
83
|
+
v.options.merge! val
|
84
|
+
else
|
85
|
+
v.string val
|
86
|
+
end
|
87
|
+
}
|
88
|
+
|
89
|
+
if( block )
|
90
|
+
block.call( v )
|
91
|
+
end
|
92
|
+
|
93
|
+
push( v )
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
data/lib/vxml_tools.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'vxml-tools'
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vxml-tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Mohammed Siddick.E
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-08-21 00:00:00 +05:30
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Contain vxml library and Rails generators.
|
23
|
+
email: siddick@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- MIT-LICENSE
|
32
|
+
- README.rdoc
|
33
|
+
- lib/vxml-tools.rb
|
34
|
+
- lib/generators/vxml/controller/templates/view.vxml.erb
|
35
|
+
- lib/generators/vxml/controller/controller_generator.rb
|
36
|
+
- lib/vxml-tools/vxml.rb
|
37
|
+
- lib/vxml_tools.rb
|
38
|
+
- config/initializers/mime_types.rb
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://siddick.github.com/vxml-tools/
|
41
|
+
licenses: []
|
42
|
+
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
hash: 57
|
54
|
+
segments:
|
55
|
+
- 1
|
56
|
+
- 8
|
57
|
+
- 7
|
58
|
+
version: 1.8.7
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.3.7
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Tools for the VXML implementation.
|
75
|
+
test_files: []
|
76
|
+
|