rails-db_env 0.0.1 → 0.0.2

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/Readme.md CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  About
3
3
  -------------
4
- A `rails` development utility to help you quickly switch between configured databases.
4
+ A `Rails` development utility to help you quickly switch between configured databases.
5
5
 
6
6
  Why and How
7
7
  -------------
@@ -10,14 +10,16 @@ Sometimes you may want to run your local copy of app against `staging` DB:
10
10
 
11
11
  rails2app$ DB_ENV=staging ./script/server
12
12
 
13
- starts a server with default `RAILS_ENV`(`development`) and database configured against `staging:` configuration in `database.yml`
13
+ starts server with default `RAILS_ENV` and **database connection pointing to `staging:`** as configured in `database.yml`
14
14
 
15
15
 
16
16
  TODO
17
17
  -------------
18
- - rails3
19
- - tests
20
-
21
-
22
18
 
19
+ - support rails3
20
+ - tests
23
21
 
22
+ Also
23
+ -------------
24
+ make sure you know what you're doing: running development migration on production database might not be a good idea!
25
+ Use it on your own risc!
@@ -11,4 +11,10 @@ Rails::Configuration.class_eval do
11
11
  alias :database_configuration_without_db_env :database_configuration
12
12
  alias :database_configuration :database_configuration_with_db_env
13
13
 
14
- end if ENV['DB_ENV']
14
+ # since gems are loaded after configuration
15
+ # re establish connection with DB_ENV env
16
+ warn "[rails-db_env]: reconnecting to \x1B[1;37;42m#{ENV['DB_ENV']}\x1B[m DB "
17
+
18
+ ActiveRecord::Base.configurations = Rails.configuration.database_configuration
19
+ ActiveRecord::Base.establish_connection
20
+ end if ENV['DB_ENV'] && Rails.configuration.frameworks.include?(:active_record)
@@ -4,7 +4,7 @@ $:.push File.expand_path("../lib", __FILE__)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "rails-db_env"
7
- s.version = "0.0.1"
7
+ s.version = "0.0.2"
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = %w[gmarik blibbey]
10
10
  s.email = ['gmarik+no+spam@gmail.com']
@@ -16,4 +16,5 @@ Gem::Specification.new do |s|
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
+ s.add_dependency 'rails', '> 2.3.0'
19
20
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-db_env
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - gmarik
@@ -16,10 +16,25 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-03-09 00:00:00 -06:00
19
+ date: 2011-03-12 00:00:00 -06:00
20
20
  default_executable:
21
- dependencies: []
22
-
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: rails
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">"
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 2
33
+ - 3
34
+ - 0
35
+ version: 2.3.0
36
+ type: :runtime
37
+ version_requirements: *id001
23
38
  description: " DB_ENV=staging ./script/server "
24
39
  email:
25
40
  - gmarik+no+spam@gmail.com