sequella 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7384529f1adb3ceb73ece05ef95bac77c0e4630d
4
+ data.tar.gz: ca6f06a1dae2217a1723b10b3580d4f3e3ce7273
5
+ SHA512:
6
+ metadata.gz: 95d1fe5b1d672b7c43a848b7ef4c57aeece638a4e812ae6afc480c2e44f0401fadc987fe40edb66b84f5c733d8e1e449718f8e842ce62fe597367175ab0f1446
7
+ data.tar.gz: 8b430feb1586b4baefa98e23a4f875ef6594f874caa14ca12429ef952752512b3973b679c420c3fb696f5a20467a3cb74a4c824a2924b8ff126626f4158d619f
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .*.sw*
2
+ .DS_Store
3
+ /Gemfile.lock
4
+ /coverage
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - jruby-19mode
6
+ - rbx-19mode
7
+ - ruby-head
8
+ notifications:
9
+ irc: "irc.freenode.org#adhearsion"
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # [1.0.0](https://github.com/bklang/sequella/tags/v1.0.0) - [2013-05-20](https://rubygems.org/gems/sequella/versions/1.0.0)
2
+
3
+ * Initial release
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/README.md ADDED
@@ -0,0 +1,16 @@
1
+ Sequella
2
+ ==========================
3
+
4
+ An Adhearsion plugin providing integration with the [Sequel ORM](http://sequel.rubyforge.org)
5
+
6
+
7
+ Configuration
8
+ -------------
9
+
10
+ As with all Adhearsion plugins, type `rake config:show` to see the list of configuration options.
11
+
12
+
13
+ Migrations
14
+ ----------
15
+
16
+ Database migrations that reside in the directory 'db/migrations' may be executed via Rake using `rake sequella:migrate`
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
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
data/TODO.md ADDED
@@ -0,0 +1,5 @@
1
+ TODO
2
+ ====
3
+
4
+ * Rake task for migrations
5
+ * Generators for DB migrations
data/lib/sequella.rb ADDED
@@ -0,0 +1,4 @@
1
+ module Sequella
2
+ end
3
+ require "sequella/version"
4
+ require "sequella/plugin"
@@ -0,0 +1,38 @@
1
+ require 'sequel'
2
+
3
+ class Sequella::Plugin < Adhearsion::Plugin
4
+ extend ActiveSupport::Autoload
5
+
6
+ autoload :Service, 'sequella/plugin/service'
7
+
8
+ # Configure a database to use Sequel-backed models.
9
+ # See http://sequel.rubyforge.org/rdoc/classes/Sequel/Database.html
10
+ #
11
+ # MySQL options are preconfigured. If you want o use another adapter, make sure to include the
12
+ # required options in your configuration file
13
+ config :sequella do
14
+ adapter 'mysql' , :desc => 'Database adapter. It should be an adapter supported by Sequel'
15
+ database 'test' , :desc => 'Database name'
16
+ username 'admin' , :desc => 'valid database username'
17
+ password '' , :desc => 'valid database password'
18
+ host 'localhost' , :desc => 'host where the database is running'
19
+ port 3306 , :desc => 'port where the database is listening'
20
+ model_paths [] , :desc => 'paths to model files to load', :transform => Proc.new {|v| Array(v)}
21
+ end
22
+
23
+ init :sequella do
24
+ Service.start Adhearsion.config[:sequella]
25
+ end
26
+
27
+ tasks do
28
+ namespace :sequella do
29
+ desc "Run Sequel migrations"
30
+ task :migrate => :environment do
31
+ Service.start Adhearsion.config[:sequella]
32
+ Sequel.extension :migration
33
+ Sequel::Migrator.run Sequella::Plugin::Service.connection, File.join(Adhearsion.root, 'db', 'migrations'), :use_transactions=>true
34
+ puts "Successfully migrated database"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,63 @@
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
+
@@ -0,0 +1,3 @@
1
+ module Sequella
2
+ VERSION = "1.0.0"
3
+ end
data/sequella.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "sequella/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "sequella"
7
+ s.version = Sequella::VERSION
8
+ s.authors = ["Ben Klang"]
9
+ s.email = ["bklang@mojolingo.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Sequel ORM plugin for Adhearsion}
12
+ s.description = %q{This gem provides a plugin for Adhearsion, allowing you to create and use Sequel ORM-based models in your Adhearsion application.}
13
+
14
+ s.rubyforge_project = "sequella"
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<sequel>, [">= 3.40.0"]
23
+
24
+ s.add_development_dependency %q<bundler>, ["~> 1.0"]
25
+ s.add_development_dependency %q<rspec>, ["~> 2.5"]
26
+ s.add_development_dependency %q<rake>, [">= 0"]
27
+ s.add_development_dependency %q<mocha>, [">= 0"]
28
+ s.add_development_dependency %q<guard-rspec>
29
+ s.add_development_dependency %q<simplecov>
30
+ s.add_development_dependency %q<simplecov-rcov>
31
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+ require 'ostruct'
3
+
4
+ describe Sequella::Plugin::Service do
5
+ subject { Sequella::Plugin::Service }
6
+
7
+ describe '#start' do
8
+ it 'should raise if start attempted without an adapter specified' do
9
+ config = OpenStruct.new
10
+ expect { subject.start config }.to raise_error
11
+ end
12
+ end
13
+
14
+ describe '#qualify_path' do
15
+ it 'should not alter a path that begins with "/"' do
16
+ subject.qualify_path('/tmp/foo/bar').should == '/tmp/foo/bar'
17
+ end
18
+
19
+ it 'should prefix the Adhearsion root for relative paths' do
20
+ Adhearsion.should_receive(:root).once.and_return '/path/to/myapp'
21
+ subject.qualify_path('models').should == '/path/to/myapp/models'
22
+ end
23
+ end
24
+
25
+ describe '#require_models' do
26
+ it 'should load all files in a given path' do
27
+ Dir.should_receive(:glob).once.with('/tmp/models/*.rb').and_yield('/tmp/models/foo.rb').and_yield('/tmp/models/bar.rb')
28
+ subject.should_receive(:require).once.ordered.with '/tmp/models/foo.rb'
29
+ subject.should_receive(:require).once.ordered.with '/tmp/models/bar.rb'
30
+ subject.require_models '/tmp/models'
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,27 @@
1
+ require 'adhearsion'
2
+ require 'sequella'
3
+
4
+ unless ENV['SKIP_RCOV']
5
+ require 'simplecov'
6
+ require 'simplecov-rcov'
7
+ class SimpleCov::Formatter::MergedFormatter
8
+ def format(result)
9
+ SimpleCov::Formatter::HTMLFormatter.new.format(result)
10
+ SimpleCov::Formatter::RcovFormatter.new.format(result)
11
+ end
12
+ end
13
+ SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
14
+ SimpleCov.start do
15
+ add_filter "/vendor/"
16
+ add_filter "/spec/"
17
+ end
18
+ end
19
+
20
+ RSpec.configure do |config|
21
+ config.color_enabled = true
22
+ config.tty = true
23
+
24
+ config.filter_run :focus => true
25
+ config.run_all_when_everything_filtered = true
26
+ end
27
+
metadata ADDED
@@ -0,0 +1,201 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sequella
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Klang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: adhearsion
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
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
+ - !ruby/object:Gem::Dependency
42
+ name: sequel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 3.40.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 3.40.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '2.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '2.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: mocha
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
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
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov-rcov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: This gem provides a plugin for Adhearsion, allowing you to create and
154
+ use Sequel ORM-based models in your Adhearsion application.
155
+ email:
156
+ - bklang@mojolingo.com
157
+ executables: []
158
+ extensions: []
159
+ extra_rdoc_files: []
160
+ files:
161
+ - .gitignore
162
+ - .travis.yml
163
+ - CHANGELOG.md
164
+ - Gemfile
165
+ - README.md
166
+ - Rakefile
167
+ - TODO.md
168
+ - lib/sequella.rb
169
+ - lib/sequella/plugin.rb
170
+ - lib/sequella/plugin/service.rb
171
+ - lib/sequella/version.rb
172
+ - sequella.gemspec
173
+ - spec/sequella/plugin/service_spec.rb
174
+ - spec/spec_helper.rb
175
+ homepage: ''
176
+ licenses: []
177
+ metadata: {}
178
+ post_install_message:
179
+ rdoc_options: []
180
+ require_paths:
181
+ - lib
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - '>='
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ required_rubygems_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - '>='
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ requirements: []
193
+ rubyforge_project: sequella
194
+ rubygems_version: 2.0.3
195
+ signing_key:
196
+ specification_version: 4
197
+ summary: Sequel ORM plugin for Adhearsion
198
+ test_files:
199
+ - spec/sequella/plugin/service_spec.rb
200
+ - spec/spec_helper.rb
201
+ has_rdoc: