sequel-rails 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +8 -0
- data/History.md +21 -10
- data/README.md +6 -4
- data/Rakefile +3 -1
- data/lib/sequel_rails.rb +10 -0
- data/lib/sequel_rails/configuration.rb +38 -5
- data/lib/sequel_rails/railties/database.rake +6 -13
- data/lib/sequel_rails/sequel/database/active_support_notification.rb +3 -3
- data/lib/sequel_rails/storage.rb +2 -0
- data/lib/sequel_rails/storage/jdbc.rb +29 -6
- data/lib/sequel_rails/version.rb +1 -1
- data/spec/internal/config/database.yml +1 -1
- data/spec/internal/config/initializers/session.rb +1 -0
- data/spec/lib/sequel_rails/configuration_spec.rb +103 -0
- data/spec/lib/sequel_rails/migrations_spec.rb +1 -1
- data/spec/lib/sequel_rails/railties/log_subscriber_spec.rb +0 -1
- data/spec/spec_helper.rb +1 -1
- data/tasks/spec.rake +20 -11
- metadata +41 -37
data/.travis.yml
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
3
|
- 1.9.3
|
4
|
+
- jruby-18mode
|
5
|
+
- jruby-19mode
|
4
6
|
env:
|
5
7
|
- "TEST_ADAPTER=postgresql TEST_OWNER=postgres TEST_USERNAME=postgres"
|
6
8
|
- "TEST_ADAPTER=mysql TEST_USERNAME=root TEST_ENCODING=utf8"
|
7
9
|
- "TEST_ADAPTER=mysql2 TEST_USERNAME=root TEST_ENCODING=utf8"
|
8
10
|
- "TEST_ADAPTER=sqlite3 TEST_DATABASE=':memory:'"
|
11
|
+
matrix:
|
12
|
+
exclude:
|
13
|
+
- rvm: jruby-18mode
|
14
|
+
env: "TEST_ADAPTER=mysql2 TEST_USERNAME=root TEST_ENCODING=utf8"
|
15
|
+
- rvm: jruby-19mode
|
16
|
+
env: "TEST_ADAPTER=mysql2 TEST_USERNAME=root TEST_ENCODING=utf8"
|
9
17
|
script: "rake spec"
|
10
18
|
notifications:
|
11
19
|
email:
|
data/History.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
0.4.1 (2013-03-12)
|
2
|
+
==================
|
3
|
+
|
4
|
+
* DRY config in rake task and fix usage under JRUBY (Ed Ruder)
|
5
|
+
* Enable JRuby in TravisCI
|
6
|
+
* Run JDBC specs when jruby is detected
|
7
|
+
* Fix problems with JDBC support when running in 1.9 mode
|
8
|
+
* Fix JDBC support for mysql and postgresql and add specs on
|
9
|
+
`SequelRails::Configuration` (Jack Danger Canty)
|
10
|
+
* Rescue exception when dropping database [#20](https://github.com/TalentBox/sequel-rails/issues/20)
|
11
|
+
|
1
12
|
0.4.0 (2013-03-06)
|
2
13
|
==================
|
3
14
|
|
@@ -6,14 +17,14 @@
|
|
6
17
|
* Do not add any Sequel plugin by default anymore. Plugins could not be removed
|
7
18
|
so it is safer to let the user add them via an initializer. Furthermore, we
|
8
19
|
were changing the default Sequel behaviour related to 'raise on save'.
|
9
|
-
All the previous plugins/behaviours of sequel-rails can be restored by
|
20
|
+
All the previous plugins/behaviours of sequel-rails can be restored by
|
10
21
|
creating an initializer with:
|
11
22
|
|
12
23
|
```ruby
|
13
24
|
require "sequel_rails/railties/legacy_model_config"
|
14
25
|
```
|
15
26
|
|
16
|
-
Thanks to @dlee, for raising concerns about this behaviour in
|
27
|
+
Thanks to @dlee, for raising concerns about this behaviour in
|
17
28
|
[#11](https://github.com/TalentBox/sequel-rails/pull/11)
|
18
29
|
|
19
30
|
0.4.0.pre2
|
@@ -22,7 +33,7 @@
|
|
22
33
|
* Remove `rake db:forward` and `rake db:rollback` as it makes not much sense
|
23
34
|
when using the TimeStampMigration which is how this gem generates migrations
|
24
35
|
* Ensure rake tasks returns appropriate code on errors
|
25
|
-
* Ensure PostgreSQL adapter passes the right options to both create and drop
|
36
|
+
* Ensure PostgreSQL adapter passes the right options to both create and drop
|
26
37
|
database (Sascha Cunz)
|
27
38
|
|
28
39
|
0.4.0.pre1
|
@@ -38,14 +49,14 @@
|
|
38
49
|
* **BIG CHANGE** rename `Rails::Sequel` module as `SequelRails`, this becomes
|
39
50
|
the namespace for all sequel-rails related classes.
|
40
51
|
* Split `Rails::Sequel::Storage` class in multiple adapter for each db
|
41
|
-
* Only log queries if logger level is set to :debug (matching ActiveRecord
|
52
|
+
* Only log queries if logger level is set to :debug (matching ActiveRecord
|
42
53
|
default).
|
43
54
|
* Correctly display time spent in models in controller logs.
|
44
|
-
* Add simple `ActiveSupport::Notification` support to Sequel using logger
|
55
|
+
* Add simple `ActiveSupport::Notification` support to Sequel using logger
|
45
56
|
facility. This is done by monkey patching `Sequel::Database#log_yield`, so
|
46
57
|
it does not yield directly if no loggers configured and instrument the yield
|
47
58
|
call. Note that this does not allow to know from which class the query comes
|
48
|
-
from. So it still does not display the `Sequel::Model` subclass like
|
59
|
+
from. So it still does not display the `Sequel::Model` subclass like
|
49
60
|
`ActiveRecord` does (eg: User load).
|
50
61
|
* Add spec for Sequel::Railties::LogSubscriber
|
51
62
|
* Add initial specs for railtie setup
|
@@ -90,7 +101,7 @@
|
|
90
101
|
- `db:drop` don't drop the test db automatically
|
91
102
|
- `db:test:prepare` don't depend on `db:reset` which was loading `db:seed` (Sean Kirby)
|
92
103
|
* Make `rake db:setup` load schema instead of running migrations (Markus Fenske)
|
93
|
-
* Depends on `railties` instead of `rails` to not pull `active_record`
|
104
|
+
* Depends on `railties` instead of `rails` to not pull `active_record`
|
94
105
|
as dependency (Markus Fenske)
|
95
106
|
|
96
107
|
0.3.5
|
@@ -105,11 +116,11 @@
|
|
105
116
|
and uses db types instead of ruby equivalents. This ensure loading the schema
|
106
117
|
file will result in a correct db
|
107
118
|
|
108
|
-
* Map some Sequel specific exceptions to `ActiveRecord` equivalents, in
|
119
|
+
* Map some Sequel specific exceptions to `ActiveRecord` equivalents, in
|
109
120
|
`config.action_dispatch.rescue_responses`. This allows controllers to behave
|
110
121
|
more like `ActiveRecord` when Sequel raises exceptions. (Joshua Hansen)
|
111
|
-
|
112
|
-
* New Sequel plugin added to all `Sequel::Model` which allows to use
|
122
|
+
|
123
|
+
* New Sequel plugin added to all `Sequel::Model` which allows to use
|
113
124
|
`Sequel::Model#find!` which will raise an exception if record does not exists.
|
114
125
|
This method is an alias to `Sequel::Model#[]` method. (Joshua Hansen)
|
115
126
|
|
data/README.md
CHANGED
@@ -37,13 +37,13 @@ Secondly, you'll need to require the different Rails components separately in yo
|
|
37
37
|
|
38
38
|
# Instead of 'rails/all', require these:
|
39
39
|
require "action_controller/railtie"
|
40
|
-
# require "active_record/railtie"
|
40
|
+
# require "active_record/railtie"
|
41
41
|
require "action_mailer/railtie"
|
42
42
|
require "sprockets/railtie"
|
43
43
|
```
|
44
44
|
|
45
45
|
Starting with sequel-rails 0.4.0.pre3 we don't change default Sequel behaviour
|
46
|
-
nor include any plugin by default, if you want to get back the previous
|
46
|
+
nor include any plugin by default, if you want to get back the previous
|
47
47
|
behaviour, you can create a new initializer (eg: `config/initializers/sequel.rb`) with content:
|
48
48
|
|
49
49
|
```ruby
|
@@ -74,7 +74,7 @@ rake db:create[env] # Create the database defined in config/da
|
|
74
74
|
rake db:create:all # Create all the local databases defined in config/database.yml
|
75
75
|
rake db:drop[env] # Create the database defined in config/database.yml for the current Rails.env
|
76
76
|
rake db:drop:all # Drops all the local databases defined in config/database.yml
|
77
|
-
rake db:force_close_open_connections # Forcibly close any open connections to the test database
|
77
|
+
rake db:force_close_open_connections # Forcibly close any open connections to the test database
|
78
78
|
rake db:migrate # Migrate the database to the latest version
|
79
79
|
rake db:migrate:down # Runs the "down" for a given migration VERSION.
|
80
80
|
rake db:migrate:redo # Rollbacks the database one migration and re migrate up.
|
@@ -84,7 +84,7 @@ rake db:reset # Drops and recreates the database from db
|
|
84
84
|
rake db:schema:dump # Create a db/schema.rb file that can be portably used against any DB supported by Sequel
|
85
85
|
rake db:schema:load # Load a schema.rb file into the database
|
86
86
|
rake db:seed # Load the seed data from db/seeds.rb
|
87
|
-
rake db:setup # Create the database, load the schema, and initialize with the seed data
|
87
|
+
rake db:setup # Create the database, load the schema, and initialize with the seed data
|
88
88
|
rake db:test:prepare # Prepare test database (ensure all migrations ran, drop and re-create database then load schema). This task can be run in the same invocation as other task (eg: rake db:migrate db:test:prepare).
|
89
89
|
```
|
90
90
|
|
@@ -124,6 +124,8 @@ Improvements has been made by those awesome contributors:
|
|
124
124
|
* Thiago Pradi (tchandy)
|
125
125
|
* Sascha Cunz (scunz)
|
126
126
|
* Brian Donovan (eventualbuddha)
|
127
|
+
* Jack Danger Canty (JackDanger)
|
128
|
+
* Ed Ruder (edruder)
|
127
129
|
|
128
130
|
Credits
|
129
131
|
=======
|
data/Rakefile
CHANGED
data/lib/sequel_rails.rb
CHANGED
@@ -1,2 +1,12 @@
|
|
1
1
|
require "sequel_rails/version"
|
2
2
|
require "sequel_rails/railtie" if defined? Rails
|
3
|
+
|
4
|
+
module SequelRails
|
5
|
+
def self.jruby?
|
6
|
+
@using_jruby ||= if defined?(RUBY_ENGINE)
|
7
|
+
RUBY_ENGINE == "jruby"
|
8
|
+
else
|
9
|
+
ENV['RUBY_VERSION'].to_s =~ /jruby/
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -5,7 +5,12 @@ module SequelRails
|
|
5
5
|
mattr_accessor :configuration
|
6
6
|
|
7
7
|
def self.setup(environment)
|
8
|
-
|
8
|
+
config = configuration.environment_for(environment.to_s)
|
9
|
+
if config['url']
|
10
|
+
::Sequel.connect config['url'], config
|
11
|
+
else
|
12
|
+
::Sequel.connect config
|
13
|
+
end
|
9
14
|
end
|
10
15
|
|
11
16
|
class Configuration
|
@@ -23,7 +28,7 @@ module SequelRails
|
|
23
28
|
end
|
24
29
|
|
25
30
|
def environments
|
26
|
-
@environments ||=
|
31
|
+
@environments ||= raw.inject({}) do |normalized, environment|
|
27
32
|
name, config = environment.first, environment.last
|
28
33
|
normalized[name] = normalize_repository_config(config)
|
29
34
|
normalized
|
@@ -39,12 +44,12 @@ module SequelRails
|
|
39
44
|
def normalize_repository_config(hash)
|
40
45
|
config = {}
|
41
46
|
hash.each do |key, value|
|
42
|
-
config[key.to_s] =
|
47
|
+
config[key.to_s] =
|
43
48
|
if key.to_s == 'port'
|
44
49
|
value.to_i
|
45
50
|
elsif key.to_s == 'adapter' && value == 'sqlite3'
|
46
51
|
'sqlite'
|
47
|
-
elsif key.to_s == 'database' && (hash['adapter'] == 'sqlite3' ||
|
52
|
+
elsif key.to_s == 'database' && (hash['adapter'] == 'sqlite3' ||
|
48
53
|
hash['adapter'] == 'sqlite' ||
|
49
54
|
hash[:adapter] == 'sqlite3' ||
|
50
55
|
hash[:adapter] == 'sqlite')
|
@@ -55,7 +60,35 @@ module SequelRails
|
|
55
60
|
value
|
56
61
|
end
|
57
62
|
end
|
58
|
-
|
63
|
+
|
64
|
+
# always use jdbc when running jruby
|
65
|
+
if SequelRails.jruby?
|
66
|
+
if config['adapter']
|
67
|
+
case config['adapter'].to_sym
|
68
|
+
when :postgres
|
69
|
+
config['adapter'] = :postgresql
|
70
|
+
end
|
71
|
+
config['adapter'] = "jdbc:#{config['adapter']}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# some adapters only support an url
|
76
|
+
if config['adapter'] && config['adapter'] =~ /^(jdbc|do):/
|
77
|
+
params = {}
|
78
|
+
config.each do |k, v|
|
79
|
+
next if ['adapter', 'host', 'port', 'database'].include?(k)
|
80
|
+
params[k] = v
|
81
|
+
end
|
82
|
+
params_str = params.map { |k, v| "#{k}=#{v}" }.join('&')
|
83
|
+
port = config['port'] ? ":#{config['port']}" : ''
|
84
|
+
config['url'] = case config['adapter']
|
85
|
+
when /sqlite/
|
86
|
+
"%s:%s" % [config['adapter'], config['database']]
|
87
|
+
else
|
88
|
+
"%s://%s%s/%s?%s" % [config['adapter'], config['host'], port, config['database'], params_str]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
59
92
|
config
|
60
93
|
end
|
61
94
|
|
@@ -4,10 +4,7 @@ require 'sequel_rails/storage'
|
|
4
4
|
namespace :db do
|
5
5
|
def db_for_current_env
|
6
6
|
@db_for_current_env ||= {}
|
7
|
-
@db_for_current_env[Rails.env] ||=
|
8
|
-
config = ::SequelRails.configuration.environment_for(Rails.env)
|
9
|
-
::Sequel.connect(config)
|
10
|
-
end
|
7
|
+
@db_for_current_env[Rails.env] ||= ::SequelRails.setup(Rails.env)
|
11
8
|
end
|
12
9
|
|
13
10
|
# desc "Raises an error if there are pending migrations"
|
@@ -23,7 +20,7 @@ namespace :db do
|
|
23
20
|
task :dump => :environment do
|
24
21
|
::Sequel.extension :schema_dumper
|
25
22
|
File.open(ENV['SCHEMA'] || "#{Rails.root}/db/schema.rb", "w") do |file|
|
26
|
-
file.write db_for_current_env.dump_schema_migration(same_db
|
23
|
+
file.write db_for_current_env.dump_schema_migration(:same_db => true)
|
27
24
|
end
|
28
25
|
Rake::Task["db:schema:dump"].reenable
|
29
26
|
end
|
@@ -63,7 +60,7 @@ namespace :db do
|
|
63
60
|
desc 'Drops all the local databases defined in config/database.yml'
|
64
61
|
task :all => :environment do
|
65
62
|
unless SequelRails::Storage.drop_all
|
66
|
-
|
63
|
+
warn "Couldn't drop all databases"
|
67
64
|
end
|
68
65
|
end
|
69
66
|
end
|
@@ -73,7 +70,7 @@ namespace :db do
|
|
73
70
|
args.with_defaults(:env => Rails.env)
|
74
71
|
|
75
72
|
unless SequelRails::Storage.drop_environment(args.env)
|
76
|
-
|
73
|
+
warn "Couldn't drop database for environment #{args.env}"
|
77
74
|
end
|
78
75
|
end
|
79
76
|
|
@@ -134,18 +131,14 @@ namespace :db do
|
|
134
131
|
desc 'Forcibly close any open connections to the current env database (PostgreSQL specific)'
|
135
132
|
task :force_close_open_connections, [:env] => :environment do |t, args|
|
136
133
|
args.with_defaults(:env => Rails.env)
|
137
|
-
SequelRails::Storage.close_connections_environment(
|
134
|
+
SequelRails::Storage.close_connections_environment(args.env)
|
138
135
|
end
|
139
136
|
|
140
137
|
namespace :test do
|
141
138
|
desc "Prepare test database (ensure all migrations ran, drop and re-create database then load schema). This task can be run in the same invocation as other task (eg: rake db:migrate db:test:prepare)."
|
142
139
|
task :prepare => "db:abort_if_pending_migrations" do
|
143
140
|
previous_env, Rails.env = Rails.env, 'test'
|
144
|
-
|
145
|
-
Rake::Task['db:drop'].execute
|
146
|
-
rescue Exception => e
|
147
|
-
$stderr.puts "Could not drop test db: #{e.message}"
|
148
|
-
end
|
141
|
+
Rake::Task['db:drop'].execute
|
149
142
|
Rake::Task['db:create'].execute
|
150
143
|
Rake::Task['db:schema:load'].execute
|
151
144
|
Sequel::DATABASES.each do |db|
|
data/lib/sequel_rails/storage.rb
CHANGED
@@ -64,6 +64,8 @@ module SequelRails
|
|
64
64
|
|
65
65
|
def self.lookup_class(adapter)
|
66
66
|
raise "Adapter not specified in config, please set the :adapter key." unless adapter
|
67
|
+
return Jdbc if adapter =~ /jdbc/
|
68
|
+
|
67
69
|
klass_name = adapter.camelize.to_sym
|
68
70
|
unless self.const_defined?(klass_name)
|
69
71
|
raise "Adapter #{adapter} not supported (#{klass_name.inspect})"
|
@@ -3,34 +3,52 @@ module SequelRails
|
|
3
3
|
class Jdbc < Abstract
|
4
4
|
|
5
5
|
def _is_mysql?
|
6
|
-
|
6
|
+
config['adapter'].match(/^jdbc:mysql/)
|
7
|
+
end
|
8
|
+
|
9
|
+
def _is_postgres?
|
10
|
+
config['adapter'].match(/^jdbc:postgresql/)
|
11
|
+
end
|
12
|
+
|
13
|
+
def _is_sqlite?
|
14
|
+
config['adapter'].match(/^jdbc:sqlite/)
|
7
15
|
end
|
8
16
|
|
9
17
|
def _root_url
|
10
|
-
|
18
|
+
config['url'].scan(/^jdbc:mysql:\/\/\w*:?\d*/).first
|
11
19
|
end
|
12
20
|
|
13
21
|
def db_name
|
14
|
-
database
|
22
|
+
config['database']
|
15
23
|
end
|
16
24
|
|
17
25
|
def _params
|
18
|
-
|
26
|
+
config['url'].scan(/\?.*$/).first
|
19
27
|
end
|
20
28
|
|
21
29
|
def _create
|
22
|
-
if
|
30
|
+
if _is_sqlite?
|
31
|
+
return if in_memory?
|
32
|
+
::Sequel.connect config['url']
|
33
|
+
elsif _is_mysql?
|
23
34
|
::Sequel.connect("#{_root_url}#{_params}") do |db|
|
24
35
|
db.execute("CREATE DATABASE IF NOT EXISTS `#{db_name}` DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}")
|
25
36
|
end
|
37
|
+
elsif _is_postgres?
|
38
|
+
system("createdb #{db_name}")
|
26
39
|
end
|
27
40
|
end
|
28
41
|
|
29
42
|
def _drop
|
30
|
-
if
|
43
|
+
if _is_sqlite?
|
44
|
+
return if in_memory?
|
45
|
+
::Sequel.connect config['url']
|
46
|
+
elsif _is_mysql?
|
31
47
|
::Sequel.connect("#{_root_url}#{_params}") do |db|
|
32
48
|
db.execute("DROP DATABASE IF EXISTS `#{db_name}`")
|
33
49
|
end
|
50
|
+
elsif _is_postgres?
|
51
|
+
system("dropdb #{db_name}")
|
34
52
|
end
|
35
53
|
end
|
36
54
|
|
@@ -40,6 +58,11 @@ module SequelRails
|
|
40
58
|
@collation ||= config['collation'] || ENV['COLLATION'] || 'utf8_unicode_ci'
|
41
59
|
end
|
42
60
|
|
61
|
+
def in_memory?
|
62
|
+
return false unless _is_sqlite?
|
63
|
+
database == ":memory:"
|
64
|
+
end
|
65
|
+
|
43
66
|
end
|
44
67
|
end
|
45
68
|
end
|
data/lib/sequel_rails/version.rb
CHANGED
@@ -2,6 +2,6 @@ test:
|
|
2
2
|
adapter: "<%= ENV["TEST_ADAPTER"] || "postgresql" %>"
|
3
3
|
database: "<%= ENV["TEST_DATABASE"] || "sequel_rails_test" %>"
|
4
4
|
owner: "<%= ENV["TEST_OWNER"] || ENV["USER"] %>"
|
5
|
-
|
5
|
+
user: "<%= ENV["TEST_USERNAME"] || ENV["USER"] %>"
|
6
6
|
password: "<%= ENV["TEST_PASSWORD"] %>"
|
7
7
|
encoding: "<%= ENV["TEST_ENCODING"] || "unicode" %>"
|
@@ -0,0 +1 @@
|
|
1
|
+
Combustion::Application.config.session_store :cookie_store, :key => "sequel-rails", :secret => "secret-token"
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe SequelRails::Configuration do
|
4
|
+
|
5
|
+
let(:environments) do
|
6
|
+
{
|
7
|
+
"development" => {
|
8
|
+
"adapter" => "postgres",
|
9
|
+
"owner" => (ENV["TEST_OWNER"] || ENV["USER"]),
|
10
|
+
"username" => (ENV["TEST_OWNER"] || ENV["USER"]),
|
11
|
+
"database" => "sequel_rails_test_storage_dev",
|
12
|
+
"host" => "127.0.0.1",
|
13
|
+
},
|
14
|
+
"test" => {
|
15
|
+
"adapter" => "postgres",
|
16
|
+
"owner" => (ENV["TEST_OWNER"] || ENV["USER"]),
|
17
|
+
"username" => (ENV["TEST_OWNER"] || ENV["USER"]),
|
18
|
+
"database" => "sequel_rails_test_storage_test",
|
19
|
+
"host" => "127.0.0.1",
|
20
|
+
},
|
21
|
+
"remote" => {
|
22
|
+
"adapter" => "mysql",
|
23
|
+
"host" => "10.0.0.1",
|
24
|
+
"database" => "sequel_rails_test_storage_remote",
|
25
|
+
},
|
26
|
+
"production" => {
|
27
|
+
"host" => "10.0.0.1",
|
28
|
+
"database" => "sequel_rails_test_storage_production",
|
29
|
+
},
|
30
|
+
"bogus" => {},
|
31
|
+
}
|
32
|
+
end
|
33
|
+
let(:is_jruby) { false }
|
34
|
+
|
35
|
+
before do
|
36
|
+
SequelRails.configuration.stub(:raw).and_return environments
|
37
|
+
SequelRails.configuration.instance_variable_set('@environments', nil)
|
38
|
+
SequelRails.stub(:jruby?).and_return is_jruby
|
39
|
+
end
|
40
|
+
|
41
|
+
subject { SequelRails.setup(environment) }
|
42
|
+
|
43
|
+
describe ".setup" do
|
44
|
+
|
45
|
+
context "for a postgres connection" do
|
46
|
+
|
47
|
+
let(:environment) { 'development' }
|
48
|
+
|
49
|
+
context "in C-Ruby" do
|
50
|
+
|
51
|
+
it "produces a sane config without url" do
|
52
|
+
::Sequel.should_receive(:connect) do |hash|
|
53
|
+
hash['adapter'].should == 'postgres'
|
54
|
+
end
|
55
|
+
subject
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "in JRuby" do
|
60
|
+
|
61
|
+
let(:is_jruby) { true }
|
62
|
+
|
63
|
+
it "produces an adapter config with a url" do
|
64
|
+
::Sequel.should_receive(:connect) do |url, hash|
|
65
|
+
url.should =~ /^jdbc:postgresql:\/\//
|
66
|
+
hash['adapter'].should == 'jdbc:postgresql'
|
67
|
+
hash['host'].should == '127.0.0.1'
|
68
|
+
end
|
69
|
+
subject
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "for a mysql connection" do
|
75
|
+
|
76
|
+
let(:environment) { 'remote' }
|
77
|
+
|
78
|
+
context "in C-Ruby" do
|
79
|
+
|
80
|
+
it "produces a config without url" do
|
81
|
+
::Sequel.should_receive(:connect) do |hash|
|
82
|
+
hash['adapter'].should == 'mysql'
|
83
|
+
end
|
84
|
+
subject
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "in JRuby" do
|
89
|
+
|
90
|
+
let(:is_jruby) { true }
|
91
|
+
|
92
|
+
it "produces a jdbc mysql config" do
|
93
|
+
::Sequel.should_receive(:connect) do |url, hash|
|
94
|
+
url.should =~ /^jdbc:mysql:\/\//
|
95
|
+
hash['adapter'].should == 'jdbc:mysql'
|
96
|
+
hash['database'].should == 'sequel_rails_test_storage_remote'
|
97
|
+
end
|
98
|
+
subject
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -17,7 +17,7 @@ describe SequelRails::Migrations do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
context "with version specified" do
|
20
|
-
let(:opts) { {target
|
20
|
+
let(:opts) { {:target => 1} }
|
21
21
|
it "runs migrations using Sequel::Migrator" do
|
22
22
|
::Sequel::Migrator.should_receive(:run).with(
|
23
23
|
db, "db/migrate", opts
|
data/spec/spec_helper.rb
CHANGED
@@ -11,7 +11,7 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
11
11
|
|
12
12
|
RSpec.configure do |config|
|
13
13
|
config.around :each do |example|
|
14
|
-
Sequel::Model.db.transaction(rollback
|
14
|
+
Sequel::Model.db.transaction(:rollback => :always) do
|
15
15
|
example.run
|
16
16
|
end
|
17
17
|
end
|
data/tasks/spec.rake
CHANGED
@@ -7,8 +7,8 @@ begin
|
|
7
7
|
namespace :spec do
|
8
8
|
def clean_env
|
9
9
|
[
|
10
|
-
"TEST_ADAPTER",
|
11
|
-
"TEST_DATABASE",
|
10
|
+
"TEST_ADAPTER",
|
11
|
+
"TEST_DATABASE",
|
12
12
|
"TEST_OWNER",
|
13
13
|
"TEST_USERNAME",
|
14
14
|
"TEST_PASSWORD",
|
@@ -38,11 +38,15 @@ begin
|
|
38
38
|
|
39
39
|
desc "Run specs for mysql2 adapter"
|
40
40
|
task :mysql2 do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
if SequelRails.jruby?
|
42
|
+
warn "No mysql2 adapter for jdbc"
|
43
|
+
else
|
44
|
+
clean_env
|
45
|
+
Rake::Task["spec"].reenable
|
46
|
+
ENV["TEST_ADAPTER"] = "mysql2"
|
47
|
+
ENV["TEST_ENCODING"] = "utf8"
|
48
|
+
Rake::Task["spec"].invoke
|
49
|
+
end
|
46
50
|
end
|
47
51
|
|
48
52
|
desc "Run specs for sqlite3 adapter"
|
@@ -56,10 +60,15 @@ begin
|
|
56
60
|
|
57
61
|
desc "Run specs for all adapters"
|
58
62
|
task :all do
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
+
res = [
|
64
|
+
"spec:postgresql",
|
65
|
+
"spec:mysql",
|
66
|
+
"spec:mysql2",
|
67
|
+
"spec:sqlite3"
|
68
|
+
].map do |task_name|
|
69
|
+
Rake::Task[task_name].invoke
|
70
|
+
end
|
71
|
+
res.all?
|
63
72
|
end
|
64
73
|
end
|
65
74
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sequel-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.4.
|
5
|
+
version: 0.4.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brasten Sager (brasten)
|
@@ -10,104 +10,104 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-03-
|
13
|
+
date: 2013-03-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sequel
|
17
|
-
|
17
|
+
version_requirements: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
18
19
|
requirements:
|
19
20
|
- - ~>
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: '3.28'
|
22
|
-
|
23
|
+
prerelease: false
|
23
24
|
type: :runtime
|
24
|
-
|
25
|
+
requirement: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
25
27
|
requirements:
|
26
28
|
- - ~>
|
27
29
|
- !ruby/object:Gem::Version
|
28
30
|
version: '3.28'
|
29
|
-
none: false
|
30
|
-
prerelease: false
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: railties
|
33
|
-
|
33
|
+
version_requirements: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
34
35
|
requirements:
|
35
36
|
- - ! '>='
|
36
37
|
- !ruby/object:Gem::Version
|
37
38
|
version: 3.2.0
|
38
|
-
|
39
|
+
prerelease: false
|
39
40
|
type: :runtime
|
40
|
-
|
41
|
+
requirement: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
41
43
|
requirements:
|
42
44
|
- - ! '>='
|
43
45
|
- !ruby/object:Gem::Version
|
44
46
|
version: 3.2.0
|
45
|
-
none: false
|
46
|
-
prerelease: false
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
50
51
|
requirements:
|
51
52
|
- - ! '>='
|
52
53
|
- !ruby/object:Gem::Version
|
53
54
|
version: 0.8.7
|
54
|
-
|
55
|
+
prerelease: false
|
55
56
|
type: :development
|
56
|
-
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
57
59
|
requirements:
|
58
60
|
- - ! '>='
|
59
61
|
- !ruby/object:Gem::Version
|
60
62
|
version: 0.8.7
|
61
|
-
none: false
|
62
|
-
prerelease: false
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
64
|
name: rspec
|
65
|
-
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
66
67
|
requirements:
|
67
68
|
- - ~>
|
68
69
|
- !ruby/object:Gem::Version
|
69
70
|
version: 2.7.0
|
70
|
-
|
71
|
+
prerelease: false
|
71
72
|
type: :development
|
72
|
-
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
73
75
|
requirements:
|
74
76
|
- - ~>
|
75
77
|
- !ruby/object:Gem::Version
|
76
78
|
version: 2.7.0
|
77
|
-
none: false
|
78
|
-
prerelease: false
|
79
79
|
- !ruby/object:Gem::Dependency
|
80
80
|
name: combustion
|
81
|
-
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
82
83
|
requirements:
|
83
84
|
- - ~>
|
84
85
|
- !ruby/object:Gem::Version
|
85
86
|
version: 0.3.1
|
86
|
-
|
87
|
+
prerelease: false
|
87
88
|
type: :development
|
88
|
-
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
89
91
|
requirements:
|
90
92
|
- - ~>
|
91
93
|
- !ruby/object:Gem::Version
|
92
94
|
version: 0.3.1
|
93
|
-
none: false
|
94
|
-
prerelease: false
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: generator_spec
|
97
|
-
|
97
|
+
version_requirements: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
98
99
|
requirements:
|
99
100
|
- - ~>
|
100
101
|
- !ruby/object:Gem::Version
|
101
102
|
version: 0.8.7
|
102
|
-
|
103
|
+
prerelease: false
|
103
104
|
type: :development
|
104
|
-
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
105
107
|
requirements:
|
106
108
|
- - ~>
|
107
109
|
- !ruby/object:Gem::Version
|
108
110
|
version: 0.8.7
|
109
|
-
none: false
|
110
|
-
prerelease: false
|
111
111
|
description: Integrate Sequel with Rails 3
|
112
112
|
email:
|
113
113
|
- brasten@gmail.com
|
@@ -161,10 +161,12 @@ files:
|
|
161
161
|
- spec/internal/Rakefile
|
162
162
|
- spec/internal/app/models/user.rb
|
163
163
|
- spec/internal/config/database.yml
|
164
|
+
- spec/internal/config/initializers/session.rb
|
164
165
|
- spec/internal/config/routes.rb
|
165
166
|
- spec/internal/db/schema.rb
|
166
167
|
- spec/internal/public/favicon.ico
|
167
168
|
- spec/lib/generators/sequel/migration_spec.rb
|
169
|
+
- spec/lib/sequel_rails/configuration_spec.rb
|
168
170
|
- spec/lib/sequel_rails/migrations_spec.rb
|
169
171
|
- spec/lib/sequel_rails/railtie_spec.rb
|
170
172
|
- spec/lib/sequel_rails/railties/log_subscriber_spec.rb
|
@@ -179,26 +181,26 @@ rdoc_options:
|
|
179
181
|
require_paths:
|
180
182
|
- lib
|
181
183
|
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
+
none: false
|
182
185
|
requirements:
|
183
186
|
- - ! '>='
|
184
187
|
- !ruby/object:Gem::Version
|
188
|
+
hash: 4606545589271147809
|
185
189
|
segments:
|
186
190
|
- 0
|
187
|
-
hash: 1691704785188510155
|
188
191
|
version: '0'
|
189
|
-
none: false
|
190
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
191
194
|
requirements:
|
192
195
|
- - ! '>='
|
193
196
|
- !ruby/object:Gem::Version
|
197
|
+
hash: 4606545589271147809
|
194
198
|
segments:
|
195
199
|
- 0
|
196
|
-
hash: 1691704785188510155
|
197
200
|
version: '0'
|
198
|
-
none: false
|
199
201
|
requirements: []
|
200
202
|
rubyforge_project:
|
201
|
-
rubygems_version: 1.8.
|
203
|
+
rubygems_version: 1.8.23
|
202
204
|
signing_key:
|
203
205
|
specification_version: 3
|
204
206
|
summary: Use Sequel with Rails 3
|
@@ -206,10 +208,12 @@ test_files:
|
|
206
208
|
- spec/internal/Rakefile
|
207
209
|
- spec/internal/app/models/user.rb
|
208
210
|
- spec/internal/config/database.yml
|
211
|
+
- spec/internal/config/initializers/session.rb
|
209
212
|
- spec/internal/config/routes.rb
|
210
213
|
- spec/internal/db/schema.rb
|
211
214
|
- spec/internal/public/favicon.ico
|
212
215
|
- spec/lib/generators/sequel/migration_spec.rb
|
216
|
+
- spec/lib/sequel_rails/configuration_spec.rb
|
213
217
|
- spec/lib/sequel_rails/migrations_spec.rb
|
214
218
|
- spec/lib/sequel_rails/railtie_spec.rb
|
215
219
|
- spec/lib/sequel_rails/railties/log_subscriber_spec.rb
|