capistrano-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.
data/.gitignore ADDED
@@ -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-copy-subdir.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Yamashita Yuu
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.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # capistrano-copy-subdir
2
+
3
+ a capistrano strategy to deploy subdir with copy strategy.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'capistrano-copy-subdir'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install capistrano-copy-subdir
18
+
19
+ ## Usage
20
+
21
+ Write following snipet in your `config/deploy.rb`.
22
+
23
+ set(:deploy_via, :copy_subdir)
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
32
+
33
+ ## Author
34
+
35
+ - YAMASHITA Yuu (https://github.com/yyuu)
36
+ - Geisha Tokyo Entertainment Inc. (http://www.geishatokyo.com/)
37
+
38
+ ## License
39
+
40
+ MIT
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/capistrano-copy-subdir/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Yamashita Yuu"]
6
+ gem.email = ["yamashita@geishatokyo.com"]
7
+ gem.description = %q{a capistrano strategy to deploy subdir with copy strategy.}
8
+ gem.summary = %q{a capistrano strategy to deploy subdir with copy strategy.}
9
+ gem.homepage = "https://github.com/yyuu/capistrano-copy-subdir"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "capistrano-copy-subdir"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Capistrano::CopySubdir::VERSION
17
+
18
+ gem.add_dependency("capistrano")
19
+ end
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # a capistrano strategy to deploy sub-directory in the repository.
4
+ # this is a stuff like "remote_cache_subdir" strategy described in following page,
5
+ # but based on "copy" strategy of capistrano deploy recipe.
6
+ #
7
+ # http://stackoverflow.com/questions/29168/deploying-a-git-subdirectory-in-capistrano
8
+ #
9
+
10
+ require 'capistrano'
11
+ require 'capistrano/recipes/deploy/strategy/copy'
12
+ require 'capistrano-copy-subdir'
13
+ require 'tmpdir'
14
+
15
+ module Capistrano
16
+ module Deploy
17
+ module Strategy
18
+ class CopySubdir < Copy
19
+
20
+ def deploy!
21
+ update_repository_cache
22
+ copy_repository_cache
23
+ distribute!
24
+ ensure
25
+ FileUtils.rm filename rescue nil
26
+ FileUtils.rm_rf destination rescue nil
27
+ FileUtils.rm_rf repository_cache rescue nil if remove_repository_cache?
28
+ end
29
+
30
+ private
31
+
32
+ def update_repository_cache
33
+ if File.exists?(repository_cache)
34
+ logger.debug "refreshing local cache to revision #{revision} at #{repository_cache}"
35
+ system(source.sync(revision, repository_cache))
36
+ else
37
+ logger.debug "preparing local cache at #{repository_cache}"
38
+ system(source.checkout(revision, repository_cache))
39
+ end
40
+
41
+ # Check the return code of last system command and rollback if not 0
42
+ unless $? == 0
43
+ raise Capistrano::Error, "shell command failed with return code #{$?}"
44
+ end
45
+ end
46
+
47
+ def copy_repository_cache
48
+ logger.debug "copying cache from #{repository_cache_subdir} to deployment staging area #{destination}"
49
+ if copy_exclude.empty?
50
+ run_locally "cp -RPp #{repository_cache_subdir} #{destination} && #{mark}"
51
+ else
52
+ exclusions = copy_exclude.map { |e| "--exclude=\"#{e}\"" }.join(' ')
53
+ run_locally "rsync -lrpt #{exclusions} #{repository_cache_subdir}/ #{destination} && #{mark}"
54
+ end
55
+
56
+ logger.trace "compressing #{destination} to #{filename}"
57
+ Dir.chdir(copy_dir) { system(compress(File.basename(destination), File.basename(filename)).join(" ")) }
58
+ end
59
+
60
+ # Returns the command which will write the identifier of the
61
+ # revision being deployed to the REVISION file on each host.
62
+ def mark
63
+ "(echo #{revision} > #{destination}/REVISION)"
64
+ end
65
+
66
+ # Remote filename should be differ from local filename to allow deploy to localhost.
67
+ def remote_filename
68
+ @remote_filename ||= File.join(remote_dir, "copy-#{File.basename(destination)}.#{compression.extension}")
69
+ end
70
+
71
+ # Local repository path.
72
+ def repository_cache
73
+ @repository_cache ||= copy_cache || Dir.mktmpdir('cached-copy', copy_dir) { |dir| dir }
74
+ end
75
+
76
+ # Deploy subtree specified as :deploy_subdir in local repository.
77
+ def repository_cache_subdir
78
+ @repository_cache_subdir ||= if configuration[:deploy_subdir] then
79
+ File.join(repository_cache, configuration[:deploy_subdir])
80
+ else
81
+ repository_cache
82
+ end
83
+ end
84
+
85
+ # Remove local repository cache if :copy_cache is not enabled.
86
+ def remove_repository_cache?
87
+ !copy_cache
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+ # vim:set ft=ruby :
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module CopySubdir
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "capistrano-copy-subdir/version"
2
+
3
+ module Capistrano
4
+ module CopySubdir
5
+ # Your code goes here...
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-copy-subdir
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Yamashita Yuu
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: a capistrano strategy to deploy subdir with copy strategy.
31
+ email:
32
+ - yamashita@geishatokyo.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE
40
+ - README.md
41
+ - Rakefile
42
+ - capistrano-copy-subdir.gemspec
43
+ - lib/capistrano-copy-subdir.rb
44
+ - lib/capistrano-copy-subdir/version.rb
45
+ - lib/capistrano/recipes/deploy/strategy/copy_subdir.rb
46
+ homepage: https://github.com/yyuu/capistrano-copy-subdir
47
+ licenses: []
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 1.8.23
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: a capistrano strategy to deploy subdir with copy strategy.
70
+ test_files: []
71
+ has_rdoc: