capistrano-shared_file 0.1.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,9 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Add dependencies to develop your gem here.
4
+ # Include everything needed to run rake, tests, features, etc.
5
+ group :development do
6
+ gem "rdoc", "~> 3.12"
7
+ gem "bundler", "~> 1.0.0"
8
+ gem "jeweler", "~> 1.8.3"
9
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,21 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.8.3)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rdoc
10
+ json (1.7.1)
11
+ rake (0.9.2.2)
12
+ rdoc (3.12)
13
+ json (~> 1.4)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ bundler (~> 1.0.0)
20
+ jeweler (~> 1.8.3)
21
+ rdoc (~> 3.12)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Huiming Teo (teohm)
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.rdoc ADDED
@@ -0,0 +1,26 @@
1
+ = capistrano-shared_file
2
+
3
+ Capistrano recipe to symlink shared files e.g. config/database.yml
4
+ stored in shared path to release path.
5
+
6
+ To use the recipe, add the following lines to config/deploy.rb:
7
+
8
+ #set :shared_files, %w(config/database.yml) # optional, as it's the default value
9
+ require 'capistrano/shared_file'
10
+
11
+
12
+ == Contributing to capistrano-shared_file
13
+
14
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
15
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
16
+ * Fork the project.
17
+ * Start a feature/bugfix branch.
18
+ * Commit and push until you are happy with your contribution.
19
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
20
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
21
+
22
+ == Copyright
23
+
24
+ Copyright (c) 2012 teohm. See LICENSE.txt for
25
+ further details.
26
+
data/Rakefile ADDED
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "capistrano-shared_file"
18
+ gem.homepage = "http://github.com/teohm/capistrano-shared_file"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Capistrano recipe to symlink shared files e.g. config/database.yml}
21
+ gem.description = %Q{
22
+ To use the recipe, add the following lines to config/deploy.rb:
23
+
24
+ #set :shared_files, %w(config/database.yml) # optional, as it's the default value
25
+ require 'capistrano/shared_file'
26
+ }
27
+ gem.email = "teohuiming@gmail.com"
28
+ gem.authors = ["teohm"]
29
+ # dependencies defined in Gemfile
30
+ end
31
+ Jeweler::RubygemsDotOrgTasks.new
32
+
33
+ task :default => :version
34
+
35
+ require 'rdoc/task'
36
+ Rake::RDocTask.new do |rdoc|
37
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
38
+
39
+ rdoc.rdoc_dir = 'rdoc'
40
+ rdoc.title = "capistrano-shared_file #{version}"
41
+ rdoc.rdoc_files.include('README*')
42
+ rdoc.rdoc_files.include('lib/**/*.rb')
43
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,54 @@
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 = "capistrano-shared_file"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["teohm"]
12
+ s.date = "2012-05-11"
13
+ s.description = "\n To use the recipe, add the following lines to config/deploy.rb: \n \n #set :shared_files, %w(config/database.yml) # optional, as it's the default value\n require 'capistrano/shared_file'\n "
14
+ s.email = "teohuiming@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "capistrano-shared_file.gemspec",
28
+ "lib/capistrano/shared_file.rb"
29
+ ]
30
+ s.homepage = "http://github.com/teohm/capistrano-shared_file"
31
+ s.licenses = ["MIT"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = "1.8.24"
34
+ s.summary = "Capistrano recipe to symlink shared files e.g. config/database.yml"
35
+
36
+ if s.respond_to? :specification_version then
37
+ s.specification_version = 3
38
+
39
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
40
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
41
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
42
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
43
+ else
44
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
45
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
46
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
47
+ end
48
+ else
49
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
50
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
51
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
52
+ end
53
+ end
54
+
@@ -0,0 +1,104 @@
1
+ unless Capistrano::Configuration.respond_to?(:instance)
2
+ abort "capistrano/shared_files requires Capistrano 2"
3
+ end
4
+
5
+ Capistrano::Configuration.instance.load do
6
+
7
+ # ================================================================
8
+ # This variable defines files to be symlinked from shared path.
9
+ #
10
+ # File 'config/database.yml' is added by default, to cover 80%
11
+ # of the use cases. Please OVERWRITE this to fit your needs.
12
+ # ================================================================
13
+ _cset :shared_files, %w(config/database.yml)
14
+
15
+ # ================================================================
16
+ # These variables define where to store the shared files.
17
+ # Make sure you understand the implication when you modify them.
18
+ # ================================================================
19
+ _cset :shared_file_dir, "files"
20
+ _cset(:shared_file_path) { File.join(shared_path, shared_file_dir) }
21
+
22
+
23
+ # ================================================================
24
+ # Cap tasks are added under namespace deploy:shared_file:*
25
+ # Usually you do not need to call them directly, as they are
26
+ # triggered during deploy:setup and deploy.
27
+ # ================================================================
28
+ namespace :deploy do
29
+ namespace :shared_file do
30
+
31
+ desc <<-DESC
32
+ Generate shared file dirs under shared/files dir.
33
+
34
+ For example, given:
35
+ set :shared_files, %w(config/database.yml db/seeds.yml)
36
+
37
+ The following directories will be generated:
38
+ shared/files/config/
39
+ shared/files/db/
40
+ DESC
41
+ task :setup, :except => { :no_release => true } do
42
+ if exists?(:shared_files)
43
+ dirs = shared_files.map {|f| File.join(shared_file_path, File.dirname(f)) }
44
+ run "#{try_sudo} mkdir -p #{dirs.join(' ')}"
45
+ run "#{try_sudo} chmod g+w #{dirs.join(' ')}" if fetch(:group_writable, true)
46
+ end
47
+ end
48
+ after "deploy:setup", "deploy:shared_file:setup"
49
+
50
+
51
+ desc <<-DESC
52
+ Print a reminder to upload shared files \
53
+ along with scp samples.
54
+ DESC
55
+ task :print_reminder do
56
+ if exists?(:shared_files)
57
+ servers = find_servers(:no_release => false)
58
+ puts <<-INFO
59
+ *************************
60
+ * UPLOAD SHARED FILES *
61
+
62
+ Remember to upload these files:
63
+ #{ shared_files.join('\n ') }
64
+
65
+ To '#{shared_file_path}' in server(s):
66
+ #{servers.join('\n ')}
67
+
68
+ SCP Samples:
69
+ INFO
70
+
71
+ servers.each do |server|
72
+ shared_files.each do |file_path|
73
+ puts " scp #{file_path} #{server}:#{File.join(shared_file_path, file_path)}\n"
74
+ end
75
+ end
76
+
77
+ puts <<-INFO
78
+
79
+ *************************
80
+ INFO
81
+ end
82
+ end
83
+ after "deploy:setup", "deploy:shared_file:print_reminder"
84
+
85
+
86
+ desc <<-DESC
87
+ Symlink shared files to release path.
88
+
89
+ WARNING: It DOES NOT warn you when shared files not exist. \
90
+ So symlink will be created even when a shared file does not \
91
+ exist.
92
+ DESC
93
+ task :create_symlink, :except => { :no_release => true } do
94
+ (shared_files || []).each do |path|
95
+ run "ln -nfs #{shared_file_path}/#{path} #{release_path}/#{path}"
96
+ end
97
+ end
98
+ after "deploy:finalize_update", "deploy:shared_file:create_symlink"
99
+
100
+ end # namespace shared_file
101
+ end # namespace deploy
102
+
103
+ end
104
+
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-shared_file
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - teohm
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rdoc
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.12'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.12'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.0.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: jeweler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.3
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.3
62
+ description: ! "\n To use the recipe, add the following lines to config/deploy.rb:
63
+ \n \n #set :shared_files, %w(config/database.yml) # optional, as it's the default
64
+ value\n require 'capistrano/shared_file'\n "
65
+ email: teohuiming@gmail.com
66
+ executables: []
67
+ extensions: []
68
+ extra_rdoc_files:
69
+ - LICENSE.txt
70
+ - README.rdoc
71
+ files:
72
+ - .document
73
+ - Gemfile
74
+ - Gemfile.lock
75
+ - LICENSE.txt
76
+ - README.rdoc
77
+ - Rakefile
78
+ - VERSION
79
+ - capistrano-shared_file.gemspec
80
+ - lib/capistrano/shared_file.rb
81
+ homepage: http://github.com/teohm/capistrano-shared_file
82
+ licenses:
83
+ - MIT
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ segments:
95
+ - 0
96
+ hash: -955439828747405408
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 1.8.24
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: Capistrano recipe to symlink shared files e.g. config/database.yml
109
+ test_files: []