sequella 1.0.0 → 1.0.1

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: 7384529f1adb3ceb73ece05ef95bac77c0e4630d
4
- data.tar.gz: ca6f06a1dae2217a1723b10b3580d4f3e3ce7273
3
+ metadata.gz: adc52d89fdc151212e3bd84bba160ec42288eda8
4
+ data.tar.gz: caa1f464289d2ad9550260c1e496132ab264eaba
5
5
  SHA512:
6
- metadata.gz: 95d1fe5b1d672b7c43a848b7ef4c57aeece638a4e812ae6afc480c2e44f0401fadc987fe40edb66b84f5c733d8e1e449718f8e842ce62fe597367175ab0f1446
7
- data.tar.gz: 8b430feb1586b4baefa98e23a4f875ef6594f874caa14ca12429ef952752512b3973b679c420c3fb696f5a20467a3cb74a4c824a2924b8ff126626f4158d619f
6
+ metadata.gz: 7d8c8eaadecbf66a86836ffcfe32c9f564d99bdb1478869e2d64f05393d9ef47939d8ac5c17977f69f57301fccb7afdb4a006f3ed88a6556407e50d7e2db76bf
7
+ data.tar.gz: 19077d991eab0f14bc693e903e8a63136ff2e69dd7632cf11805a60ac572a41bb5ff21631285deeb05b0bb6b0b81565435ddac011f98531d7b238231710f51f5
@@ -1,10 +1,7 @@
1
1
  require 'sequel'
2
+ require 'sequella/service'
2
3
 
3
4
  class Sequella::Plugin < Adhearsion::Plugin
4
- extend ActiveSupport::Autoload
5
-
6
- autoload :Service, 'sequella/plugin/service'
7
-
8
5
  # Configure a database to use Sequel-backed models.
9
6
  # See http://sequel.rubyforge.org/rdoc/classes/Sequel/Database.html
10
7
  #
@@ -30,7 +27,7 @@ class Sequella::Plugin < Adhearsion::Plugin
30
27
  task :migrate => :environment do
31
28
  Service.start Adhearsion.config[:sequella]
32
29
  Sequel.extension :migration
33
- Sequel::Migrator.run Sequella::Plugin::Service.connection, File.join(Adhearsion.root, 'db', 'migrations'), :use_transactions=>true
30
+ Sequel::Migrator.run Sequella::Service.connection, File.join(Adhearsion.root, 'db', 'migrations'), :use_transactions=>true
34
31
  puts "Successfully migrated database"
35
32
  end
36
33
  end
@@ -0,0 +1,64 @@
1
+ module Sequella
2
+ class Service
3
+ cattr_accessor :connection
4
+
5
+ class << self
6
+
7
+ ##
8
+ # Start the Sequel connection with the configured database
9
+ def start(config)
10
+ raise "Must supply an adapter argument to the Sequel configuration" if (config.adapter.nil? || config.adapter.empty?)
11
+
12
+ params = config.to_hash.select { |k,v| !v.nil? }
13
+
14
+ @@connection = establish_connection params
15
+ require_models(*params.delete(:model_paths))
16
+
17
+ # Provide Sequel a handle on the Adhearsion logger
18
+ params[:loggers] = Array(params[:loggers]) << logger
19
+
20
+ create_call_hook_for_connection_cleanup
21
+ end
22
+
23
+ ##
24
+ # Stop the database connection
25
+ def stop
26
+ logger.warn "Todo: Close down Sequel connections"
27
+ end
28
+
29
+ def create_call_hook_for_connection_cleanup
30
+ # There does not seem to be an equivalent in Sequel
31
+ #Adhearsion::Events.punchblock Punchblock::Event::Offer do
32
+ # ::ActiveRecord::Base.verify_active_connections!
33
+ #end
34
+ end
35
+
36
+ def require_models(*paths)
37
+ paths.each do |path|
38
+ path = qualify_path path
39
+ logger.debug "Loading Sequel models from #{path}"
40
+ Dir.glob("#{path}/*.rb") do |model|
41
+ require model
42
+ end
43
+ end
44
+ end
45
+
46
+ def qualify_path(path)
47
+ if path =~ /^\//
48
+ path
49
+ else
50
+ File.join Adhearsion.root, path
51
+ end
52
+ end
53
+
54
+ ##
55
+ # Start the Sequel connection with the configured database
56
+ #
57
+ # @param params [Hash] Options to establish the database connection
58
+ def establish_connection(params)
59
+ ::Sequel.connect params
60
+ end
61
+
62
+ end # class << self
63
+ end # Service
64
+ end
@@ -1,3 +1,3 @@
1
1
  module Sequella
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
18
18
  s.require_paths = ["lib"]
19
19
 
20
20
  s.add_runtime_dependency %q<adhearsion>, ["~> 2.1"]
21
- s.add_runtime_dependency %q<activesupport>, [">= 3.0.10"]
22
21
  s.add_runtime_dependency %q<sequel>, [">= 3.40.0"]
23
22
 
24
23
  s.add_development_dependency %q<bundler>, ["~> 1.0"]
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
  require 'ostruct'
3
3
 
4
- describe Sequella::Plugin::Service do
5
- subject { Sequella::Plugin::Service }
4
+ describe Sequella::Service do
5
+ subject { Sequella::Service }
6
6
 
7
7
  describe '#start' do
8
8
  it 'should raise if start attempted without an adapter specified' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequella
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Klang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-20 00:00:00.000000000 Z
11
+ date: 2013-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: adhearsion
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.1'
27
- - !ruby/object:Gem::Dependency
28
- name: activesupport
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: 3.0.10
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: 3.0.10
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: sequel
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -167,10 +153,10 @@ files:
167
153
  - TODO.md
168
154
  - lib/sequella.rb
169
155
  - lib/sequella/plugin.rb
170
- - lib/sequella/plugin/service.rb
156
+ - lib/sequella/service.rb
171
157
  - lib/sequella/version.rb
172
158
  - sequella.gemspec
173
- - spec/sequella/plugin/service_spec.rb
159
+ - spec/sequella/service_spec.rb
174
160
  - spec/spec_helper.rb
175
161
  homepage: ''
176
162
  licenses: []
@@ -196,6 +182,5 @@ signing_key:
196
182
  specification_version: 4
197
183
  summary: Sequel ORM plugin for Adhearsion
198
184
  test_files:
199
- - spec/sequella/plugin/service_spec.rb
185
+ - spec/sequella/service_spec.rb
200
186
  - spec/spec_helper.rb
201
- has_rdoc:
@@ -1,63 +0,0 @@
1
- class Sequella::Plugin::Service
2
- cattr_accessor :connection
3
-
4
- class << self
5
-
6
- ##
7
- # Start the Sequel connection with the configured database
8
- def start(config)
9
- raise "Must supply an adapter argument to the Sequel configuration" if (config.adapter.nil? || config.adapter.empty?)
10
-
11
- params = config.to_hash.select { |k,v| !v.nil? }
12
-
13
- @@connection = establish_connection params
14
- require_models(*params.delete(:model_paths))
15
-
16
- # Provide Sequel a handle on the Adhearsion logger
17
- params[:loggers] = Array(params[:loggers]) << logger
18
-
19
- create_call_hook_for_connection_cleanup
20
- end
21
-
22
- ##
23
- # Stop the database connection
24
- def stop
25
- logger.warn "Todo: Close down Sequel connections"
26
- end
27
-
28
- def create_call_hook_for_connection_cleanup
29
- # There does not seem to be an equivalent in Sequel
30
- #Adhearsion::Events.punchblock Punchblock::Event::Offer do
31
- # ::ActiveRecord::Base.verify_active_connections!
32
- #end
33
- end
34
-
35
- def require_models(*paths)
36
- paths.each do |path|
37
- path = qualify_path path
38
- logger.debug "Loading Sequel models from #{path}"
39
- Dir.glob("#{path}/*.rb") do |model|
40
- require model
41
- end
42
- end
43
- end
44
-
45
- def qualify_path(path)
46
- if path =~ /^\//
47
- path
48
- else
49
- File.join Adhearsion.root, path
50
- end
51
- end
52
-
53
- ##
54
- # Start the Sequel connection with the configured database
55
- #
56
- # @param params [Hash] Options to establish the database connection
57
- def establish_connection(params)
58
- ::Sequel.connect params
59
- end
60
-
61
- end # class << self
62
- end # Service
63
-