rails-default-database 1.0.7 → 1.0.8
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 +4 -4
- data/README.markdown +8 -2
- data/lib/rails-default-database.rb +14 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 633ec0d9f384cfde25f28c728afd761cc2cfaa4e
|
4
|
+
data.tar.gz: b70291050260374fc2f87f851f2ef5f2e05ea0c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a0c7b0f13f69f460c7d4e32d52e053cc19c24f3d84cc713320d277c52a4c8908eaeca06346c0c1d4778081a34d5e0749dd68218fdd6e680df7c4d3dd83767e6
|
7
|
+
data.tar.gz: 1e018748e74acee4b7423c6c00f272ea6e2ce6bc6cd12249e8294943ef8a553128ae9c0c7547e099ac380588ce326577396d08da49e1ecccd0ad59939fdf9aef
|
data/README.markdown
CHANGED
@@ -11,7 +11,13 @@ You can still override the defaults by creating `config/database.yml`.
|
|
11
11
|
Use `rake db:config` to create `config/database.yml` with the defaults
|
12
12
|
that would have been assumed.
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
As in standard Rails, the `DATABASE_URL` environment variable takes
|
15
|
+
precedence when defined. However, in the test environment, Rails Default
|
16
|
+
Database will append `_test` to the database name (after stripping an optional
|
17
|
+
existing environment suffix), ensuring the development (or production!)
|
18
|
+
database is never clobbered. This enables storing your database configuration
|
19
|
+
in [`.env`](https://github.com/bkeepers/dotenv), if you so choose.
|
20
|
+
|
21
|
+
## License
|
16
22
|
|
17
23
|
Copyright (c) Tim Pope. MIT License.
|
@@ -1,17 +1,28 @@
|
|
1
1
|
Rails::Application::Configuration.class_eval do
|
2
2
|
|
3
3
|
def database_configuration_with_default
|
4
|
-
|
4
|
+
config =
|
5
5
|
begin
|
6
6
|
database_configuration_without_default
|
7
7
|
rescue Errno::ENOENT, RuntimeError
|
8
8
|
end || {}
|
9
9
|
|
10
|
-
|
10
|
+
if url = ENV['DATABASE_URL'].presence
|
11
|
+
config['test'] ||= {}
|
12
|
+
config['test']['url'] ||= ENV['TEST_DATABASE_URL'] ||
|
13
|
+
url.sub(/(?:_development|_test|_production)?(?=\?|$)/, "_test")
|
14
|
+
config[if Rails.env.test? then 'development' else Rails.env end] ||= {}
|
15
|
+
config.keys.each do |k|
|
16
|
+
config[k]['url'] ||= url
|
17
|
+
end
|
18
|
+
config
|
19
|
+
else
|
20
|
+
default_database_configuration.merge(config)
|
21
|
+
end
|
11
22
|
end
|
12
23
|
|
13
24
|
def default_database_configuration
|
14
|
-
name = File.basename(root)
|
25
|
+
name = File.basename(root).gsub(/[^[:alnum:]]+/, '_')
|
15
26
|
driver = %w(pg mysql mysql2 sqlite3).detect do |a|
|
16
27
|
begin
|
17
28
|
require a
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-default-database
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Pope
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|