rails-default-database 1.0.0

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.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) Tim Pope
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,10 @@
1
+ # Rails Default Database
2
+
3
+ Tired of `cp config/database.example.yml config/database.yml`? Me too.
4
+ That's why I wrote this Gem. Simply add this line to your Gemfile and
5
+ PostgreSQL, MySQL, or SQLite3 (depending on which of the 3 is in your
6
+ Gemfile) will be automatically configured with Rails defaults:
7
+
8
+ gem 'rails-default-database'
9
+
10
+ You can still override the defaults by creating `config/database.yml`.
@@ -0,0 +1,38 @@
1
+ Rails::Application::Configuration.class_eval do
2
+
3
+ def database_configuration_with_default
4
+ database_configuration_without_default
5
+ rescue Errno::ENOENT
6
+ name = File.basename(root)
7
+ begin
8
+ require 'pg'
9
+ Hash.new do |h,env|
10
+ h[env] = {
11
+ 'adapter' => 'postgresql',
12
+ 'database' => "#{name}_#{env}"
13
+ }
14
+ end
15
+ rescue LoadError
16
+ begin
17
+ require 'mysql'
18
+ Hash.new do |h,env|
19
+ h[env] = {
20
+ 'adapter' => 'mysql',
21
+ 'username' => 'root',
22
+ 'database' => "#{name}_#{env}"
23
+ }
24
+ end
25
+ rescue LoadError
26
+ require 'sqlite3'
27
+ Hash.new do |h,env|
28
+ h[env] = {
29
+ 'adapter' => 'sqlite3',
30
+ 'database' => "db/#{env}.sqlite3"
31
+ }
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ alias_method_chain :database_configuration, :default
38
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-default-database
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
10
+ platform: ruby
11
+ authors:
12
+ - Tim Pope
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-01-04 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: railties
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ description: Provides a default database configuration for Rails applications that lack one
34
+ email: ruby@tpope.org
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files: []
40
+
41
+ files:
42
+ - README.markdown
43
+ - MIT-LICENSE
44
+ - lib/rails-default-database.rb
45
+ has_rdoc: true
46
+ homepage: http://github.com/tpope/rails-default-database
47
+ licenses: []
48
+
49
+ post_install_message:
50
+ rdoc_options: []
51
+
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ requirements: []
71
+
72
+ rubyforge_project:
73
+ rubygems_version: 1.3.7
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: Make database.yml optional in Rails
77
+ test_files: []
78
+