capistrano-withrsync 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3dc836514cd56e010f35c2998c3bebb2265b8968
4
+ data.tar.gz: e13b8154050308fa253e6d7abeee4a488955ec9a
5
+ SHA512:
6
+ metadata.gz: d5de3c79d18374a49a24efcdd921d8dba6e07e5afbd38288f803250ca080e4af3d24072347bdad44bab443651eb5bc88facaed18c058c162c5ad19dfc46f9ea2
7
+ data.tar.gz: 63bebc5ed87b0012e09c17a37c47c24b636726fdb9a5ef05e5a5a1334696b5625b7616be619350541eeb1a9ba3137840c1fcfd450540da8438bfb69d702ebca5
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
18
+ vendor
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-withrsync.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 linyows
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,85 @@
1
+ Capistrano with Rsync
2
+ =====================
3
+
4
+ Capistrano with rsync to deployment hosts from local repository.
5
+
6
+ [![Gem version](https://badge.fury.io/rb/capistrano-withrsync.png)][gem]
7
+
8
+ [capistrano]: https://github.com/capistrano/capistrano
9
+ [gem]: https://rubygems.org/gems/capistrano-withrsync
10
+
11
+ Requirements
12
+ ------------
13
+
14
+ - Ruby >= 2.0
15
+ - Capistrano >= 3.1
16
+ - Rsync >= 2.6
17
+
18
+ Installation
19
+ ------------
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem 'capistrano-withrsync'
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ ```ruby
30
+ $ bundle
31
+ ```
32
+
33
+ Or install it yourself as:
34
+
35
+ ```ruby
36
+ $ gem install capistrano-withrsync
37
+ ```
38
+
39
+ Usage
40
+ -----
41
+
42
+ Capfile:
43
+
44
+ ```ruby
45
+ require 'capistrano/withrsync'
46
+ ```
47
+
48
+ deploy as usual
49
+
50
+ ```sh
51
+ $ cap deploy
52
+ ```
53
+
54
+ Configuration
55
+ -------------
56
+
57
+ Set capistrano variables with `set name, value`.
58
+
59
+ Name | Default | Description
60
+ ------------- |-------- |------------
61
+ rsync_stage | `tmp/deploy` | Path where to clone your repository for staging, checkouting and rsyncing. Can be both relative or absolute.
62
+ rsync_cache | `shared/deploy` | Path where to cache your repository on the server to avoid rsyncing from scratch each time. Can be both relative or absolute.<br> Set to `nil` if you want to disable the cache.
63
+ rsync_options | `%w(--recursive --delete --delete-excluded --exclude .git* --exclude .svn*)` | Array of options to pass to `rsync`.
64
+
65
+ Contributing
66
+ ------------
67
+
68
+ 1. Fork it ( http://github.com/<my-github-username>/capistrano-withrsync/fork )
69
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
70
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
71
+ 4. Push to the branch (`git push origin my-new-feature`)
72
+ 5. Create new Pull Request
73
+
74
+
75
+ Author
76
+ ------
77
+
78
+ - [linyows][linyows]
79
+
80
+ [linyows]: https://github.com/linyows
81
+
82
+ License
83
+ -------
84
+
85
+ The MIT License (MIT)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/withrsync/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-withrsync"
8
+ spec.version = Capistrano::Withrsync::VERSION
9
+ spec.authors = ["linyows"]
10
+ spec.email = ["linyows@gmail.com"]
11
+ spec.summary = %q{Capistrano with rsync}
12
+ spec.description = %q{Capistrano with rsync}
13
+ spec.homepage = "https://github.com/linyows/capistrano-withrsync"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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_dependency "capistrano", ">= 3.1"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.5"
24
+ spec.add_development_dependency "rake"
25
+ end
@@ -0,0 +1,111 @@
1
+ Rake::Task[:'deploy:check'].enhance [:'rsync:override_scm']
2
+ Rake::Task[:'deploy:updating'].enhance [:'rsync:override_scm']
3
+
4
+ namespace :rsync do
5
+ set :rsync_options, %w(
6
+ --recursive
7
+ --delete
8
+ --delete-excluded
9
+ --exclude .git*
10
+ --exclude .svn*
11
+ )
12
+
13
+ set :rsync_copy_options, %w(
14
+ --archive
15
+ --acls
16
+ --xattrs
17
+ )
18
+
19
+ set :rsync_stage, 'tmp/deploy'
20
+ set :rsync_cache, 'shared/deploy'
21
+
22
+ set :rsync_cache_path, -> {
23
+ cache = fetch(:rsync_cache)
24
+ cache = "#{deploy_to}/#{cache}" if cache && cache !~ /^\//
25
+ cache
26
+ }
27
+
28
+ desc 'Override scm tasks'
29
+ task :override_scm do
30
+ Rake::Task[:"#{scm}:check"].delete
31
+ Rake::Task.define_task(:"#{scm}:check") do
32
+ invoke :'rsync:check'
33
+ end
34
+
35
+ Rake::Task[:"#{scm}:create_release"].delete
36
+ Rake::Task.define_task(:"#{scm}:create_release") do
37
+ invoke :'rsync:release'
38
+ end
39
+ end
40
+
41
+ desc 'Check that the repository is reachable'
42
+ task :check do
43
+ run_locally do
44
+ exit 1 unless strategy.check
45
+ end
46
+
47
+ invoke :'rsync:create_dest'
48
+ end
49
+
50
+ desc 'Create a destination for rsync on deployment hosts'
51
+ task :create_dest do
52
+ on release_roles :all do
53
+ path = File.join fetch(:deploy_to), fetch(:rsync_cache)
54
+ execute :mkdir, '-pv', path
55
+ end
56
+ end
57
+
58
+ desc 'Create a source for rsync'
59
+ task :create_src do
60
+ next if File.directory? fetch(:rsync_stage)
61
+
62
+ run_locally do
63
+ execute :git, :clone, fetch(:repo_url), fetch(:rsync_stage)
64
+ end
65
+ end
66
+
67
+ desc 'Stage the repository in a local directory'
68
+ task stage: :'rsync:create_src' do
69
+ run_locally do
70
+ within fetch(:rsync_stage) do
71
+ execute :git, :fetch, '--quiet --all --prune'
72
+ execute :git, :reset, "--hard origin/#{fetch(:branch)}"
73
+ set :current_revision, "#{`git rev-parse --short HEAD`}".chomp
74
+ end
75
+ end
76
+ end
77
+
78
+ desc 'Sync to deployment hosts from local'
79
+ task sync: :'rsync:stage' do
80
+ last_rsync_to = nil
81
+ roles(:all).each do |role|
82
+ run_locally do
83
+ user = "#{role.user}@" if !role.user.nil?
84
+ rsync_options = "#{fetch(:rsync_options).join(' ')}"
85
+ rsync_from = "#{fetch(:rsync_stage)}/"
86
+ rsync_to = "#{user}#{role.hostname}:#{fetch(:rsync_cache_path) || release_path}"
87
+
88
+ unless rsync_to == last_rsync_to
89
+ execute :rsync, rsync_options, rsync_from, rsync_to
90
+ last_rsync_to = rsync_to
91
+ end
92
+ end
93
+ end
94
+ end
95
+
96
+ desc 'Copy the code to the releases directory'
97
+ task release: :'rsync:sync' do
98
+ next if !fetch(:rsync_cache)
99
+
100
+ on release_roles :all do
101
+ execute :rsync,
102
+ "#{fetch(:rsync_copy_options).join(' ')}",
103
+ "#{fetch(:rsync_cache_path)}/",
104
+ "#{release_path}/"
105
+ end
106
+ end
107
+
108
+ task :create_release do
109
+ invoke :'rsync:release'
110
+ end
111
+ end
@@ -0,0 +1,6 @@
1
+ class Rake::Task
2
+ def delete
3
+ self.clear
4
+ @full_comment = nil
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Withrsync
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require 'capistrano/withrsync/version'
2
+ require 'capistrano/withrsync/rake/task'
3
+ load File.expand_path('../../tasks/withrsync.rake', __FILE__)
4
+
5
+ module Capistrano
6
+ module Withrsync
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-withrsync
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - linyows
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Capistrano with rsync
56
+ email:
57
+ - linyows@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - capistrano-withrsync.gemspec
68
+ - lib/capistrano/tasks/withrsync.rake
69
+ - lib/capistrano/withrsync.rb
70
+ - lib/capistrano/withrsync/rake/task.rb
71
+ - lib/capistrano/withrsync/version.rb
72
+ homepage: https://github.com/linyows/capistrano-withrsync
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.2.0
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Capistrano with rsync
96
+ test_files: []