sequel-rails 0.9.12 → 0.9.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -8
- data/History.md +12 -0
- data/README.md +31 -28
- data/Rakefile +7 -3
- data/ci/rails-3.2.gemfile +1 -0
- data/lib/action_dispatch/middleware/session/sequel_store.rb +23 -16
- data/lib/generators/sequel/model/templates/migration.rb.erb +2 -2
- data/lib/generators/sequel/model/templates/model.rb.erb +1 -1
- data/lib/sequel_rails/railtie.rb +2 -2
- data/lib/sequel_rails/railties/spring_support.rb +3 -2
- data/lib/sequel_rails/sequel/database/active_support_notification.rb +9 -4
- data/lib/sequel_rails/storage.rb +38 -4
- data/lib/sequel_rails/storage/abstract.rb +16 -0
- data/lib/sequel_rails/version.rb +1 -1
- data/spec/internal/app/controllers/sessions_controller.rb +2 -2
- data/spec/lib/sequel_rails/storage_spec.rb +1 -2
- data/spec/spec_helper.rb +1 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1baea5434b859f792b982cb26885b30629e8a443
|
4
|
+
data.tar.gz: f1176da5f83ed06c55aa675a2de1a5631845de55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8be6f01d2e34e7062c6a854ad18e0a60af75a4448470d18ce70e8206ab5843bdabf0b300c706624988050ffa8ff10674f29c5abb2c479bda75f8d80d41f87194
|
7
|
+
data.tar.gz: aa6ea0faee39b20dc3bc01f40bc472e95a933c1e528c204e83fd0e53d33576e13b63924756d2de882bc05e13c7652f4d0ef5e71205eac18187cbff6f9d90752a
|
data/.travis.yml
CHANGED
@@ -6,12 +6,17 @@ rvm:
|
|
6
6
|
- 1.8.7
|
7
7
|
- 1.9.3
|
8
8
|
- 2.0.0
|
9
|
-
- 2.1.
|
10
|
-
- 2.2.
|
11
|
-
- 2.3.
|
9
|
+
- 2.1.10
|
10
|
+
- 2.2.5
|
11
|
+
- 2.3.1
|
12
12
|
- jruby-18mode
|
13
13
|
- jruby-19mode
|
14
|
-
- jruby-9.0.
|
14
|
+
- jruby-9.0.5.0
|
15
|
+
- jruby-9.1.2.0
|
16
|
+
before_script:
|
17
|
+
- mysql -e 'create database sequel_rails_test;'
|
18
|
+
- mysql -e 'create database sequel_rails_test_mysql2;'
|
19
|
+
- psql -c 'create database sequel_rails_test;' -U postgres
|
15
20
|
env:
|
16
21
|
- SEQUEL='~> 3.0'
|
17
22
|
- SEQUEL='~> 4.0'
|
@@ -22,14 +27,14 @@ gemfile:
|
|
22
27
|
- ci/rails-4.2.gemfile
|
23
28
|
- ci/rails-5.0.gemfile
|
24
29
|
matrix:
|
25
|
-
allow_failures:
|
26
|
-
- gemfile: ci/rails-5.0.gemfile
|
27
30
|
exclude:
|
28
31
|
- rvm: 2.2.4
|
29
32
|
gemfile: ci/rails-3.2.gemfile
|
30
33
|
- rvm: 2.3.0
|
31
34
|
gemfile: ci/rails-3.2.gemfile
|
32
|
-
- rvm: jruby-9.0.
|
35
|
+
- rvm: jruby-9.0.5.0
|
36
|
+
gemfile: ci/rails-3.2.gemfile
|
37
|
+
- rvm: jruby-9.1.2.0
|
33
38
|
gemfile: ci/rails-3.2.gemfile
|
34
39
|
- rvm: ree
|
35
40
|
gemfile: ci/rails-4.0.gemfile
|
@@ -61,8 +66,10 @@ matrix:
|
|
61
66
|
gemfile: ci/rails-5.0.gemfile
|
62
67
|
- rvm: 2.0.0
|
63
68
|
gemfile: ci/rails-5.0.gemfile
|
64
|
-
- rvm: 2.1.
|
69
|
+
- rvm: 2.1.10
|
65
70
|
gemfile: ci/rails-5.0.gemfile
|
71
|
+
- gemfile: ci/rails-3.2.gemfile
|
72
|
+
env: SEQUEL='~> 4.0'
|
66
73
|
notifications:
|
67
74
|
email:
|
68
75
|
- jonathan.tron@metrilio.com
|
data/History.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
0.9.13 (2016-08-11)
|
2
|
+
===================
|
3
|
+
|
4
|
+
* Remove some trailing spaces (Pablo Herrero)
|
5
|
+
[#119](https://github.com/TalentBox/sequel-rails/pull/119)
|
6
|
+
* Update session store for Rails 5/Rack 2.0 compatibility (Jordan Owens)
|
7
|
+
[#110](https://github.com/TalentBox/sequel-rails/pull/110)
|
8
|
+
* Make logging compatible with the Sequel master
|
9
|
+
[#109](https://github.com/TalentBox/sequel-rails/issues/109)
|
10
|
+
* Ensure `url` database config is used in Rake task as well (Lukas Fittl)
|
11
|
+
[#106](https://github.com/TalentBox/sequel-rails/pull/106)
|
12
|
+
|
1
13
|
0.9.12 (2016-01-18)
|
2
14
|
===================
|
3
15
|
|
data/README.md
CHANGED
@@ -361,34 +361,37 @@ Contributors
|
|
361
361
|
|
362
362
|
Improvements have been made by those awesome contributors:
|
363
363
|
|
364
|
-
* Benjamin Atkin (benatkin)
|
365
|
-
* Gabor Ratky (rgabo)
|
366
|
-
* Joshua Hansen (binarypaladin)
|
367
|
-
* Arron Washington (radicaled)
|
368
|
-
* Thiago Pradi (tchandy)
|
369
|
-
* Sascha Cunz (scunz)
|
370
|
-
* Brian Donovan (eventualbuddha)
|
371
|
-
* Jack Danger Canty (JackDanger)
|
372
|
-
* Ed Ruder (edruder)
|
373
|
-
* Rafał Rzepecki (dividedmind)
|
374
|
-
* Sean Sorrell (rudle)
|
375
|
-
* Saulius Grigaliunas (sauliusg)
|
376
|
-
* Jacques Crocker (railsjedi)
|
377
|
-
* Eric Strathmeyer (strathmeyer)
|
378
|
-
* Jan Berdajs (mrbrdo)
|
379
|
-
* Robert Payne (robertjpayne)
|
380
|
-
* Kevin Menard (nirvdrum)
|
381
|
-
* Chris Heisterkamp (cheister)
|
382
|
-
* Tamir Duberstein (tamird)
|
383
|
-
* shelling (shelling)
|
384
|
-
* a3gis (a3gis)
|
385
|
-
* Andrey Chernih (andreychernih)
|
386
|
-
* Nico Rieck (gix)
|
387
|
-
* Alexander Birkner (BirknerAlex)
|
388
|
-
* kr3ssh (kressh)
|
389
|
-
* John Anderson (djellemah)
|
390
|
-
* Larivact (Larivact)
|
391
|
-
* Jan Berdajs (mrbrdo)
|
364
|
+
* Benjamin Atkin (@benatkin)
|
365
|
+
* Gabor Ratky (@rgabo)
|
366
|
+
* Joshua Hansen (@binarypaladin)
|
367
|
+
* Arron Washington (@radicaled)
|
368
|
+
* Thiago Pradi (@tchandy)
|
369
|
+
* Sascha Cunz (@scunz)
|
370
|
+
* Brian Donovan (@eventualbuddha)
|
371
|
+
* Jack Danger Canty (@JackDanger)
|
372
|
+
* Ed Ruder (@edruder)
|
373
|
+
* Rafał Rzepecki (@dividedmind)
|
374
|
+
* Sean Sorrell (@rudle)
|
375
|
+
* Saulius Grigaliunas (@sauliusg)
|
376
|
+
* Jacques Crocker (@railsjedi)
|
377
|
+
* Eric Strathmeyer (@strathmeyer)
|
378
|
+
* Jan Berdajs (@mrbrdo)
|
379
|
+
* Robert Payne (@robertjpayne)
|
380
|
+
* Kevin Menard (@nirvdrum)
|
381
|
+
* Chris Heisterkamp (@cheister)
|
382
|
+
* Tamir Duberstein (@tamird)
|
383
|
+
* shelling (@shelling)
|
384
|
+
* a3gis (@a3gis)
|
385
|
+
* Andrey Chernih (@andreychernih)
|
386
|
+
* Nico Rieck (@gix)
|
387
|
+
* Alexander Birkner (@BirknerAlex)
|
388
|
+
* kr3ssh (@kressh)
|
389
|
+
* John Anderson (@djellemah)
|
390
|
+
* Larivact (@Larivact)
|
391
|
+
* Jan Berdajs (@mrbrdo)
|
392
|
+
* Lukas Fittl (@lfittl)
|
393
|
+
* Jordan Owens (@jkowens)
|
394
|
+
* Pablo Herrero (@pabloh)
|
392
395
|
|
393
396
|
Credits
|
394
397
|
=======
|
data/Rakefile
CHANGED
@@ -34,19 +34,23 @@ begin
|
|
34
34
|
'sqlite3' => { 'TEST_DATABASE' => 'db/database.sqlite3' },
|
35
35
|
}
|
36
36
|
|
37
|
-
configs.merge!(
|
37
|
+
configs.merge!(
|
38
|
+
'mysql2' => configs.fetch('mysql').merge(
|
39
|
+
'TEST_DATABASE' => 'sequel_rails_test_mysql2'
|
40
|
+
)
|
41
|
+
) unless SequelRails.jruby?
|
38
42
|
|
39
43
|
configs.each do |adapter, config|
|
40
44
|
desc "Run specs for #{adapter} adapter"
|
41
45
|
task adapter do
|
42
46
|
puts "running spec:#{adapter}"
|
43
47
|
clean_env
|
44
|
-
Rake::Task['spec'].reenable
|
45
48
|
ENV['TEST_ADAPTER'] = adapter
|
46
49
|
config.each do |key, value|
|
47
50
|
ENV[key] = value
|
48
51
|
end
|
49
|
-
|
52
|
+
rake = ENV['RAKE'] || "#{FileUtils::RUBY} -S rake"
|
53
|
+
sh "#{rake} spec 2>&1"
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
data/ci/rails-3.2.gemfile
CHANGED
@@ -21,42 +21,49 @@ module ActionDispatch
|
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
|
+
def find_session(req, sid)
|
25
|
+
get_session(req.env, sid)
|
26
|
+
end
|
27
|
+
|
24
28
|
def get_session(env, sid)
|
25
|
-
|
26
|
-
session = find_session(sid)
|
29
|
+
session = load_from_store(sid)
|
27
30
|
env[SESSION_RECORD_KEY] = session
|
28
|
-
[
|
31
|
+
[session.session_id, session.data]
|
32
|
+
end
|
33
|
+
|
34
|
+
def write_session(req, sid, session_data, options)
|
35
|
+
set_session(req.env, sid, session_data, options)
|
29
36
|
end
|
30
37
|
|
31
|
-
def set_session(env, sid, session_data,
|
38
|
+
def set_session(env, sid, session_data, options)
|
32
39
|
session = get_session_model(env, sid)
|
33
40
|
session.data = session_data
|
34
|
-
session.save(:raise_on_failure => false) &&
|
41
|
+
session.save(:raise_on_failure => false) && session.session_id
|
35
42
|
end
|
36
43
|
|
37
|
-
def
|
38
|
-
sid
|
39
|
-
|
40
|
-
session = get_session_model(env, sid)
|
41
|
-
session.destroy unless session.new?
|
42
|
-
env[SESSION_RECORD_KEY] = nil
|
43
|
-
end
|
44
|
+
def delete_session(req, sid, options)
|
45
|
+
destroy_session(req.env, sid, options)
|
46
|
+
end
|
44
47
|
|
48
|
+
def destroy_session(env, sid, options)
|
49
|
+
session = get_session_model(env, sid)
|
50
|
+
session.destroy unless session.new?
|
51
|
+
env[SESSION_RECORD_KEY] = nil
|
45
52
|
generate_sid unless options[:drop]
|
46
53
|
end
|
47
54
|
|
48
55
|
def get_session_model(env, sid)
|
49
56
|
if env[ENV_SESSION_OPTIONS_KEY][:id].nil?
|
50
|
-
env[SESSION_RECORD_KEY] =
|
57
|
+
env[SESSION_RECORD_KEY] = load_from_store(sid)
|
51
58
|
else
|
52
|
-
env[SESSION_RECORD_KEY] ||=
|
59
|
+
env[SESSION_RECORD_KEY] ||= load_from_store(sid)
|
53
60
|
end
|
54
61
|
end
|
55
62
|
|
56
|
-
def
|
63
|
+
def load_from_store(sid)
|
57
64
|
klass = self.class.session_class
|
58
65
|
klass.where(:session_id => sid).first ||
|
59
|
-
klass.new(:session_id =>
|
66
|
+
klass.new(:session_id => generate_sid, :data => {})
|
60
67
|
end
|
61
68
|
end
|
62
69
|
end
|
data/lib/sequel_rails/railtie.rb
CHANGED
@@ -71,9 +71,9 @@ module SequelRails
|
|
71
71
|
::SequelRails.setup ::Rails.env unless app.config.sequel[:skip_connect]
|
72
72
|
end
|
73
73
|
|
74
|
-
initializer 'sequel.spring' do |
|
74
|
+
initializer 'sequel.spring' do |_app|
|
75
75
|
if defined?(::Spring::Application)
|
76
|
-
class ::Spring::Application
|
76
|
+
class ::Spring::Application # rubocop:disable Style/ClassAndModuleChildren
|
77
77
|
include ::SequelRails::SpringSupport
|
78
78
|
alias_method_chain :disconnect_database, :sequel
|
79
79
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module SequelRails
|
2
2
|
module SpringSupport
|
3
3
|
def disconnect_database_with_sequel
|
4
|
-
Sequel::DATABASES.each
|
4
|
+
Sequel::DATABASES.each(&:disconnect) if sequel_configured?
|
5
5
|
disconnect_database_without_sequel
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
private
|
9
|
+
|
9
10
|
def sequel_configured?
|
10
11
|
defined?(Sequel::DATABASES)
|
11
12
|
end
|
@@ -3,9 +3,10 @@ require 'active_support/notifications'
|
|
3
3
|
|
4
4
|
module Sequel
|
5
5
|
class Database
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
|
7
|
+
def log_connection_yield(sql, conn, args=nil)
|
8
|
+
sql_for_log = "#{connection_info(conn) if conn && log_connection_info}#{sql}#{"; #{args.inspect}" if args}"
|
9
|
+
start = Time.now
|
9
10
|
begin
|
10
11
|
::ActiveSupport::Notifications.instrument(
|
11
12
|
'sql.sequel',
|
@@ -19,8 +20,12 @@ module Sequel
|
|
19
20
|
log_exception(e, sql_for_log) unless @loggers.empty?
|
20
21
|
raise
|
21
22
|
ensure
|
22
|
-
log_duration(Time.now
|
23
|
+
log_duration(Time.now - start, sql_for_log) unless e || @loggers.empty?
|
23
24
|
end
|
24
25
|
end
|
26
|
+
|
27
|
+
def log_yield(sql, args = nil, &block)
|
28
|
+
log_connection_yield(sql, nil, args, &block)
|
29
|
+
end
|
25
30
|
end
|
26
31
|
end
|
data/lib/sequel_rails/storage.rb
CHANGED
@@ -53,20 +53,54 @@ module SequelRails
|
|
53
53
|
|
54
54
|
private
|
55
55
|
|
56
|
+
def self.parse_url(value)
|
57
|
+
URI(value) if value.present?
|
58
|
+
rescue ArgumentError
|
59
|
+
warn "config url could not be parsed, value was: #{value.inspect}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.extract_database(config, uri)
|
63
|
+
database = config['database']
|
64
|
+
database ||= uri.path[1..-1] if uri
|
65
|
+
database
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.extract_adapter(config, uri)
|
69
|
+
adapter = config['adapter']
|
70
|
+
adapter ||= uri.scheme if uri
|
71
|
+
adapter
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.extract_host(config, uri)
|
75
|
+
host = config['host']
|
76
|
+
host ||= uri.host if uri
|
77
|
+
host
|
78
|
+
end
|
79
|
+
|
56
80
|
def self.with_local_repositories
|
57
81
|
::SequelRails.configuration.environments.each_value do |config|
|
58
|
-
|
59
|
-
|
82
|
+
uri = parse_url(config['url'])
|
83
|
+
|
84
|
+
database = extract_database(config, uri)
|
85
|
+
adapter = extract_adapter(config, uri)
|
86
|
+
host = extract_host(config, uri)
|
87
|
+
|
88
|
+
next if database.blank? || adapter.blank?
|
89
|
+
if host.blank? || %w( 127.0.0.1 localhost ).include?(host)
|
60
90
|
yield config
|
61
91
|
else
|
62
|
-
warn "This task only modifies local databases. #{
|
92
|
+
warn "This task only modifies local databases. #{database} is on a remote host."
|
63
93
|
end
|
64
94
|
end
|
65
95
|
end
|
66
96
|
|
67
97
|
def self.with_all_repositories
|
68
98
|
::SequelRails.configuration.environments.each_value do |config|
|
69
|
-
|
99
|
+
uri = parse_url(config['url'])
|
100
|
+
database = extract_database(config, uri)
|
101
|
+
adapter = extract_adapter(config, uri)
|
102
|
+
|
103
|
+
next if database.blank? || adapter.blank?
|
70
104
|
yield config
|
71
105
|
end
|
72
106
|
end
|
@@ -5,6 +5,7 @@ module SequelRails
|
|
5
5
|
|
6
6
|
def initialize(config)
|
7
7
|
@config = config
|
8
|
+
parse_url
|
8
9
|
end
|
9
10
|
|
10
11
|
def create
|
@@ -93,6 +94,21 @@ module SequelRails
|
|
93
94
|
|
94
95
|
private
|
95
96
|
|
97
|
+
def parse_url
|
98
|
+
return unless @config['url'].present?
|
99
|
+
|
100
|
+
url = URI(@config['url'])
|
101
|
+
|
102
|
+
username, password = url.userinfo.to_s.split(':')
|
103
|
+
@config.reverse_merge!(
|
104
|
+
'database' => url.path.to_s[1..-1],
|
105
|
+
'username' => username,
|
106
|
+
'password' => password,
|
107
|
+
'host' => url.host,
|
108
|
+
'port' => url.port
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
96
112
|
def add_option(commands, name, value)
|
97
113
|
return unless value.present?
|
98
114
|
separator = name[0, 2] == '--' ? '=' : ' '
|
data/lib/sequel_rails/version.rb
CHANGED
@@ -12,10 +12,9 @@ describe SequelRails::Storage do
|
|
12
12
|
},
|
13
13
|
'test' => {
|
14
14
|
'adapter' => 'postgres',
|
15
|
+
'url' => 'postgres://127.0.0.1/sequel_rails_test_storage_test',
|
15
16
|
'owner' => (ENV['TEST_OWNER'] || ENV['USER']),
|
16
17
|
'username' => (ENV['TEST_OWNER'] || ENV['USER']),
|
17
|
-
'database' => 'sequel_rails_test_storage_test',
|
18
|
-
'host' => '127.0.0.1',
|
19
18
|
},
|
20
19
|
'remote' => {
|
21
20
|
'adapter' => 'postgres',
|
data/spec/spec_helper.rb
CHANGED
@@ -47,14 +47,9 @@ RSpec.configure do |config|
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
# Ensure db
|
50
|
+
# Ensure db migrated
|
51
51
|
begin
|
52
52
|
require 'sequel_rails/storage'
|
53
|
-
Ammeter::OutputCapturer.capture_stdout do
|
54
|
-
SequelRails::Storage.adapter_for(:test).drop
|
55
|
-
SequelRails::Storage.adapter_for(:test).create
|
56
|
-
end
|
57
|
-
|
58
53
|
require 'sequel/extensions/migration'
|
59
54
|
load "#{Rails.root}/db/schema.rb.init"
|
60
55
|
Sequel::Migration.descendants.first.apply Sequel::Model.db, :up
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brasten Sager (brasten)
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-08-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -299,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
299
299
|
version: '0'
|
300
300
|
requirements: []
|
301
301
|
rubyforge_project:
|
302
|
-
rubygems_version: 2.5.1
|
302
|
+
rubygems_version: 2.4.5.1
|
303
303
|
signing_key:
|
304
304
|
specification_version: 4
|
305
305
|
summary: Use Sequel with Rails (3.x and 4.x)
|