capistrano-strategy-copy_subdir 0.0.1

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.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-strategy-copy_subdir.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Uchio KONDO
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ # Capistrano::Strategy::CopySubdir
2
+
3
+ Introduce Capistrano::Deploy::Strategy::CopySubdir
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'capistrano-strategy-copy_subdir', github: "udzura/capistrano-strategy-copy_subdir"
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ ## Usage
16
+
17
+ set :deploy_subdir, "server-proj"
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano-strategy-copy_subdir'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-strategy-copy_subdir"
8
+ spec.version = Capistrano::Deploy::Strategy::CopySubdir::VERSION
9
+ spec.authors = ["Uchio KONDO", "Hidenori DOI"]
10
+ spec.email = ["udzura@udzura.jp"]
11
+ spec.description = %q{Introduce Capistrano::Deploy::Strategy::CopySubdir}
12
+ spec.summary = %q{Introduce Capistrano::Deploy::Strategy::CopySubdir}
13
+ spec.homepage = "https://github.com/udzura/capistrano-strategy-copy_subdir"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "capistrano", "~> 2.13.0"
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ end
@@ -0,0 +1 @@
1
+ require "capistrano/recipes/deploy/strategy/copy_subdir"
@@ -0,0 +1,102 @@
1
+ # coding: utf-8
2
+ #
3
+ require 'capistrano/recipes/deploy/strategy/base'
4
+ require 'capistrano/recipes/deploy/strategy/copy'
5
+
6
+ class Capistrano::Deploy::Strategy::CopySubdir < Capistrano::Deploy::Strategy::Copy
7
+ VERSION = "0.0.1"
8
+ # Obtains a copy of the source code locally (via the #command method),
9
+ # compresses it to a single file, copies that file to all target
10
+ # servers, and uncompresses it on each of them into the deployment
11
+ # directory.
12
+ def deploy!
13
+ if copy_cache
14
+ if File.exists?(copy_cache)
15
+ logger.debug "refreshing local cache to revision #{revision} at #{copy_cache}"
16
+ system(source.sync(revision, copy_cache))
17
+ else
18
+ logger.debug "preparing local cache at #{copy_cache}"
19
+ system(source.checkout(revision, copy_cache))
20
+ end
21
+
22
+ # Check the return code of last system command and rollback if not 0
23
+ unless $? == 0
24
+ raise Capistrano::Error, "shell command failed with return code #{$?}"
25
+ end
26
+
27
+ FileUtils.mkdir_p(destination)
28
+
29
+ logger.debug "copying cache to deployment staging area #{destination}"
30
+ Dir.chdir(copy_cache) do
31
+ queue = Dir.glob("*", File::FNM_DOTMATCH)
32
+ while queue.any?
33
+ item = queue.shift
34
+ name = File.basename(item)
35
+
36
+ next if name == "." || name == ".."
37
+ next if copy_exclude.any? { |pattern| File.fnmatch(pattern, item) }
38
+
39
+ if File.symlink?(item)
40
+ FileUtils.ln_s(File.readlink(item), File.join(destination, item))
41
+ elsif File.directory?(item)
42
+ queue += Dir.glob("#{item}/*", File::FNM_DOTMATCH)
43
+ FileUtils.mkdir(File.join(destination, item))
44
+ else
45
+ FileUtils.ln(item, File.join(destination, item))
46
+ end
47
+ end
48
+ end
49
+ else
50
+ logger.debug "getting (via #{copy_strategy}) revision #{revision} to #{destination}"
51
+ system(command)
52
+
53
+ if copy_exclude.any?
54
+ logger.debug "processing exclusions..."
55
+ if copy_exclude.any?
56
+ copy_exclude.each do |pattern|
57
+ delete_list = Dir.glob(File.join(destination, pattern), File::FNM_DOTMATCH)
58
+ # avoid the /.. trap that deletes the parent directories
59
+ delete_list.delete_if { |dir| dir =~ /\/\.\.$/ }
60
+ FileUtils.rm_rf(delete_list.compact)
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ # merge stuffs under specific dirs
67
+ if configuration[:merge_dirs]
68
+ configuration[:merge_dirs].each do |dir, dest|
69
+ from = Pathname.new(destination) + dir
70
+ to = Pathname.new(destination) + dest
71
+ logger.trace "#{from} > #{to}"
72
+ FileUtils.mkdir_p(to)
73
+ FileUtils.cp_r(Dir.glob(from), to)
74
+ end
75
+ end
76
+
77
+ # for a rails application in sub directory
78
+ # set :deploy_subdir, "rails"
79
+ if configuration[:deploy_subdir]
80
+ subdir = configuration[:deploy_subdir]
81
+ logger.trace "deploy subdir #{destination}/#{subdir}"
82
+ Dir.mktmpdir do |dir|
83
+ FileUtils.move("#{destination}/#{subdir}", dir)
84
+ FileUtils.rm_rf destination rescue nil
85
+ FileUtils.move("#{dir}/#{subdir}", "#{destination}")
86
+ end
87
+ end
88
+
89
+ File.open(File.join(destination, "REVISION"), "w") { |f| f.puts(revision) }
90
+
91
+ logger.trace "compressing #{destination} to #{filename}"
92
+ Dir.chdir(copy_dir) { system(compress(File.basename(destination), File.basename(filename)).join(" ")) }
93
+
94
+ distribute!
95
+ ensure
96
+ puts $! if $!
97
+ FileUtils.rm filename rescue nil
98
+ FileUtils.rm_rf destination rescue nil
99
+ FileUtils.rm_rf copy_subdir rescue nil
100
+ end
101
+
102
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-strategy-copy_subdir
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Uchio KONDO
9
+ - Hidenori DOI
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-05-10 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: capistrano
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 2.13.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 2.13.0
31
+ - !ruby/object:Gem::Dependency
32
+ name: bundler
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '1.3'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '1.3'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ description: Introduce Capistrano::Deploy::Strategy::CopySubdir
64
+ email:
65
+ - udzura@udzura.jp
66
+ executables: []
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - .gitignore
71
+ - Gemfile
72
+ - LICENSE.txt
73
+ - README.md
74
+ - Rakefile
75
+ - capistrano-strategy-copy_subdir.gemspec
76
+ - lib/capistrano-strategy-copy_subdir.rb
77
+ - lib/capistrano/recipes/deploy/strategy/copy_subdir.rb
78
+ homepage: https://github.com/udzura/capistrano-strategy-copy_subdir
79
+ licenses:
80
+ - MIT
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ segments:
92
+ - 0
93
+ hash: 4153424398010119768
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ segments:
101
+ - 0
102
+ hash: 4153424398010119768
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 1.8.23
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: Introduce Capistrano::Deploy::Strategy::CopySubdir
109
+ test_files: []