capistrano_database_yml 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "bundler", "~> 1.0.0"
4
+ gem "jeweler", "~> 1.5.1"
data/Gemfile.lock ADDED
@@ -0,0 +1,16 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.5.1)
6
+ bundler (~> 1.0.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.8.7)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.0.0)
16
+ jeweler (~> 1.5.1)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Simone Carletti, Michael Franz Aigner
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.mdown ADDED
@@ -0,0 +1,49 @@
1
+ # Capistrano database.yml task
2
+
3
+ Provides a couple of tasks for creating the database.yml
4
+ configuration file dynamically when deploy:setup is run.
5
+
6
+ ## Source
7
+
8
+ This is the database.yml task as introduced by Simone Carletti, packaged as a gem:
9
+
10
+ http://www.simonecarletti.com/blog/2009/06/capistrano-and-database-yml/
11
+
12
+ http://gist.github.com/2769
13
+
14
+ ## Usage
15
+
16
+ The following assumes you use bundler. If you are working on a Rails 3 project, this should be the case.
17
+
18
+ To use this gem, first add the following to your Gemfile:
19
+
20
+ gem "capistrano_database_yml"
21
+
22
+ Then install the gem by executing:
23
+
24
+ $ bundle install
25
+
26
+ Afterwards, add the following to your config/deploy.rb:
27
+
28
+ require "database_yml/capistrano"
29
+
30
+ The original config/database.yml should be excluded from version control. You can easily accomplish this by renaming the file (for example to database.example.yml) and configuring your SCM in order to ignore the database.yml file.
31
+
32
+ The following example demonstrate how to rename the file and ignore the original one with Subversion.
33
+
34
+ $ svn mv config/database.yml config/database.example.yml
35
+ $ svn propset svn:ignore 'database.yml' config
36
+
37
+ If your repository is powered by Git, type the following commands.
38
+
39
+ $ git mv config/database.yml config/database.example.yml
40
+ $ echo 'config/database.yml' >> .gitignore
41
+
42
+ ## License
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
45
+
46
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
47
+
48
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49
+
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ gem.name = "capistrano_database_yml"
15
+ gem.homepage = "http://github.com/amfranz/capistrano_database_yml"
16
+ gem.license = "MIT"
17
+ gem.summary = %Q{Capistrano database.yml task}
18
+ gem.description = %Q{Provides a couple of tasks for creating the database.yml configuration file dynamically when deploy:setup is run.}
19
+ gem.email = "amfranz@gmail.com"
20
+ gem.authors = ["Michael Franz Aigner", "Simone Carletti"]
21
+ gem.add_runtime_dependency 'capistrano', '> 2.0'
22
+ end
23
+ Jeweler::RubygemsDotOrgTasks.new
24
+
25
+ task :default => :build
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,55 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{capistrano_database_yml}
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Michael Franz Aigner", "Simone Carletti"]
12
+ s.date = %q{2010-11-29}
13
+ s.description = %q{Provides a couple of tasks for creating the database.yml configuration file dynamically when deploy:setup is run.}
14
+ s.email = %q{amfranz@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.mdown"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.mdown",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "capistrano_database_yml.gemspec",
28
+ "lib/database_yml/capistrano.rb"
29
+ ]
30
+ s.homepage = %q{http://github.com/amfranz/capistrano_database_yml}
31
+ s.licenses = ["MIT"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.7}
34
+ s.summary = %q{Capistrano database.yml task}
35
+
36
+ if s.respond_to? :specification_version then
37
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
38
+ s.specification_version = 3
39
+
40
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
+ s.add_runtime_dependency(%q<bundler>, ["~> 1.0.0"])
42
+ s.add_runtime_dependency(%q<jeweler>, ["~> 1.5.1"])
43
+ s.add_runtime_dependency(%q<capistrano>, ["> 2.0"])
44
+ else
45
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
46
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
47
+ s.add_dependency(%q<capistrano>, ["> 2.0"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
51
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
52
+ s.add_dependency(%q<capistrano>, ["> 2.0"])
53
+ end
54
+ end
55
+
@@ -0,0 +1,78 @@
1
+ #
2
+ # = Capistrano database.yml task
3
+ #
4
+ # Provides a couple of tasks for creating the database.yml
5
+ # configuration file dynamically when deploy:setup is run.
6
+ #
7
+ # Category:: Capistrano
8
+ # Package:: Database
9
+ # Author:: Simone Carletti
10
+ # Copyright:: 2007-2009 The Authors
11
+ # License:: MIT License
12
+ # Link:: http://www.simonecarletti.com/
13
+ # Source:: http://gist.github.com/2769
14
+ #
15
+ #
16
+
17
+ unless Capistrano::Configuration.respond_to?(:instance)
18
+ abort "This extension requires Capistrano 2"
19
+ end
20
+
21
+ Capistrano::Configuration.instance.load do
22
+
23
+ namespace :db do
24
+
25
+ desc <<-DESC
26
+ Creates the database.yml configuration file in shared path.
27
+
28
+ By default, this task uses a template unless a template \
29
+ called database.yml.erb is found either is :template_dir \
30
+ or /config/deploy folders. The default template matches \
31
+ the template for config/database.yml file shipped with Rails.
32
+
33
+ When this recipe is loaded, db:setup is automatically configured \
34
+ to be invoked after deploy:setup. You can skip this task setting \
35
+ the variable :skip_db_setup to true. This is especially useful \
36
+ if you are using this recipe in combination with \
37
+ capistrano-ext/multistaging to avoid multiple db:setup calls \
38
+ when running deploy:setup for all stages one by one.
39
+ DESC
40
+ task :setup, :except => { :no_release => true } do
41
+
42
+ default_template = <<-EOF
43
+ base: &base
44
+ adapter: sqlite3
45
+ timeout: 5000
46
+ development:
47
+ database: #{shared_path}/db/development.sqlite3
48
+ <<: *base
49
+ test:
50
+ database: #{shared_path}/db/test.sqlite3
51
+ <<: *base
52
+ production:
53
+ database: #{shared_path}/db/production.sqlite3
54
+ <<: *base
55
+ EOF
56
+
57
+ location = fetch(:template_dir, "config/deploy") + '/database.yml.erb'
58
+ template = File.file?(location) ? File.read(location) : default_template
59
+
60
+ config = ERB.new(template)
61
+
62
+ run "mkdir -p #{shared_path}/db"
63
+ run "mkdir -p #{shared_path}/config"
64
+ put config.result(binding), "#{shared_path}/config/database.yml"
65
+ end
66
+
67
+ desc <<-DESC
68
+ [internal] Updates the symlink for database.yml file to the just deployed release.
69
+ DESC
70
+ task :symlink, :except => { :no_release => true } do
71
+ run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
72
+ end
73
+
74
+ end
75
+
76
+ after "deploy:setup", "db:setup" unless fetch(:skip_db_setup, false)
77
+ after "deploy:finalize_update", "db:symlink"
78
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano_database_yml
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Michael Franz Aigner
14
+ - Simone Carletti
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-11-29 00:00:00 -05:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 23
29
+ segments:
30
+ - 1
31
+ - 0
32
+ - 0
33
+ version: 1.0.0
34
+ requirement: *id001
35
+ prerelease: false
36
+ type: :runtime
37
+ name: bundler
38
+ - !ruby/object:Gem::Dependency
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 1
45
+ segments:
46
+ - 1
47
+ - 5
48
+ - 1
49
+ version: 1.5.1
50
+ requirement: *id002
51
+ prerelease: false
52
+ type: :runtime
53
+ name: jeweler
54
+ - !ruby/object:Gem::Dependency
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">"
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 2
63
+ - 0
64
+ version: "2.0"
65
+ requirement: *id003
66
+ prerelease: false
67
+ type: :runtime
68
+ name: capistrano
69
+ description: Provides a couple of tasks for creating the database.yml configuration file dynamically when deploy:setup is run.
70
+ email: amfranz@gmail.com
71
+ executables: []
72
+
73
+ extensions: []
74
+
75
+ extra_rdoc_files:
76
+ - LICENSE.txt
77
+ - README.mdown
78
+ files:
79
+ - .document
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE.txt
83
+ - README.mdown
84
+ - Rakefile
85
+ - VERSION
86
+ - capistrano_database_yml.gemspec
87
+ - lib/database_yml/capistrano.rb
88
+ has_rdoc: true
89
+ homepage: http://github.com/amfranz/capistrano_database_yml
90
+ licenses:
91
+ - MIT
92
+ post_install_message:
93
+ rdoc_options: []
94
+
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ hash: 3
112
+ segments:
113
+ - 0
114
+ version: "0"
115
+ requirements: []
116
+
117
+ rubyforge_project:
118
+ rubygems_version: 1.3.7
119
+ signing_key:
120
+ specification_version: 3
121
+ summary: Capistrano database.yml task
122
+ test_files: []
123
+