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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7075c5a3d27a37d456dfeff951e4edc47f4ea9cd
4
- data.tar.gz: 6c37e55732b34440e7993db87f215fcb3708af22
3
+ metadata.gz: 633ec0d9f384cfde25f28c728afd761cc2cfaa4e
4
+ data.tar.gz: b70291050260374fc2f87f851f2ef5f2e05ea0c1
5
5
  SHA512:
6
- metadata.gz: 1f9cf2c162b1c60c5d9b3426ae2bdd28e5b50ffd8b4837e05be6205149638e9d9a536163a62cac61b9419ac78015710c6ebd83a6a2958f9303098b8b7649e97c
7
- data.tar.gz: 9fc50a30d34d8aea25865e1435450db59f2e1ab46bbdd45e0a2c674eb93605bf9234ee852686f141d344d5ecd398c4b9b99b8f1807a60344ca2f411c9b8881d5
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
- License
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
- config_file =
4
+ config =
5
5
  begin
6
6
  database_configuration_without_default
7
7
  rescue Errno::ENOENT, RuntimeError
8
8
  end || {}
9
9
 
10
- default_database_configuration.merge(config_file)
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.7
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: 2014-12-20 00:00:00.000000000 Z
11
+ date: 2015-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties