virginia 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e78625ca5438a949387b62c725e94cfc029a518
4
- data.tar.gz: b0d1bcc626e5e5a25309fb831d25184e74c54351
3
+ metadata.gz: 03c11488de9354f94fb4fddaafc9eea6edb2ea2a
4
+ data.tar.gz: ef033861cbc75a27ab882d791609966120516376
5
5
  SHA512:
6
- metadata.gz: 9934bf594319287b9d00e85956e4c69766ca4d14da5246b36c7ef7578b9873b15f4d313a5fc90da998f294872dc69317787b5e9f9ef66778be0a30fa0fcceec9
7
- data.tar.gz: 7d6fc88ad2c32c083b8b34a830a9b85750f94d6ae24b0446f308a6c883c9642018bff5adb9f2df055c1eae0692404ba575e7eaffbd8424c6811b07ece8a2070b
6
+ metadata.gz: 45abb469c15e4dff5e26d2ea886ebe0c147ed404292db70de9466cc4f7fa656d2d4227712e518cde954f8417c924862d7acfa5e689ebd8bdf7133d8eed81d54f
7
+ data.tar.gz: fa7668f83f4194cf48c618337a17201866bb060580efb4ab4113c0882859a6fffe83d7e0c703d324e85f705a0e5c1688c2c85e43085411b5d0508c89e3c3cec9
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  .bundle
2
2
  pkg
3
+ Gemfile.lock
4
+ .*.sw*
@@ -1,4 +1,5 @@
1
- # develop
1
+ # Version 0.3.0
2
+ * Switch to Rackup-style app management
2
3
 
3
4
  # Version 0.2.1
4
5
  * Removed Octarine from dependencies
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Virginia
2
2
 
3
- Virginia is a Reel interface to Adhearsion, named after a dance originating in the 17th century, the Virginia Reel.
3
+ Virginia is a Reel interface to Adhearsion, named after a dance originating in the 17th century, the Virginia Reel. Now your web apps can dance with your voice apps!
4
4
 
5
- It allows you to bundle a simple, Sinatra-style web interface with your Adhearsion application, enabling use of all the available APIs.
5
+ Virginia allows you to bundle a simple web interface in your Adhearsion application. You can use any Rack-compatible framework with Reel.
6
6
 
7
7
  ## Configuration
8
8
 
@@ -10,33 +10,54 @@ The plugin defines three configuration keys.
10
10
 
11
11
  * host: Which IP to bind on (defaults to 0.0.0.0)
12
12
  * port: Which port to listen on (defaults to 8080)
13
- * handler: the Reel::Server 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
-
23
- class RequestHandler
24
- def initialize(host, port)
25
- Reel::Server.supervise(host, port) do |connection|
26
- connection.each_request do |request|
27
- Adhearsion::OutboundCall.originate "SIP/100" do
28
- invoke ConnectingController
29
- end
30
- [200, {}, "200 OK"]
31
- end
32
- end
33
- end
13
+ * rackup: Location of the Rackup configuration file (defaults to config.ru)
14
+
15
+ ## Sinatra Example
16
+
17
+ This example uses Sinatra, but this should work with any Rack-compatible framework.
18
+
19
+ ### Update Gemfile
20
+
21
+ Add the framework gem to your Gemfile, in our case, Sinatra:
22
+
23
+ ```Ruby
24
+ gem 'sinatra'
25
+ ```
26
+
27
+ Don't forget to run `bundle install`.
28
+
29
+ ### Create the app
30
+
31
+ Here is a simple "Hello World" app in Sinatra. Place this in `lib/sinatra_app.rb`:
32
+
33
+ ```Ruby
34
+ require 'sinatra'
35
+
36
+ get '/' do
37
+ 'Hello world!'
38
+ end
34
39
  ```
35
40
 
36
- ### Author
41
+ ### Configure Rack
42
+
43
+ Finally, tell Rack how to start your web app. Place this in `config.ru`:
44
+
45
+ ```Ruby
46
+ require "#{Adhearsion.root}/lib/sinatra_app.rb"
47
+ run Sinatra::Application
48
+ ```
49
+
50
+ ### Test the app
51
+
52
+ Start Adhearsion. You should be able to visit `http://localhost:8080/` in your browser and see "Hello world!"
53
+
54
+ ### Contributors
37
55
 
38
56
  Original author: [Luca Pradovera](https://github.com/polysics)
39
57
 
58
+ Contributors:
59
+ * [Ben Klang](https://github.com/bklang)
60
+
40
61
  ### Links
41
62
 
42
63
  * [Adhearsion](http://adhearsion.com)
@@ -55,4 +76,4 @@ Original author: [Luca Pradovera](https://github.com/polysics)
55
76
 
56
77
  ### Copyright
57
78
 
58
- Copyright (c) 2012 Adhearsion Foundation Inc. MIT license (see LICENSE for details).
79
+ Copyright (c) 2012-2014 Adhearsion Foundation Inc. MIT license (see LICENSE for details).
data/Rakefile CHANGED
@@ -1 +1,11 @@
1
+ # encoding: utf-8
1
2
  require "bundler/gem_tasks"
3
+
4
+ require "rspec/core"
5
+ require "rspec/core/rake_task"
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = 'spec/**/*_spec.rb'
8
+ spec.rspec_opts = '--color'
9
+ end
10
+
11
+ task :default => :spec
@@ -1,7 +1,6 @@
1
1
  require "adhearsion"
2
2
  require "active_support/dependencies/autoload"
3
3
  require "virginia/version"
4
- require "virginia/logging_handler"
5
4
  require "virginia/plugin"
6
5
 
7
6
  module Virginia
@@ -1,15 +1,17 @@
1
+ # encoding: utf-8
2
+
1
3
  module Virginia
2
4
  class Plugin < Adhearsion::Plugin
3
5
 
4
- init :virginia do
5
- logger.warn "Virginia has been loaded"
6
+ run :virginia do
7
+ logger.info "Virginia has been loaded"
6
8
  Service.start
7
9
  end
8
10
 
9
11
  config :virginia do
10
12
  host "0.0.0.0", :desc => "IP to bind the listener to"
11
13
  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."
14
+ rackup 'config.ru', desc: 'Rack configuration file (relative to Adhearsion application root)'
13
15
  end
14
16
  end
15
17
  end
@@ -1,9 +1,25 @@
1
+ # encoding: utf-8
1
2
  require 'reel'
3
+ require 'reel/rack'
2
4
 
3
5
  module Virginia
4
6
  class Service
5
7
  def self.start
6
- Adhearsion.config[:virginia].handler.new Adhearsion.config[:virginia].host, Adhearsion.config[:virginia].port
8
+ config = Adhearsion.config.virginia
9
+
10
+ # Rack-compatible options
11
+ app, options = ::Rack::Builder.parse_file File.join(Adhearsion.root, config[:rackup])
12
+ options = {
13
+ Host: config[:host],
14
+ Port: config[:port]
15
+ }.merge(options)
16
+
17
+ app = Rack::CommonLogger.new(app, Adhearsion.logger)
18
+ supervisor = ::Reel::Rack::Server.supervise_as(:reel_rack_server, app, options)
19
+
20
+ Adhearsion::Events.register_callback :shutdown do
21
+ supervisor.terminate
22
+ end
7
23
  end
8
24
  end
9
25
  end
@@ -1,3 +1,3 @@
1
1
  module Virginia
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1 @@
1
+ run TestApp
@@ -6,17 +6,24 @@ describe Virginia::Service do
6
6
  end
7
7
  end
8
8
 
9
- let(:host) { "127.0.0.1" }
10
- let(:port) { 8989 }
11
- let(:handler) { DummyHandler }
9
+ let(:host) { "127.0.0.1" }
10
+ let(:port) { 8989 }
11
+ let(:options) { {Host: host, Port: port} }
12
+
12
13
  before :each do
13
- Adhearsion.config.virginia.host = host
14
- Adhearsion.config.virginia.port = port
15
- Adhearsion.config.virginia.handler = handler
14
+ Adhearsion.stub(:root).and_return '.'
15
+ Adhearsion.config.virginia.host = host
16
+ Adhearsion.config.virginia.port = port
17
+ Adhearsion.config.virginia.rackup = 'spec/fixtures/config.ru'
16
18
  end
17
19
 
18
20
  it "should instantiate the handler" do
19
- handler.should_receive(:new).with(host, port)
21
+ rack_logger = mock 'Rack::CommonLogger'
22
+ ::Rack::CommonLogger.should_receive(:new).once.with(TestApp, Adhearsion.logger).and_return rack_logger
23
+ ::Reel::Rack::Server.should_receive(:supervise_as).once.with(:reel_rack_server, rack_logger, options)
20
24
  Virginia::Service.start
21
25
  end
22
26
  end
27
+
28
+ class TestApp
29
+ end
@@ -19,7 +19,8 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.add_runtime_dependency %q<adhearsion>, ["~> 2.4"]
21
21
  s.add_runtime_dependency %q<activesupport>, [">= 3.0"]
22
- s.add_runtime_dependency %q<reel>
22
+ s.add_runtime_dependency %q<reel>, ["~> 0.5.0"]
23
+ s.add_runtime_dependency %q<reel-rack>
23
24
 
24
25
  s.add_development_dependency %q<bundler>, ["~> 1.0"]
25
26
  s.add_development_dependency %q<rspec>, ["~> 2.5"]
metadata CHANGED
@@ -1,111 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virginia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Pradovera
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-18 00:00:00.000000000 Z
11
+ date: 2014-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: adhearsion
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: reel
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.5.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.5.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: reel-rack
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - '>='
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ~>
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
75
  version: '1.0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ~>
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '1.0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rspec
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - ~>
87
+ - - "~>"
74
88
  - !ruby/object:Gem::Version
75
89
  version: '2.5'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - ~>
94
+ - - "~>"
81
95
  - !ruby/object:Gem::Version
82
96
  version: '2.5'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rake
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - '>='
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - '>='
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: guard-rspec
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - '>='
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - '>='
122
+ - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  description: Gives an Adhearsion app the ability to be controlled and interact over
@@ -116,19 +130,18 @@ executables: []
116
130
  extensions: []
117
131
  extra_rdoc_files: []
118
132
  files:
119
- - .gitignore
133
+ - ".gitignore"
120
134
  - CHANGELOG.md
121
135
  - Gemfile
122
- - Gemfile.lock
123
136
  - Guardfile
124
137
  - LICENSE.txt
125
138
  - README.md
126
139
  - Rakefile
127
140
  - lib/virginia.rb
128
- - lib/virginia/logging_handler.rb
129
141
  - lib/virginia/plugin.rb
130
142
  - lib/virginia/service.rb
131
143
  - lib/virginia/version.rb
144
+ - spec/fixtures/config.ru
132
145
  - spec/spec_helper.rb
133
146
  - spec/virginia/service_spec.rb
134
147
  - tmp/dsl.rb
@@ -143,20 +156,21 @@ require_paths:
143
156
  - lib
144
157
  required_ruby_version: !ruby/object:Gem::Requirement
145
158
  requirements:
146
- - - '>='
159
+ - - ">="
147
160
  - !ruby/object:Gem::Version
148
161
  version: '0'
149
162
  required_rubygems_version: !ruby/object:Gem::Requirement
150
163
  requirements:
151
- - - '>='
164
+ - - ">="
152
165
  - !ruby/object:Gem::Version
153
166
  version: '0'
154
167
  requirements: []
155
168
  rubyforge_project: virginia
156
- rubygems_version: 2.1.9
169
+ rubygems_version: 2.2.2
157
170
  signing_key:
158
171
  specification_version: 4
159
172
  summary: A Reel interface to Adhearsion
160
173
  test_files:
174
+ - spec/fixtures/config.ru
161
175
  - spec/spec_helper.rb
162
176
  - spec/virginia/service_spec.rb
@@ -1,162 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- virginia (0.2.1)
5
- activesupport (>= 3.0)
6
- adhearsion (~> 2.4)
7
- reel
8
-
9
- GEM
10
- remote: http://rubygems.org/
11
- specs:
12
- activesupport (4.0.0)
13
- i18n (~> 0.6, >= 0.6.4)
14
- minitest (~> 4.2)
15
- multi_json (~> 1.3)
16
- thread_safe (~> 0.1)
17
- tzinfo (~> 0.3.37)
18
- adhearsion (2.4.0)
19
- activesupport (>= 3.0.0, < 5.0.0)
20
- adhearsion-loquacious (~> 1.9)
21
- bundler (~> 1.0)
22
- celluloid (~> 0.14)
23
- countdownlatch
24
- deep_merge
25
- ffi (~> 1.0)
26
- girl_friday
27
- has-guarded-handlers (~> 1.5)
28
- logging (~> 1.8)
29
- pry
30
- punchblock (~> 2.0)
31
- rake
32
- ruby_speech (~> 2.0)
33
- thor (~> 0.18.0)
34
- adhearsion-loquacious (1.9.3)
35
- atomic (1.1.14)
36
- backports (3.3.5)
37
- blather (0.8.8)
38
- activesupport (>= 2.3.11)
39
- eventmachine (>= 1.0.0)
40
- girl_friday
41
- niceogiri (~> 1.0)
42
- nokogiri (~> 1.5, >= 1.5.6)
43
- celluloid (0.15.2)
44
- timers (~> 1.1.0)
45
- celluloid-io (0.15.0)
46
- celluloid (>= 0.15.0)
47
- nio4r (>= 0.5.0)
48
- coderay (1.0.9)
49
- connection_pool (1.1.0)
50
- countdownlatch (1.0.0)
51
- deep_merge (1.0.0)
52
- descendants_tracker (0.0.3)
53
- diff-lcs (1.2.4)
54
- eventmachine (1.0.3)
55
- ffi (1.9.0)
56
- formatador (0.2.4)
57
- future-resource (1.1.0)
58
- girl_friday (0.11.2)
59
- connection_pool (~> 1.0)
60
- rubinius-actor
61
- guard (2.1.1)
62
- formatador (>= 0.2.4)
63
- listen (~> 2.1)
64
- lumberjack (~> 1.0)
65
- pry (>= 0.9.12)
66
- thor (>= 0.18.1)
67
- guard-rspec (4.0.3)
68
- guard (>= 2.1.1)
69
- rspec (~> 2.14)
70
- has-guarded-handlers (1.5.0)
71
- http (0.5.0)
72
- http_parser.rb
73
- http_parser.rb (0.6.0.beta.2)
74
- i18n (0.6.5)
75
- json (1.8.1)
76
- listen (2.1.1)
77
- celluloid (>= 0.15.2)
78
- rb-fsevent (>= 0.9.3)
79
- rb-inotify (>= 0.9)
80
- little-plugger (1.1.3)
81
- logging (1.8.1)
82
- little-plugger (>= 1.1.3)
83
- multi_json (>= 1.3.6)
84
- lumberjack (1.0.4)
85
- method_source (0.8.2)
86
- mini_portile (0.5.1)
87
- minitest (4.7.5)
88
- multi_json (1.8.2)
89
- niceogiri (1.1.2)
90
- nokogiri (~> 1.5)
91
- nio4r (0.5.0)
92
- nokogiri (1.6.0)
93
- mini_portile (~> 0.5.0)
94
- pry (0.9.12.2)
95
- coderay (~> 1.0.5)
96
- method_source (~> 0.8)
97
- slop (~> 3.4)
98
- punchblock (2.0.2)
99
- activesupport (>= 3.0.0, < 5.0.0)
100
- blather (>= 0.7.0)
101
- celluloid (~> 0.14)
102
- future-resource (~> 1.0)
103
- has-guarded-handlers (~> 1.5)
104
- nokogiri (~> 1.5, >= 1.5.6)
105
- ruby_ami (~> 2.0)
106
- ruby_fs (~> 1.1)
107
- ruby_jid (~> 1.0)
108
- ruby_speech (~> 2.0)
109
- state_machine (~> 1.0)
110
- virtus (~> 0.5)
111
- rake (10.1.0)
112
- rb-fsevent (0.9.3)
113
- rb-inotify (0.9.2)
114
- ffi (>= 0.5.0)
115
- reel (0.4.0)
116
- celluloid (>= 0.15.1)
117
- celluloid-io (>= 0.15.0)
118
- http (>= 0.5.0)
119
- http_parser.rb (>= 0.6.0.beta.2)
120
- websocket_parser (>= 0.1.4)
121
- rspec (2.14.1)
122
- rspec-core (~> 2.14.0)
123
- rspec-expectations (~> 2.14.0)
124
- rspec-mocks (~> 2.14.0)
125
- rspec-core (2.14.6)
126
- rspec-expectations (2.14.3)
127
- diff-lcs (>= 1.1.3, < 2.0)
128
- rspec-mocks (2.14.4)
129
- rubinius-actor (0.0.2)
130
- rubinius-core-api
131
- rubinius-core-api (0.0.1)
132
- ruby_ami (2.1.0)
133
- celluloid-io (~> 0.13)
134
- ruby_fs (1.1.0)
135
- celluloid-io (~> 0.13)
136
- json
137
- ruby_jid (1.0.0)
138
- ruby_speech (2.3.0)
139
- activesupport (>= 3.0.7, < 5.0.0)
140
- nokogiri (~> 1.6)
141
- slop (3.4.6)
142
- state_machine (1.2.0)
143
- thor (0.18.1)
144
- thread_safe (0.1.3)
145
- atomic
146
- timers (1.1.0)
147
- tzinfo (0.3.38)
148
- virtus (0.5.5)
149
- backports (~> 3.3)
150
- descendants_tracker (~> 0.0.1)
151
- websocket_parser (0.1.4)
152
- http
153
-
154
- PLATFORMS
155
- ruby
156
-
157
- DEPENDENCIES
158
- bundler (~> 1.0)
159
- guard-rspec
160
- rake
161
- rspec (~> 2.5)
162
- virginia!
@@ -1,13 +0,0 @@
1
- require 'reel'
2
-
3
- module Virginia
4
- class LoggingHandler
5
- def initialize(host, port)
6
- Reel::Server.supervise(host, port) do |connection|
7
- connection.each_request do |request|
8
- request.respond :ok, "Hello, world!"
9
- end
10
- end
11
- end
12
- end
13
- end