deeby 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/CHANGELOG.rdoc +3 -0
  2. data/Manifest.txt +5 -0
  3. data/README.rdoc +76 -0
  4. data/Rakefile +12 -0
  5. data/lib/deeby.rb +20 -0
  6. metadata +77 -0
@@ -0,0 +1,3 @@
1
+ === 1.0.0 / 2009-10-01
2
+
3
+ * Birthday!
@@ -0,0 +1,5 @@
1
+ CHANGELOG.rdoc
2
+ Manifest.txt
3
+ README.rdoc
4
+ Rakefile
5
+ lib/deeby.rb
@@ -0,0 +1,76 @@
1
+ = Deeby
2
+
3
+ * http://github.com/jbarnette/deeby
4
+
5
+ == Description
6
+
7
+ Tasks to switch your Rails database configuration for a single Rake
8
+ run. Useful when you're targeting more than one database engine.
9
+
10
+ I use this for Rails, but it should work in any framework that uses
11
+ a config/database.yml file.
12
+
13
+ == Examples
14
+
15
+ Create a <tt>database.[DB].yml</tt> file for each extra DB setup you
16
+ might want to use. For example:
17
+
18
+ $ ls config/database.*.yml
19
+ config/database.pg.yml
20
+ config/database.sqlite.yml
21
+
22
+ These files look remarkably similar to <tt>database.yml</tt>, they're
23
+ just written for a different DB engine. Deeby looks for files that
24
+ match this pattern and generates prefix Rake tasks for each
25
+ alternative DB file you've created.
26
+
27
+ For the example above, Deeby will generate tasks called <tt>db:pg</tt>
28
+ and <tt>db:sqlite</tt>. These tasks swap out <tt>database.yml</tt> for
29
+ the scope of the Rake run and restore it when you're finished.
30
+
31
+ Let's say you develop on MySQL by default, but you're also deploying
32
+ (or transitioning) to Postgres. Once you've written
33
+ <tt>database.pg.yml</tt>, here's how it works out:
34
+
35
+ # runs the tests against your normal setup (MySQL)
36
+ $ rake test
37
+
38
+ # runs the tests against your Postgres setup
39
+ $ rake db:pg test
40
+
41
+ ...and things are back to normal afterward. Don't forget to run
42
+ <tt>db:create</tt> and <tt>db:reset</tt> (or whatever) with the prefix
43
+ task when you're setting things up initially:
44
+
45
+ # new Postgres setup
46
+ $ rake db:pg db:create db:reset
47
+
48
+ == Installation
49
+
50
+ $ gem install deeby
51
+
52
+ # in your Rakefile
53
+ require "deeby"
54
+
55
+ == License
56
+
57
+ Copyright 2009 John Barnette (jbarnette@rubyforge.org)
58
+
59
+ Permission is hereby granted, free of charge, to any person obtaining
60
+ a copy of this software and associated documentation files (the
61
+ 'Software'), to deal in the Software without restriction, including
62
+ without limitation the rights to use, copy, modify, merge, publish,
63
+ distribute, sublicense, and/or sell copies of the Software, and to
64
+ permit persons to whom the Software is furnished to do so, subject to
65
+ the following conditions:
66
+
67
+ The above copyright notice and this permission notice shall be
68
+ included in all copies or substantial portions of the Software.
69
+
70
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
71
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
72
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
73
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
74
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
75
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
76
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,12 @@
1
+ require "rubygems"
2
+ require "hoe"
3
+
4
+ Hoe.plugin :doofus, :git
5
+
6
+ Hoe.spec "deeby" do
7
+ developer "John Barnette", "jbarnette@rubyforge.org"
8
+
9
+ self.extra_rdoc_files = Dir["*.rdoc"]
10
+ self.history_file = "CHANGELOG.rdoc"
11
+ self.readme_file = "README.rdoc"
12
+ end
@@ -0,0 +1,20 @@
1
+ class Deeby
2
+ VERSION = "1.0.0"
3
+
4
+ ACTIVE = "config/database.yml"
5
+ BACKUP = "config/database.yml.deeby"
6
+
7
+ def self.swap engine
8
+ temp = "config/database.#{engine}.yml"
9
+
10
+ cp ACTIVE, BACKUP
11
+ cp temp, ACTIVE
12
+ at_exit { cp BACKUP, ACTIVE ; rm BACKUP }
13
+ end
14
+ end
15
+
16
+ Dir["config/database.*.yml"].each do |f|
17
+ next unless /database\.(\w+)\.yml$/ =~ f
18
+ desc "Temporarily switch the DB to #{$1}."
19
+ task("db:#{$1}") { Deeby.swap $1 }
20
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: deeby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - John Barnette
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-02 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.3
24
+ version:
25
+ description: |-
26
+ Tasks to switch your Rails database configuration for a single Rake
27
+ run. Useful when you're targeting more than one database engine.
28
+
29
+ I use this for Rails, but it should work in any framework that uses
30
+ a config/database.yml file.
31
+ email:
32
+ - jbarnette@rubyforge.org
33
+ executables: []
34
+
35
+ extensions: []
36
+
37
+ extra_rdoc_files:
38
+ - Manifest.txt
39
+ - CHANGELOG.rdoc
40
+ - README.rdoc
41
+ files:
42
+ - CHANGELOG.rdoc
43
+ - Manifest.txt
44
+ - README.rdoc
45
+ - Rakefile
46
+ - lib/deeby.rb
47
+ has_rdoc: true
48
+ homepage: http://github.com/jbarnette/deeby
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options:
53
+ - --main
54
+ - README.rdoc
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ version:
69
+ requirements: []
70
+
71
+ rubyforge_project: deeby
72
+ rubygems_version: 1.3.5
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: Tasks to switch your Rails database configuration for a single Rake run
76
+ test_files: []
77
+