rails-default-database 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/rails-default-database.rb +26 -38
- metadata +16 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7075c5a3d27a37d456dfeff951e4edc47f4ea9cd
|
4
|
+
data.tar.gz: 6c37e55732b34440e7993db87f215fcb3708af22
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f9cf2c162b1c60c5d9b3426ae2bdd28e5b50ffd8b4837e05be6205149638e9d9a536163a62cac61b9419ac78015710c6ebd83a6a2958f9303098b8b7649e97c
|
7
|
+
data.tar.gz: 9fc50a30d34d8aea25865e1435450db59f2e1ab46bbdd45e0a2c674eb93605bf9234ee852686f141d344d5ecd398c4b9b99b8f1807a60344ca2f411c9b8881d5
|
@@ -4,7 +4,7 @@ Rails::Application::Configuration.class_eval do
|
|
4
4
|
config_file =
|
5
5
|
begin
|
6
6
|
database_configuration_without_default
|
7
|
-
rescue Errno::ENOENT
|
7
|
+
rescue Errno::ENOENT, RuntimeError
|
8
8
|
end || {}
|
9
9
|
|
10
10
|
default_database_configuration.merge(config_file)
|
@@ -12,49 +12,37 @@ Rails::Application::Configuration.class_eval do
|
|
12
12
|
|
13
13
|
def default_database_configuration
|
14
14
|
name = File.basename(root)
|
15
|
-
|
16
|
-
require 'pg'
|
17
|
-
lambda do |env|
|
18
|
-
{
|
19
|
-
'adapter' => 'postgresql',
|
20
|
-
'min_messages' => 'warning',
|
21
|
-
'database' => "#{name}_#{env}"
|
22
|
-
}
|
23
|
-
end
|
24
|
-
rescue LoadError
|
15
|
+
driver = %w(pg mysql mysql2 sqlite3).detect do |a|
|
25
16
|
begin
|
26
|
-
require
|
27
|
-
|
28
|
-
{
|
29
|
-
'adapter' => 'mysql',
|
30
|
-
'username' => 'root',
|
31
|
-
'database' => "#{name}_#{env}"
|
32
|
-
}
|
33
|
-
end
|
17
|
+
require a
|
18
|
+
true
|
34
19
|
rescue LoadError
|
35
|
-
begin
|
36
|
-
require 'mysql2'
|
37
|
-
lambda do |env|
|
38
|
-
{
|
39
|
-
'adapter' => 'mysql2',
|
40
|
-
'username' => 'root',
|
41
|
-
'database' => "#{name}_#{env}"
|
42
|
-
}
|
43
|
-
end
|
44
|
-
rescue LoadError
|
45
|
-
require 'sqlite3'
|
46
|
-
lambda do |env|
|
47
|
-
{
|
48
|
-
'adapter' => 'sqlite3',
|
49
|
-
'database' => "db/#{env}.sqlite3"
|
50
|
-
}
|
51
|
-
end
|
52
|
-
end
|
53
20
|
end
|
54
21
|
end
|
22
|
+
defaults =
|
23
|
+
case driver
|
24
|
+
when 'pg'
|
25
|
+
{
|
26
|
+
'adapter' => 'postgresql',
|
27
|
+
'min_messages' => 'warning'
|
28
|
+
}
|
29
|
+
when 'sqlite3'
|
30
|
+
{
|
31
|
+
'adapter' => 'sqlite3',
|
32
|
+
'database' => 'db/%s.sqlite3'
|
33
|
+
}
|
34
|
+
when nil
|
35
|
+
{}
|
36
|
+
else
|
37
|
+
{'adapter' => driver}
|
38
|
+
end
|
39
|
+
defaults['database'] ||= "#{name}_%s"
|
55
40
|
|
56
41
|
%w(development test production).inject({}) do |h, env|
|
57
|
-
h
|
42
|
+
h[env] = defaults.merge(
|
43
|
+
'database' => defaults['database'].gsub('%s', env)
|
44
|
+
)
|
45
|
+
h
|
58
46
|
end
|
59
47
|
end
|
60
48
|
|
metadata
CHANGED
@@ -1,27 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-default-database
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tim Pope
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-12-20 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: railties
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
description: Provides a default database configuration for Rails applications that
|
26
28
|
lack one
|
27
29
|
email: ruby@tpope.org
|
@@ -29,32 +31,31 @@ executables: []
|
|
29
31
|
extensions: []
|
30
32
|
extra_rdoc_files: []
|
31
33
|
files:
|
32
|
-
- README.markdown
|
33
34
|
- MIT-LICENSE
|
34
|
-
-
|
35
|
+
- README.markdown
|
35
36
|
- lib/rails-default-database.rake
|
37
|
+
- lib/rails-default-database.rb
|
36
38
|
homepage: http://github.com/tpope/rails-default-database
|
37
39
|
licenses: []
|
40
|
+
metadata: {}
|
38
41
|
post_install_message:
|
39
42
|
rdoc_options: []
|
40
43
|
require_paths:
|
41
44
|
- lib
|
42
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
46
|
requirements:
|
45
|
-
- -
|
47
|
+
- - ">="
|
46
48
|
- !ruby/object:Gem::Version
|
47
49
|
version: '0'
|
48
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
51
|
requirements:
|
51
|
-
- -
|
52
|
+
- - ">="
|
52
53
|
- !ruby/object:Gem::Version
|
53
54
|
version: '0'
|
54
55
|
requirements: []
|
55
56
|
rubyforge_project:
|
56
|
-
rubygems_version:
|
57
|
+
rubygems_version: 2.2.2
|
57
58
|
signing_key:
|
58
|
-
specification_version:
|
59
|
+
specification_version: 4
|
59
60
|
summary: Make database.yml optional in Rails
|
60
61
|
test_files: []
|