rails_sequel 0.0.2 → 0.2.1
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/.document +5 -0
- data/.gitignore +7 -0
- data/LICENSE +20 -0
- data/README.md +9 -9
- data/Rakefile +54 -0
- data/VERSION.yml +4 -0
- data/init.rb +1 -1
- data/lib/rails_sequel.rb +4 -4
- data/lib/rails_sequel/rails_sequel.rb +50 -22
- data/lib/rails_sequel/sequel_ext.rb +2 -2
- data/lib/rails_sequel/version.rb +6 -13
- data/rails_sequel.gemspec +61 -0
- data/spec/config/database.yml +21 -0
- data/spec/rails_sequel_spec.rb +74 -0
- data/spec/sequel_ext_spec.rb +27 -0
- data/spec/spec.opts +8 -0
- data/spec/spec_helper.rb +113 -0
- data/spec/version_spec.rb +9 -0
- data/tasks/sequel.rake +38 -0
- metadata +34 -15
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Piotr Usewicz
|
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.md
CHANGED
@@ -7,27 +7,27 @@ Installation
|
|
7
7
|
### Using Rails plugin script:
|
8
8
|
|
9
9
|
script/plugin install git://github.com/pusewicz/rails_sequel.git
|
10
|
-
|
10
|
+
|
11
11
|
### Using Rails 2.1 Gem dependencies
|
12
|
-
|
12
|
+
|
13
13
|
Install the gem
|
14
|
-
|
14
|
+
|
15
15
|
gem sources -a http://gems.github.com
|
16
16
|
gem install pusewicz-rails_sequel
|
17
|
-
|
17
|
+
|
18
18
|
Load the gem in `environment.rb`
|
19
|
-
|
19
|
+
|
20
20
|
Rails::Initializer.run do |config|
|
21
|
-
config.gem 'pusewicz-rails_sequel', :
|
21
|
+
config.gem 'pusewicz-rails_sequel', :lib => 'rails_sequel', :source => 'http://gems.github.com'
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
Optional
|
25
25
|
--------
|
26
26
|
|
27
27
|
Remove ActiveRecord framework in `environment.rb` file:
|
28
|
-
|
28
|
+
|
29
29
|
config.frameworks -= [ :active_record ]
|
30
|
-
|
30
|
+
|
31
31
|
Community
|
32
32
|
=========
|
33
33
|
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "rails_sequel"
|
8
|
+
gem.summary = "Sequel plugin for Ruby on Rails"
|
9
|
+
gem.description = "rails_sequel allows you to quickly use Sequel Toolkit as your ORM in Ruby on Rails"
|
10
|
+
gem.email = "piotr@layer22.com"
|
11
|
+
gem.homepage = "http://github.com/pusewicz/rails_sequel"
|
12
|
+
gem.authors = ["Piotr Usewicz"]
|
13
|
+
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'spec/rake/spectask'
|
22
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
|
+
spec.libs << 'lib' << 'spec'
|
24
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
25
|
+
spec.spec_opts = %w("--color")
|
26
|
+
end
|
27
|
+
|
28
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
+
spec.libs << 'lib' << 'spec'
|
30
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
spec.rcov = true
|
32
|
+
spec.rcov_opts = if PLATFORM =~ /darwin/
|
33
|
+
['--exclude "gems/*,spec_helper.rb"']
|
34
|
+
else
|
35
|
+
['--exclude "rubygems/*,spec_helper.rb"']
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
if File.exist?('VERSION.yml')
|
44
|
+
config = YAML.load(File.read('VERSION.yml'))
|
45
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
46
|
+
else
|
47
|
+
version = ""
|
48
|
+
end
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "rails_sequel #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
data/VERSION.yml
ADDED
data/init.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'rails_sequel'
|
data/lib/rails_sequel.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
gem 'sequel'
|
2
2
|
require 'sequel'
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
4
|
+
require 'rails_sequel/rails_sequel'
|
5
|
+
require 'rails_sequel/version'
|
6
|
+
require 'rails_sequel/sequel_ext'
|
7
7
|
|
8
|
-
|
8
|
+
RailsSequel.connect
|
@@ -1,27 +1,55 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
Sequel.connect uri, :loggers => [Rails.logger]
|
1
|
+
module RailsSequel
|
2
|
+
|
3
|
+
# Connects to database using constructed Database Connection URI
|
4
|
+
def self.connect
|
5
|
+
connection = Sequel.connect(options = self.prepare_options)
|
6
|
+
if options[:adapter] == 'mysql'
|
7
|
+
connection.execute("SET SQL_AUTO_IS_NULL=0")
|
9
8
|
end
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
connection
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns loaded database.yml configuration for current environment
|
13
|
+
def self.config
|
14
|
+
@config ||= YAML::load(ERB.new(IO.read(File.join(Rails.root, "config", "database.yml"))).result)[Rails.env].with_indifferent_access
|
15
|
+
end
|
16
|
+
|
17
|
+
# Resets config
|
18
|
+
def self.reset_config!
|
19
|
+
@config = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
# Constructs Database Connection URI
|
23
|
+
def self.prepare_options
|
24
|
+
options = {}
|
25
|
+
|
26
|
+
# Use SQLite by default
|
27
|
+
options[:adapter] = config[:adapter] || "sqlite"
|
28
|
+
|
29
|
+
# Use localhost as default host
|
30
|
+
options[:host] = config[:host] || config[:hostname] || "localhost"
|
31
|
+
|
32
|
+
# Default user is an empty string. Both username and user keys are supported.
|
33
|
+
options[:user] = config[:username] || config[:user] || ""
|
34
|
+
options[:password] = config[:password] || ""
|
35
|
+
|
36
|
+
# Both encoding and charset options are supported, default is utf8
|
37
|
+
options[:encoding] = config[:encoding] || config[:charset] || "utf8"
|
38
|
+
|
39
|
+
# Default database is hey_dude_configure_your_database
|
40
|
+
options[:database] = config[:database] || "hey_dude_configure_your_database"
|
41
|
+
|
42
|
+
# MSSQL support
|
43
|
+
[:db_type, :socket, :charset, :encoding].each do |var|
|
44
|
+
options[var] = config[var] if config[var]
|
14
45
|
end
|
15
|
-
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
uri << config[:username] if config[:username]
|
20
|
-
uri << ':' << config[:password] if config[:password]
|
21
|
-
uri << '@' if config[:username] || config[:password]
|
22
|
-
uri << ':' << config[:port] if config[:port]
|
23
|
-
uri << (config[:host] || 'localhost')
|
24
|
-
uri << '/' << config[:database]
|
46
|
+
|
47
|
+
# JDBC support
|
48
|
+
[:url, :uri].each do |var|
|
49
|
+
options[var] = config[var] if config[var]
|
25
50
|
end
|
51
|
+
|
52
|
+
options[:loggers] = [Rails.logger]
|
53
|
+
options
|
26
54
|
end
|
27
55
|
end
|
data/lib/rails_sequel/version.rb
CHANGED
@@ -1,15 +1,8 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
STRING = [MAJOR, MINOR, TINY].join('.')
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.version
|
12
|
-
Version::STRING
|
13
|
-
end
|
1
|
+
module RailsSequel
|
2
|
+
# Returns current plugin version
|
3
|
+
def self.version
|
4
|
+
return @version if @version
|
5
|
+
config = YAML.load(File.read(File.join(File.dirname(__FILE__), '../../VERSION.yml')))
|
6
|
+
@version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
14
7
|
end
|
15
8
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rails_sequel}
|
8
|
+
s.version = "0.2.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Piotr Usewicz"]
|
12
|
+
s.date = %q{2009-10-09}
|
13
|
+
s.description = %q{rails_sequel allows you to quickly use Sequel Toolkit as your ORM in Ruby on Rails}
|
14
|
+
s.email = %q{piotr@layer22.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.md",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION.yml",
|
26
|
+
"init.rb",
|
27
|
+
"lib/rails_sequel.rb",
|
28
|
+
"lib/rails_sequel/rails_sequel.rb",
|
29
|
+
"lib/rails_sequel/sequel_ext.rb",
|
30
|
+
"lib/rails_sequel/version.rb",
|
31
|
+
"rails_sequel.gemspec",
|
32
|
+
"spec/config/database.yml",
|
33
|
+
"spec/rails_sequel_spec.rb",
|
34
|
+
"spec/sequel_ext_spec.rb",
|
35
|
+
"spec/spec.opts",
|
36
|
+
"spec/spec_helper.rb",
|
37
|
+
"spec/version_spec.rb",
|
38
|
+
"tasks/sequel.rake"
|
39
|
+
]
|
40
|
+
s.homepage = %q{http://github.com/pusewicz/rails_sequel}
|
41
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = %q{1.3.5}
|
44
|
+
s.summary = %q{Sequel plugin for Ruby on Rails}
|
45
|
+
s.test_files = [
|
46
|
+
"spec/rails_sequel_spec.rb",
|
47
|
+
"spec/sequel_ext_spec.rb",
|
48
|
+
"spec/spec_helper.rb",
|
49
|
+
"spec/version_spec.rb"
|
50
|
+
]
|
51
|
+
|
52
|
+
if s.respond_to? :specification_version then
|
53
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
54
|
+
s.specification_version = 3
|
55
|
+
|
56
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
57
|
+
else
|
58
|
+
end
|
59
|
+
else
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
test:
|
2
|
+
adapter: sqlite
|
3
|
+
database: db/test.sqlite3
|
4
|
+
|
5
|
+
mysql:
|
6
|
+
adapter: mysql
|
7
|
+
database: henry
|
8
|
+
hostname: john
|
9
|
+
username: piotr
|
10
|
+
password: usewicz
|
11
|
+
charset: brilliant
|
12
|
+
encoding: ascii
|
13
|
+
socket: /var/run/my.socket
|
14
|
+
|
15
|
+
mssql:
|
16
|
+
db_type: sometype
|
17
|
+
|
18
|
+
test_mysql:
|
19
|
+
adapter: mysql
|
20
|
+
database: mysql
|
21
|
+
user: root
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
require 'rails_sequel'
|
3
|
+
|
4
|
+
describe RailsSequel do
|
5
|
+
it "can reset config" do
|
6
|
+
RailsSequel.config.should_not be_nil
|
7
|
+
RailsSequel.config.should == RailsSequel.instance_variable_get(:@config)
|
8
|
+
RailsSequel.reset_config!
|
9
|
+
RailsSequel.instance_variable_get(:@config).should be_nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe RailsSequel, '#config' do
|
14
|
+
before(:each) do
|
15
|
+
RailsSequel.reset_config!
|
16
|
+
end
|
17
|
+
|
18
|
+
it "reads values for current environment" do
|
19
|
+
RailsSequel.config.should == {
|
20
|
+
"adapter" => 'sqlite',
|
21
|
+
"database" => 'db/test.sqlite3'
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "MySQL" do
|
26
|
+
it "recognizes database options" do
|
27
|
+
Rails.stub!(:env).and_return("mysql")
|
28
|
+
RailsSequel.config.should == {
|
29
|
+
"adapter" => "mysql",
|
30
|
+
"database" => "henry",
|
31
|
+
"hostname" => "john",
|
32
|
+
"username" => "piotr",
|
33
|
+
"password" => "usewicz",
|
34
|
+
"charset" =>"brilliant",
|
35
|
+
"encoding" => "ascii",
|
36
|
+
"socket" => "/var/run/my.socket"
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "MSSQL" do
|
42
|
+
it "recognizes database options" do
|
43
|
+
Rails.stub!(:env).and_return("mssql")
|
44
|
+
RailsSequel.config.should == {
|
45
|
+
"db_type" => "sometype"
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe RailsSequel, "#connect" do
|
52
|
+
before(:each) do
|
53
|
+
RailsSequel.reset_config!
|
54
|
+
end
|
55
|
+
|
56
|
+
it "returns connection" do
|
57
|
+
Sequel.stub!(:connect).and_return(MODEL_DB)
|
58
|
+
RailsSequel.connect.should == MODEL_DB
|
59
|
+
end
|
60
|
+
|
61
|
+
it "connects with configuration loaded from file" do
|
62
|
+
options = RailsSequel.prepare_options
|
63
|
+
RailsSequel.should_receive(:prepare_options).and_return(options)
|
64
|
+
Sequel.should_receive(:connect).with(options)
|
65
|
+
RailsSequel.connect
|
66
|
+
end
|
67
|
+
|
68
|
+
it "sets SQL_AUTO_IS_NULL if adapter is MySQL" do
|
69
|
+
Rails.stub!(:env).and_return('test_mysql')
|
70
|
+
Sequel.stub!(:connect).and_return(MODEL_DB)
|
71
|
+
RailsSequel.connect
|
72
|
+
MODEL_DB.sqls.should include("SET SQL_AUTO_IS_NULL=0")
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
require 'rails_sequel/sequel_ext'
|
3
|
+
|
4
|
+
class TestModel < Sequel::Model
|
5
|
+
end
|
6
|
+
|
7
|
+
describe Sequel::Model, '#id' do
|
8
|
+
before(:all) do
|
9
|
+
@model = TestModel.create
|
10
|
+
end
|
11
|
+
|
12
|
+
it "to_params returns id as a string" do
|
13
|
+
@model.to_param.should == '1'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe Sequel::Model, '#new_record?' do
|
18
|
+
before(:all) do
|
19
|
+
@model = TestModel.new
|
20
|
+
end
|
21
|
+
|
22
|
+
it "behaves like new?" do
|
23
|
+
@model.new_record?.should === @model.new?
|
24
|
+
@model.save
|
25
|
+
@model.new_record?.should === @model.new?
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'erb'
|
3
|
+
require 'rr'
|
4
|
+
require 'spec'
|
5
|
+
require 'sequel'
|
6
|
+
require 'active_support/core_ext' # HashWithIndifferentAccess
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
9
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
10
|
+
|
11
|
+
Spec::Runner.configure do |config|
|
12
|
+
# config.mock_with :rr
|
13
|
+
end
|
14
|
+
|
15
|
+
class MockDataset < Sequel::Dataset
|
16
|
+
def insert(*args)
|
17
|
+
@db.execute insert_sql(*args)
|
18
|
+
end
|
19
|
+
|
20
|
+
def update(*args)
|
21
|
+
@db.execute update_sql(*args)
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete(*args)
|
25
|
+
@db.execute delete_sql(*args)
|
26
|
+
end
|
27
|
+
|
28
|
+
def fetch_rows(sql)
|
29
|
+
return if sql =~ /information_schema/
|
30
|
+
@db.execute(sql)
|
31
|
+
yield({:id => 1, :x => 1})
|
32
|
+
end
|
33
|
+
|
34
|
+
def quoted_identifier(c)
|
35
|
+
"\"#{c}\""
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class MockDatabase < Sequel::Database
|
40
|
+
@@quote_identifiers = false
|
41
|
+
self.identifier_input_method = nil
|
42
|
+
self.identifier_output_method = nil
|
43
|
+
attr_reader :sqls
|
44
|
+
|
45
|
+
def execute(sql, opts={})
|
46
|
+
@sqls ||= []
|
47
|
+
@sqls << sql
|
48
|
+
end
|
49
|
+
|
50
|
+
def reset
|
51
|
+
@sqls = []
|
52
|
+
end
|
53
|
+
|
54
|
+
def schema(table_name, opts)
|
55
|
+
if table_name
|
56
|
+
[[:id, {:primary_key=>true}]]
|
57
|
+
else
|
58
|
+
{table_name=>[[:id, {:primary_key=>true}]]}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def transaction(opts={})
|
63
|
+
return yield if @transactions.include?(Thread.current)
|
64
|
+
execute('BEGIN')
|
65
|
+
begin
|
66
|
+
@transactions << Thread.current
|
67
|
+
yield
|
68
|
+
rescue Exception => e
|
69
|
+
execute('ROLLBACK')
|
70
|
+
transaction_error(e)
|
71
|
+
ensure
|
72
|
+
unless e
|
73
|
+
execute('COMMIT')
|
74
|
+
end
|
75
|
+
@transactions.delete(Thread.current)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def dataset(opts=nil); MockDataset.new(self, opts); end
|
80
|
+
end
|
81
|
+
|
82
|
+
class << Sequel::Model
|
83
|
+
alias orig_columns columns
|
84
|
+
def columns(*cols)
|
85
|
+
return if cols.empty?
|
86
|
+
define_method(:columns){cols}
|
87
|
+
@dataset.instance_variable_set(:@columns, cols) if @dataset
|
88
|
+
def_column_accessor(*cols)
|
89
|
+
@columns = cols
|
90
|
+
@db_schema = {}
|
91
|
+
cols.each{|c| @db_schema[c] = {}}
|
92
|
+
end
|
93
|
+
def simple_table
|
94
|
+
nil
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
module Rails
|
99
|
+
def self.root
|
100
|
+
File.dirname(__FILE__)
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.env
|
104
|
+
'test'
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.logger
|
108
|
+
Logger.new(STDOUT)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
Sequel::Model.use_transactions = false
|
113
|
+
Sequel::Model.db = MODEL_DB = MockDatabase.new
|
data/tasks/sequel.rake
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Usage:
|
2
|
+
#
|
3
|
+
# rake sequel:migrate
|
4
|
+
# rake sequel:migrate VERSION=0
|
5
|
+
# rake sequel:migrate VERSION=3
|
6
|
+
#
|
7
|
+
desc 'Sequel migration'
|
8
|
+
namespace :sequel do
|
9
|
+
def path
|
10
|
+
File.join(RAILS_ROOT, 'db', 'migrate')
|
11
|
+
end
|
12
|
+
|
13
|
+
namespace :migrate do
|
14
|
+
desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x'
|
15
|
+
task :redo => [ 'sequel:rollback', 'sequel:migrate' ]
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
|
19
|
+
task :migrate => :environment do
|
20
|
+
if ENV['VERSION']
|
21
|
+
Sequel::Migrator.apply(Sequel::Model.db, path, ENV['VERSION'].to_i)
|
22
|
+
else
|
23
|
+
Sequel::Migrator.apply(Sequel::Model.db, path)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n'
|
28
|
+
task :rollback => :environment do
|
29
|
+
step = ENV['STEP'] ? ENV['STEP'].to_i : 1
|
30
|
+
version = Sequel::Migrator.get_current_migration_version(Sequel::Model.db) - step
|
31
|
+
Sequel::Migrator.apply(Sequel::Model.db, path, version)
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Retrieves the current schema version number"
|
35
|
+
task :version => :environment do
|
36
|
+
puts "Current version: #{Sequel::Migrator.get_current_migration_version(Sequel::Model.db)}"
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Usewicz
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-09 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -19,20 +19,36 @@ executables: []
|
|
19
19
|
|
20
20
|
extensions: []
|
21
21
|
|
22
|
-
extra_rdoc_files:
|
23
|
-
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
24
25
|
files:
|
26
|
+
- .document
|
27
|
+
- .gitignore
|
28
|
+
- LICENSE
|
29
|
+
- README.md
|
30
|
+
- Rakefile
|
31
|
+
- VERSION.yml
|
32
|
+
- init.rb
|
33
|
+
- lib/rails_sequel.rb
|
25
34
|
- lib/rails_sequel/rails_sequel.rb
|
26
35
|
- lib/rails_sequel/sequel_ext.rb
|
27
36
|
- lib/rails_sequel/version.rb
|
28
|
-
-
|
29
|
-
-
|
30
|
-
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
37
|
+
- rails_sequel.gemspec
|
38
|
+
- spec/config/database.yml
|
39
|
+
- spec/rails_sequel_spec.rb
|
40
|
+
- spec/sequel_ext_spec.rb
|
41
|
+
- spec/spec.opts
|
42
|
+
- spec/spec_helper.rb
|
43
|
+
- spec/version_spec.rb
|
44
|
+
- tasks/sequel.rake
|
45
|
+
has_rdoc: true
|
46
|
+
homepage: http://github.com/pusewicz/rails_sequel
|
47
|
+
licenses: []
|
35
48
|
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options:
|
51
|
+
- --charset=UTF-8
|
36
52
|
require_paths:
|
37
53
|
- lib
|
38
54
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -50,9 +66,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
66
|
requirements: []
|
51
67
|
|
52
68
|
rubyforge_project:
|
53
|
-
rubygems_version: 1.3.
|
69
|
+
rubygems_version: 1.3.5
|
54
70
|
signing_key:
|
55
|
-
specification_version:
|
71
|
+
specification_version: 3
|
56
72
|
summary: Sequel plugin for Ruby on Rails
|
57
|
-
test_files:
|
58
|
-
|
73
|
+
test_files:
|
74
|
+
- spec/rails_sequel_spec.rb
|
75
|
+
- spec/sequel_ext_spec.rb
|
76
|
+
- spec/spec_helper.rb
|
77
|
+
- spec/version_spec.rb
|