sinatra-activerecord 2.0.9 → 2.0.10
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a13239550230a493ce9ccff2522d3388086d015
|
4
|
+
data.tar.gz: a2026e6c361446847cbabbd3ef6175285eba01ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b027e361b09da93519bc9bf7e02ffe14de1dd4a1d5484b5a2a95cc5855c59553e9eb9424221d8bb0b78c0cd89d1aa3719b6c39ad47e512f20def3f8b6fbf1ba1
|
7
|
+
data.tar.gz: 31732cfa6c9acbe83b4072458c79468a7a8384af2c97bcf95fad32f9697dae0caf0d432cfbc07dc329a54dad46a7619ecb574445740e28ced00e8dc33a00b439
|
data/lib/sinatra/activerecord.rb
CHANGED
@@ -30,7 +30,9 @@ module Sinatra
|
|
30
30
|
|
31
31
|
# re-connect if database connection dropped (Rails 3 only)
|
32
32
|
app.before { ActiveRecord::Base.verify_active_connections! if ActiveRecord::Base.respond_to?(:verify_active_connections!) }
|
33
|
-
|
33
|
+
if ActiveRecord::ConnectionAdapters.const_defined?(:ConnectionManagement)
|
34
|
+
app.use ActiveRecord::ConnectionAdapters::ConnectionManagement
|
35
|
+
end
|
34
36
|
end
|
35
37
|
|
36
38
|
def database_file=(path)
|
@@ -43,10 +45,13 @@ module Sinatra
|
|
43
45
|
if spec.is_a?(Hash) and spec.symbolize_keys[environment.to_sym]
|
44
46
|
ActiveRecord::Base.configurations = spec.stringify_keys
|
45
47
|
ActiveRecord::Base.establish_connection(environment.to_sym)
|
48
|
+
elsif spec.is_a?(Hash)
|
49
|
+
ActiveRecord::Base.configurations[environment.to_s] = spec.stringify_keys
|
50
|
+
ActiveRecord::Base.establish_connection(spec.stringify_keys)
|
46
51
|
else
|
47
52
|
ActiveRecord::Base.establish_connection(spec)
|
48
53
|
ActiveRecord::Base.configurations ||= {}
|
49
|
-
ActiveRecord::Base.configurations[environment.to_s] = ActiveRecord::
|
54
|
+
ActiveRecord::Base.configurations[environment.to_s] = ActiveRecord::ConnectionAdapters::ConnectionSpecification::ConnectionUrlResolver.new(spec).to_hash
|
50
55
|
end
|
51
56
|
end
|
52
57
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
seed_loader = Class.new do
|
2
|
+
def load_seed
|
3
|
+
load "#{ActiveRecord::Tasks::DatabaseTasks.db_dir}/seeds.rb"
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
ActiveRecord::Tasks::DatabaseTasks.tap do |config|
|
8
|
+
config.root = Rake.application.original_dir
|
9
|
+
config.env = ENV["RACK_ENV"] || "development"
|
10
|
+
config.db_dir = "db"
|
11
|
+
config.migrations_paths = ["db/migrate"]
|
12
|
+
config.fixtures_path = "test/fixtures"
|
13
|
+
config.seed_loader = seed_loader.new
|
14
|
+
config.database_configuration = ActiveRecord::Base.configurations
|
15
|
+
end
|
16
|
+
|
17
|
+
# db:load_config can be overriden manually
|
18
|
+
Rake::Task["db:seed"].enhance(["db:load_config"])
|
19
|
+
Rake::Task["db:load_config"].clear
|
20
|
+
|
21
|
+
# define Rails' tasks as no-op
|
22
|
+
Rake::Task.define_task("db:environment")
|
23
|
+
Rake::Task["db:test:deprecated"].clear if Rake::Task.task_defined?("db:test:deprecated")
|
@@ -23,7 +23,7 @@ namespace :db do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
filename = "#{version}_#{name}.rb"
|
26
|
-
dirname = ActiveRecord::Migrator.
|
26
|
+
dirname = ActiveRecord::Migrator.migrations_paths.first
|
27
27
|
path = File.join(dirname, filename)
|
28
28
|
|
29
29
|
FileUtils.mkdir_p(dirname)
|
@@ -37,3 +37,12 @@ namespace :db do
|
|
37
37
|
puts path
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
# The `db:create` and `db:drop` command won't work with a DATABASE_URL because
|
42
|
+
# the `db:load_config` command tries to connect to the DATABASE_URL, which either
|
43
|
+
# doesn't exist or isn't able to drop the database. Ignore loading the configs for
|
44
|
+
# these tasks if a `DATABASE_URL` is present.
|
45
|
+
if ENV.has_key? "DATABASE_URL"
|
46
|
+
Rake::Task["db:create"].prerequisites.delete("load_config")
|
47
|
+
Rake::Task["db:drop"].prerequisites.delete("load_config")
|
48
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Mizerany
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-07-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/sinatra/activerecord/rake.rb
|
108
108
|
- lib/sinatra/activerecord/rake/activerecord_3.rb
|
109
109
|
- lib/sinatra/activerecord/rake/activerecord_4.rb
|
110
|
+
- lib/sinatra/activerecord/rake/activerecord_5.rb
|
110
111
|
- lib/sinatra/activerecord/tasks.rake
|
111
112
|
homepage: http://github.com/janko-m/sinatra-activerecord
|
112
113
|
licenses:
|
@@ -128,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
129
|
version: '0'
|
129
130
|
requirements: []
|
130
131
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
132
|
+
rubygems_version: 2.5.1
|
132
133
|
signing_key:
|
133
134
|
specification_version: 4
|
134
135
|
summary: Extends Sinatra with ActiveRecord helpers.
|