virginia 0.1.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/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # develop
2
+
3
+ # Version 0.1.0
4
+ * First official release
5
+
6
+ # Version 0.0.2
7
+ * Now using Reel::App instead of an explicit handler
8
+
9
+ # Version 0.0.1
10
+ * First version
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in plugin-template.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,155 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ virginia (0.0.2)
5
+ activesupport (>= 3.0.10)
6
+ adhearsion (~> 2.1)
7
+ octarine
8
+ reel
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ activesupport (3.2.12)
14
+ i18n (~> 0.6)
15
+ multi_json (~> 1.0)
16
+ adhearsion (2.2.1)
17
+ activesupport (~> 3.0)
18
+ adhearsion-loquacious (~> 1.9)
19
+ bundler (~> 1.0)
20
+ celluloid (~> 0.12, >= 0.12.1)
21
+ countdownlatch
22
+ deep_merge
23
+ ffi (~> 1.0)
24
+ future-resource (~> 1.0)
25
+ girl_friday
26
+ has-guarded-handlers (~> 1.5)
27
+ logging (~> 1.8)
28
+ pry
29
+ punchblock (~> 1.4)
30
+ rake
31
+ ruby_speech (~> 1.0)
32
+ thor
33
+ adhearsion-loquacious (1.9.3)
34
+ blather (0.8.2)
35
+ activesupport (>= 2.3.11)
36
+ eventmachine (>= 1.0.0)
37
+ girl_friday
38
+ niceogiri (~> 1.0)
39
+ nokogiri (~> 1.5, >= 1.5.6)
40
+ celluloid (0.12.4)
41
+ facter (>= 1.6.12)
42
+ timers (>= 1.0.0)
43
+ celluloid-io (0.12.1)
44
+ celluloid (~> 0.12.0)
45
+ nio4r (>= 0.4.0)
46
+ certified (0.1.1)
47
+ coderay (1.0.8)
48
+ connection_pool (1.0.0)
49
+ countdownlatch (1.0.0)
50
+ deep_merge (1.0.0)
51
+ diff-lcs (1.1.3)
52
+ eventmachine (1.0.0)
53
+ facter (1.6.17)
54
+ ffi (1.3.1)
55
+ future-resource (1.0.0)
56
+ girl_friday (0.11.2)
57
+ connection_pool (~> 1.0)
58
+ rubinius-actor
59
+ guard (1.5.0)
60
+ listen (>= 0.4.2)
61
+ lumberjack (>= 1.0.2)
62
+ pry (>= 0.9.10)
63
+ thor (>= 0.14.6)
64
+ guard-rspec (2.1.0)
65
+ guard (>= 1.1)
66
+ rspec (~> 2.11)
67
+ has-guarded-handlers (1.5.0)
68
+ http (0.4.0)
69
+ certified
70
+ http_parser.rb
71
+ http_parser.rb (0.5.3)
72
+ http_router (0.11.0)
73
+ rack (>= 1.0.0)
74
+ url_mount (~> 0.2.1)
75
+ i18n (0.6.1)
76
+ json (1.7.7)
77
+ listen (0.5.3)
78
+ little-plugger (1.1.3)
79
+ logging (1.8.1)
80
+ little-plugger (>= 1.1.3)
81
+ multi_json (>= 1.3.6)
82
+ lumberjack (1.0.2)
83
+ method_source (0.8.1)
84
+ multi_json (1.6.1)
85
+ niceogiri (1.1.1)
86
+ nokogiri (~> 1.5)
87
+ nio4r (0.4.3)
88
+ nokogiri (1.5.6)
89
+ octarine (0.0.3)
90
+ http_router
91
+ pry (0.9.10)
92
+ coderay (~> 1.0.5)
93
+ method_source (~> 0.8)
94
+ slop (~> 3.3.1)
95
+ punchblock (1.8.0)
96
+ activesupport (~> 3.0)
97
+ blather (>= 0.7.0)
98
+ celluloid (~> 0.12, >= 0.12.4)
99
+ future-resource (~> 1.0)
100
+ has-guarded-handlers (~> 1.5)
101
+ niceogiri (~> 1.1)
102
+ nokogiri (~> 1.5, >= 1.5.6)
103
+ ruby_ami (~> 1.2, >= 1.2.1)
104
+ ruby_fs (~> 1.0)
105
+ ruby_speech (~> 1.0)
106
+ state_machine (~> 1.0)
107
+ rack (1.5.2)
108
+ rake (0.9.2.2)
109
+ reel (0.3.0)
110
+ celluloid-io (>= 0.8.0)
111
+ http (>= 0.2.0)
112
+ http_parser.rb (>= 0.5.3)
113
+ rack (>= 1.4.0)
114
+ websocket_parser (>= 0.1.0)
115
+ rspec (2.11.0)
116
+ rspec-core (~> 2.11.0)
117
+ rspec-expectations (~> 2.11.0)
118
+ rspec-mocks (~> 2.11.0)
119
+ rspec-core (2.11.1)
120
+ rspec-expectations (2.11.3)
121
+ diff-lcs (~> 1.1.3)
122
+ rspec-mocks (2.11.3)
123
+ rubinius-actor (0.0.2)
124
+ rubinius-core-api
125
+ rubinius-core-api (0.0.1)
126
+ ruby_ami (1.3.0)
127
+ celluloid-io (~> 0.12.0)
128
+ countdownlatch (~> 1.0)
129
+ future-resource
130
+ girl_friday
131
+ ruby_fs (1.0.3)
132
+ celluloid-io (~> 0.12.0)
133
+ json
134
+ ruby_speech (1.0.2)
135
+ activesupport (>= 3.0.7)
136
+ niceogiri (~> 1.1, >= 1.1.1)
137
+ nokogiri (~> 1.5, >= 1.5.6)
138
+ slop (3.3.3)
139
+ state_machine (1.1.2)
140
+ thor (0.16.0)
141
+ timers (1.1.0)
142
+ url_mount (0.2.1)
143
+ rack
144
+ websocket_parser (0.1.1)
145
+ http
146
+
147
+ PLATFORMS
148
+ ruby
149
+
150
+ DEPENDENCIES
151
+ bundler (~> 1.0)
152
+ guard-rspec
153
+ rake
154
+ rspec (~> 2.5)
155
+ virginia!
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard 'rspec', :version => 2, :cli => '--format documentation' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec/" }
5
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2012 Adhearsion Foundation Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Virginia
2
+
3
+ Virginia is a Reel interface to Adhearsion, named after a dance originating in the 17th century, the Virginia Reel.
4
+
5
+ It allows you to bundle a simple, Sinatra-style web interface with your Adhearsion application, enabling use of all the available APIs.
6
+
7
+ ## Configuration
8
+
9
+ The plugin defines three configuration keys.
10
+
11
+ * host: Which IP to bind on (defaults to 0.0.0.0)
12
+ * port: Which port to listen on (defaults to 8080)
13
+ * handler: the Reel::App class to use (see below)
14
+
15
+ ## Handler
16
+ Virginia bundles a simple logging handler class that will answer to GET on "/" with OK and prints a log message in the Adhearsion console.
17
+
18
+ An example handler, implementing click-to-call, would be built as follows:
19
+
20
+ ```ruby
21
+ require 'reel'
22
+ require 'reel/app'
23
+
24
+ class RequestHandler
25
+ include Reel::App
26
+ get('/dial') do
27
+ Adhearsion::OutboundCall.originate "SIP/100" do
28
+ invoke ConnectingController
29
+ end
30
+ [200, {}, "200 OK"]
31
+ end
32
+ end
33
+ ```
34
+
35
+ ### Author
36
+
37
+ Original author: [Luca Pradovera](https://github.com/polysics)
38
+
39
+ ### Links
40
+
41
+ * [Adhearsion](http://adhearsion.com)
42
+ * [Source](https://github.com/adhearsion/adhearsion-asterisk)
43
+ * [Documentation](http://rdoc.info/github/adhearsion/adhearsion-asterisk/master/frames)
44
+ * [Bug Tracker](https://github.com/adhearsion/adhearsion-asterisk/issues)
45
+
46
+ ### Note on Patches/Pull Requests
47
+
48
+ * Fork the project.
49
+ * Make your feature addition or bug fix.
50
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
51
+ * Commit, do not mess with rakefile, version, or history.
52
+ * If you want to have your own version, that is fine but bump version in a commit by itself so I can ignore when I pull
53
+ * Send me a pull request. Bonus points for topic branches.
54
+
55
+ ### Copyright
56
+
57
+ Copyright (c) 2012 Adhearsion Foundation Inc. MIT license (see LICENSE for details).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,12 @@
1
+ require 'reel'
2
+ require 'reel/app'
3
+
4
+ module Virginia
5
+ class LoggingHandler
6
+ include Reel::App
7
+ get "/" do
8
+ logger.info "Virginia request received"
9
+ [:ok, "200 OK"]
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ module Virginia
2
+ class Plugin < Adhearsion::Plugin
3
+
4
+ init :virginia do
5
+ logger.warn "Virginia has been loaded"
6
+ Service.start
7
+ end
8
+
9
+ config :virginia do
10
+ host "0.0.0.0", :desc => "IP to bind the listener to"
11
+ port "8080", :desc => "The port to bind the listener to"
12
+ handler Virginia::LoggingHandler, :desc => "The object that will be handling the requests. Must be a Reel:App."
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ require 'reel'
2
+
3
+ module Virginia
4
+ class Service
5
+ def self.start
6
+ Adhearsion.config[:virginia].handler.new Adhearsion.config[:virginia].host, Adhearsion.config[:virginia].port
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Virginia
2
+ VERSION = "0.1.0"
3
+ end
data/lib/virginia.rb ADDED
@@ -0,0 +1,12 @@
1
+ require "adhearsion"
2
+ require "active_support/dependencies/autoload"
3
+ require "virginia/version"
4
+ require "virginia/logging_handler"
5
+ require "virginia/plugin"
6
+
7
+ module Virginia
8
+ extend ActiveSupport::Autoload
9
+ autoload :Plugin
10
+ autoload :Service
11
+ autoload :LoggingHandler
12
+ end
@@ -0,0 +1,11 @@
1
+ require 'adhearsion'
2
+ require 'virginia'
3
+
4
+ RSpec.configure do |config|
5
+ config.color_enabled = true
6
+ config.tty = true
7
+
8
+ config.filter_run :focus => true
9
+ config.run_all_when_everything_filtered = true
10
+ end
11
+
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Virginia::Service do
4
+ class DummyHandler
5
+ def initialize(host, port)
6
+ end
7
+ end
8
+
9
+ let(:host) { "127.0.0.1" }
10
+ let(:port) { 8989 }
11
+ let(:handler) { DummyHandler }
12
+ before :all do
13
+ Adhearsion.config.virginia.host = host
14
+ Adhearsion.config.virginia.port = port
15
+ Adhearsion.config.virginia.handler = handler
16
+ end
17
+
18
+ it "should instantiate the handler" do
19
+ handler.should_receive(:new).with(host, port)
20
+ Virginia::Service.start
21
+ end
22
+ end
data/tmp/dsl.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Virginia
2
+ class Dsl
3
+
4
+ end
5
+ end
data/tmp/example.rb ADDED
@@ -0,0 +1,66 @@
1
+ #Reel::Server.supervise "0.0.0.0", 80 do |connection|
2
+ #while request = connection.request
3
+ #case request
4
+ #when Reel::Request
5
+ #status, body = case request.url
6
+ #when /call_count/
7
+ #[:ok, Adhearsion.active_calls.count]
8
+ #end
9
+ #connection.respond status, body
10
+ #end
11
+ #end
12
+ #end
13
+
14
+ #client = Faraday.new url: 'http://sushi.com'
15
+ #response = client.get '/call_count'
16
+ #response.status # => 200
17
+ #response.body # => 1_235_234
18
+
19
+
20
+ #module Virginia
21
+ #class Dsl
22
+ #def parse(path)
23
+ #keys = []
24
+ #ignore = ""
25
+ #pattern = path.to_str.gsub(/[^\?\%\\\/\:\*\w]/) do |c|
26
+ #ignore << escaped(c).join if c.match(/[\.@]/)
27
+ #encoded(c)
28
+ #end
29
+ #pattern.gsub!(/((:\w+)|\*)/) do |match|
30
+ #if match == "*"
31
+ #keys << 'splat'
32
+ #"(.*?)"
33
+ #else
34
+ #keys << $2[1..-1]
35
+ #"([^#{ignore}/?#]+)"
36
+ #end
37
+ #end
38
+ #[/\A#{pattern}\z/, keys]
39
+ #end
40
+ #end
41
+
42
+ #def process_route(route)
43
+
44
+ #end
45
+
46
+ #end
47
+
48
+
49
+ # def process_route(pattern, keys, conditions, block = nil, values = [])
50
+ #route = @request.path_info
51
+ #route = '/' if route.empty? and not settings.empty_path_info?
52
+ #return unless match = pattern.match(route)
53
+ #values += match.captures.to_a.map { |v| force_encoding URI.decode_www_form_component(v) if v }
54
+
55
+ #if values.any?
56
+ #original, @params = params, params.merge('splat' => [], 'captures' => values)
57
+ #keys.zip(values) { |k,v| Array === @params[k] ? @params[k] << v : @params[k] = v if v }
58
+ #end
59
+
60
+ #catch(:pass) do
61
+ #conditions.each { |c| throw :pass if c.bind(self).call == false }
62
+ #block ? block[self, values] : yield(self, values)
63
+ #end
64
+ #ensure
65
+ #@params = original if original
66
+ #end
data/virginia.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "virginia/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "virginia"
7
+ s.version = Virginia::VERSION
8
+ s.authors = ["Luca Pradovera"]
9
+ s.email = ["lpradovera@mojolingo.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{A Reel interface to Adhearsion}
12
+ s.description = %q{Gives an Adhearsion app the ability to be controlled and interact over HTTP}
13
+
14
+ s.rubyforge_project = "virginia"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_runtime_dependency %q<adhearsion>, ["~> 2.1"]
21
+ s.add_runtime_dependency %q<activesupport>, [">= 3.0.10"]
22
+ s.add_runtime_dependency %q<reel>
23
+ s.add_runtime_dependency %q<octarine>
24
+
25
+ s.add_development_dependency %q<bundler>, ["~> 1.0"]
26
+ s.add_development_dependency %q<rspec>, ["~> 2.5"]
27
+ s.add_development_dependency %q<rake>, [">= 0"]
28
+ s.add_development_dependency %q<guard-rspec>
29
+ end
metadata ADDED
@@ -0,0 +1,195 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: virginia
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Luca Pradovera
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: adhearsion
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: activesupport
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 3.0.10
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 3.0.10
46
+ - !ruby/object:Gem::Dependency
47
+ name: reel
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: octarine
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: bundler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '1.0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '1.0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '2.5'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '2.5'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rake
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: guard-rspec
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ description: Gives an Adhearsion app the ability to be controlled and interact over
143
+ HTTP
144
+ email:
145
+ - lpradovera@mojolingo.com
146
+ executables: []
147
+ extensions: []
148
+ extra_rdoc_files: []
149
+ files:
150
+ - .gitignore
151
+ - CHANGELOG.md
152
+ - Gemfile
153
+ - Gemfile.lock
154
+ - Guardfile
155
+ - LICENSE.txt
156
+ - README.md
157
+ - Rakefile
158
+ - lib/virginia.rb
159
+ - lib/virginia/logging_handler.rb
160
+ - lib/virginia/plugin.rb
161
+ - lib/virginia/service.rb
162
+ - lib/virginia/version.rb
163
+ - spec/spec_helper.rb
164
+ - spec/virginia/service_spec.rb
165
+ - tmp/dsl.rb
166
+ - tmp/example.rb
167
+ - virginia.gemspec
168
+ homepage: ''
169
+ licenses: []
170
+ post_install_message:
171
+ rdoc_options: []
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ none: false
176
+ requirements:
177
+ - - ! '>='
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
+ none: false
182
+ requirements:
183
+ - - ! '>='
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ requirements: []
187
+ rubyforge_project: virginia
188
+ rubygems_version: 1.8.24
189
+ signing_key:
190
+ specification_version: 3
191
+ summary: A Reel interface to Adhearsion
192
+ test_files:
193
+ - spec/spec_helper.rb
194
+ - spec/virginia/service_spec.rb
195
+ has_rdoc: