capistrano-rsync-bladrak 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NGRlMGYwMGE4YjY1NzZmNjRiYmZiZGEwZTlkYmFiMTMyNWRiMmE3OQ==
5
+ data.tar.gz: !binary |-
6
+ YTczM2VlOGNmOGIwNTYxMzc0ZmZmNDA0MjQ3MWVjY2JmYTk5MmQwYg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MjFkNjRhOGJiNTYxZmIxYjM3NDhiOTliNDY5NDgxYjg1NGQ1ZGIwNzkwZTc4
10
+ MzU3ZDY1ZDRlNjM2YzA4OWRiMmE3NmQ1OGQ4OTMxYzYyNmM4ZmJhMGU3MGE5
11
+ NTIxMTQyZjFjMWZhMjU0YjhmYzRmMDViZWM5NmVkZTI2MmNlNjc=
12
+ data.tar.gz: !binary |-
13
+ M2U1ZTdjNWExNDU0MWMxNWJjM2Y3ZmFiMGE4NmE0ODNiZmQyNDJjNGQ0MzIz
14
+ Yjc3MWM3MTcyNzRlNTczMzA0YzdjMzNlM2JmN2VkOTA0OGY4MWNiZDNkNDFl
15
+ MDVlMzExNzY0ZDlkNTRhMzZjNzRiMTNmYmNkYTY4YWUzNjU3ZTU=
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ /*.gem
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ ## 1.0.2 (Oct 13, 2013)
2
+ - Updates README and code comments.
3
+
4
+ ## 1.0.1 (Sep 2, 2013)
5
+ - Updates README and adds implementation details to it.
6
+
7
+ ## 1.0.0 (Sep 2, 2013)
8
+ - Makes the `rsync:stage` task public for extending and hooking.
9
+ - Renames `rsync:create_release` to `rsync:release`. Old name still works.
10
+ - Adds optional caching to `rsync_cache` directory on the server.
11
+
12
+ ## 0.2.1 (Sep 1, 2013)
13
+ - Fixes starting with no previous local repository cache.
14
+ Note to self: Avoid writing code without integration tests.
15
+
16
+ ## 0.2.0 (Sep 1, 2013)
17
+ - Passes user given in `role :app, "user@host"` to `rsync` if set.
18
+
19
+ ## 0.1.338 (Sep 1, 2013)
20
+ - Adds gem dependency on Capistrano v3.
21
+
22
+ ## 0.1.337 (Sep 1, 2013)
23
+ - First release. Let's get syncing!
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Capistrano::Rsync
2
+ Copyright (C) 2013 Andri Möll
3
+
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License as published by the Free
6
+ Software Foundation, either version 3 of the License, or any later version.
7
+
8
+ Additional permission under the GNU Affero GPL version 3 section 7:
9
+ If you modify this Program, or any covered work, by linking or
10
+ combining it with other code, such other code is not for that reason
11
+ alone subject to any of the requirements of the GNU Affero GPL version 3.
12
+
13
+ In summary:
14
+ - You can use this program for no cost.
15
+ - You can use this program for both personal and commercial reasons.
16
+ - You do not have to share your own program's code which uses this program.
17
+ - You have to share modifications (e.g bug-fixes) you've made to this program.
18
+
19
+ For the full copy of the GNU Affero General Public License see:
20
+ http://www.gnu.org/licenses.
data/Makefile ADDED
@@ -0,0 +1,16 @@
1
+ NAME = capistrano-rsync-bladrak
2
+
3
+ love:
4
+ @echo "Feel like makin' love."
5
+
6
+ pack:
7
+ gem build $(NAME).gemspec
8
+
9
+ publish:
10
+ gem push $(NAME)-*.gem
11
+
12
+ clean:
13
+ rm -f *.gem
14
+
15
+ .PHONY: love pack publish
16
+ .PHONY: clean
data/README.md ADDED
@@ -0,0 +1,125 @@
1
+ Capistrano::Rsync for Capistrano v3
2
+ ===================================
3
+ [![Gem version][gem-badge]](http://badge.fury.io/rb/capistrano-rsync)
4
+ [gem-badge]: https://badge.fury.io/rb/capistrano-rsync.png
5
+
6
+ **Deploy with Rsync** to your server from any local (or remote) repository when
7
+ using [**Capistrano**](http://www.capistranorb.com/). Saves you from having to
8
+ install Git on your production machine and allows you to customize which files
9
+ you want to deploy. Also allows you to easily precompile things on your local
10
+ machine before deploying.
11
+
12
+ ### Tour
13
+ - Works with the new [**Capistrano v3**](http://www.capistranorb.com/) ([source
14
+ code](https://github.com/capistrano/capistrano)) versions `>= 3.0.0pre14` and
15
+ `< 4`.
16
+ - Suitable for deploying any apps, be it Ruby, Rails, Node.js or others.
17
+ - Exclude files from being deployed with Rsync's `--exclude` options.
18
+ - Precompile files or assets easily before deploying, like JavaScript or CSS.
19
+ - Caches your previously deployed code to speed up deployments ~1337%.
20
+ - Currently works only with Git (as does Capistrano v3), so please shout out
21
+ your interest in other SCMs.
22
+
23
+ Using [Mina](http://nadarei.co/mina/) instead of Capistrano? I've built
24
+ [Mina::Rsync](https://github.com/moll/mina-rsync) as well.
25
+
26
+
27
+ Using
28
+ -----
29
+ Install with:
30
+ ```
31
+ gem install capistrano-rsync
32
+ ```
33
+
34
+ Require it at the top of your `Capfile` (or `config/deploy.rb`):
35
+ ```ruby
36
+ require "capistrano/rsync"
37
+ ```
38
+
39
+ Set some `rsync_options` to your liking:
40
+ ```ruby
41
+ set :rsync_options, %w[--recursive --delete --delete-excluded --exclude .git*]
42
+ ```
43
+
44
+ And after setting regular Capistrano options, deploy as usual!
45
+ ```
46
+ cap deploy
47
+ ```
48
+
49
+ ### Implementation
50
+ 1. Clones and updates your repository to `rsync_stage` (defaults to
51
+ `tmp/deploy`) on your local machine.
52
+ 2. Checks out the branch set in the `branch` variable (defaults to `master`).
53
+ 3. If `rsync_cache` set (defaults to `shared/deploy`), rsyncs to that directory
54
+ on the server.
55
+ 4. If `rsync_cache` set, copies the content of that directory to a new release
56
+ directory.
57
+ 5. If `rsync_cache` is `nil`, rsyncs straight to a new release directory.
58
+
59
+ After that, Capistrano takes over and runs its usual tasks and symlinking.
60
+
61
+ ### Exclude files from being deployed
62
+ If you don't want to deploy everything you've committed to your repository, pass
63
+ some `--exclude` options to Rsync:
64
+ ```ruby
65
+ set :rsync_options, %w[
66
+ --recursive --delete --delete-excluded
67
+ --exclude .git*
68
+ --exclude /config/database.yml
69
+ --exclude /test/***
70
+ ]
71
+ ```
72
+
73
+ ### Precompile assets before deploy
74
+ Capistrano::Rsync runs `rsync:stage` before rsyncing. Hook to that like this:
75
+ ```ruby
76
+ task :precompile do
77
+ Dir.chdir fetch(:rsync_stage) do
78
+ system "rake", "assets:precompile"
79
+ end
80
+ end
81
+
82
+ after "rsync:stage", "precompile"
83
+ ```
84
+
85
+ ### Deploy release without symlinking the current directory
86
+ ```
87
+ cap rsync:release
88
+ ```
89
+
90
+
91
+ Configuration
92
+ -------------
93
+ Set Capistrano variables with `set name, value`.
94
+
95
+ Name | Default | Description
96
+ --------------|---------|------------
97
+ repo_url | `.` | The path or URL to a Git repository to clone from.
98
+ branch | `master` | The Git branch to checkout.
99
+ rsync_stage | `tmp/deploy` | Path where to clone your repository for staging, checkouting and rsyncing. Can be both relative or absolute.
100
+ 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.
101
+ rsync_options | `[]` | Array of options to pass to `rsync`.
102
+
103
+
104
+ License
105
+ -------
106
+ Capistrano::Rsync is released under a *Lesser GNU Affero General Public
107
+ License*, which in summary means:
108
+
109
+ - You **can** use this program for **no cost**.
110
+ - You **can** use this program for **both personal and commercial reasons**.
111
+ - You **do not have to share your own program's code** which uses this program.
112
+ - You **have to share modifications** (e.g bug-fixes) you've made to this
113
+ program.
114
+
115
+ For more convoluted language, see the `LICENSE` file.
116
+
117
+
118
+ About
119
+ -----
120
+ **[Andri Möll](http://themoll.com)** made this happen.
121
+ [Monday Calendar](https://mondayapp.com) was the reason I needed this.
122
+
123
+ If you find Capistrano::Rsync needs improving, please don't hesitate to type to
124
+ me now at [andri@dot.ee](mailto:andri@dot.ee) or [create an issue
125
+ online](https://github.com/moll/capistrano-rsync/issues).
@@ -0,0 +1,32 @@
1
+ require File.expand_path("../lib/capistrano/rsync/version", __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = "capistrano-rsync-bladrak"
5
+ gem.version = Capistrano::Rsync::VERSION
6
+ gem.homepage = "https://github.com/Bladrak/capistrano-rsync"
7
+ gem.summary = <<-end.strip.gsub(/\s*\n\s*/, " ")
8
+ Deploy with Rsync from any local (or remote) repository.
9
+ Capistrano v3 ready!
10
+ end
11
+
12
+ gem.description = <<-end.strip.gsub(/\s*?\n(\n?)\s*/, " \\1\\1")
13
+ Deploy with Rsync to your server from any local (or remote) repository.
14
+
15
+ Saves you the need to install Git on your production machine and deploy all
16
+ of your development files each time!
17
+
18
+ Works with the new Capistrano v3!
19
+ Suitable for deploying any apps, be it Ruby or Node.js.
20
+ end
21
+
22
+ gem.author = "Andri Möll, Hugo Briand"
23
+ gem.email = "andri@dot.ee, h.briand@gmail.com"
24
+ gem.license = "LAGPL"
25
+
26
+ gem.files = `git ls-files`.split($/)
27
+ gem.executables = gem.files.grep(/^bin\//).map(&File.method(:basename))
28
+ gem.test_files = gem.files.grep(/^spec\//)
29
+ gem.require_paths = ["lib"]
30
+
31
+ gem.add_dependency "capistrano", ">= 3.0.0.pre14", "< 4"
32
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Rsync
3
+ VERSION = "1.0.2"
4
+ end
5
+ end
@@ -0,0 +1,101 @@
1
+ require File.expand_path("../rsync/version", __FILE__)
2
+
3
+ # NOTE: Please don't depend on tasks without a description (`desc`) as they
4
+ # might change between minor or patch version releases. They make up the
5
+ # private API and internals of Capistrano::Rsync. If you think something should
6
+ # be public for extending and hooking, please let me know!
7
+
8
+ set :rsync_options, []
9
+ set :rsync_copy, "rsync --archive --acls --xattrs"
10
+
11
+ # Stage is used on your local machine for rsyncing from.
12
+ set :rsync_stage, "tmp/deploy"
13
+
14
+ # Cache is used on the server to copy files to from to the release directory.
15
+ # Saves you rsyncing your whole app folder each time. If you nil rsync_cache,
16
+ # Capistrano::Rsync will sync straight to the release path.
17
+ set :rsync_cache, "shared/deploy"
18
+
19
+ set :rsync_target_dir, "/"
20
+
21
+ rsync_cache = lambda do
22
+ cache = fetch(:rsync_cache)
23
+ cache = deploy_to + "/" + cache if cache && cache !~ /^\//
24
+ cache
25
+ end
26
+
27
+ Rake::Task["deploy:check"].enhance ["rsync:hook_scm"]
28
+ Rake::Task["deploy:updating"].enhance ["rsync:hook_scm"]
29
+
30
+ desc "Stage and rsync to the server (or its cache)."
31
+ task :rsync => %w[rsync:stage] do
32
+ roles(:all).each do |role|
33
+ user = role.user + "@" if !role.user.nil?
34
+
35
+ rsync = %w[rsync]
36
+ rsync.concat fetch(:rsync_options)
37
+ rsync << fetch(:rsync_stage) + fetch(:rsync_target_dir)
38
+ rsync << "#{user}#{role.hostname}:#{rsync_cache.call || release_path}"
39
+
40
+ Kernel.system *rsync
41
+ end
42
+ end
43
+
44
+ namespace :rsync do
45
+ task :hook_scm do
46
+ Rake::Task.define_task("#{scm}:check") do
47
+ invoke "rsync:check"
48
+ end
49
+
50
+ Rake::Task.define_task("#{scm}:create_release") do
51
+ invoke "rsync:release"
52
+ end
53
+ end
54
+
55
+ task :check do
56
+ # Everything's a-okay inherently!
57
+ end
58
+
59
+ task :create_stage do
60
+ next if File.directory?(fetch(:rsync_stage))
61
+
62
+ clone = %W[git clone]
63
+ clone << fetch(:repo_url, ".")
64
+ clone << fetch(:rsync_stage)
65
+ Kernel.system *clone
66
+ end
67
+
68
+ desc "Stage the repository in a local directory."
69
+ task :stage => %w[create_stage] do
70
+ Dir.chdir fetch(:rsync_stage) do
71
+ update = %W[git fetch --quiet --all --prune]
72
+ Kernel.system *update
73
+
74
+ checkout = %W[git reset --hard origin/#{fetch(:branch)}]
75
+ Kernel.system *checkout
76
+ end
77
+ end
78
+
79
+ desc "Copy the code to the releases directory."
80
+ task :release => %w[rsync] do
81
+ # Skip copying if we've already synced straight to the release directory.
82
+ next if !fetch(:rsync_cache)
83
+
84
+ copy = %(#{fetch(:rsync_copy)} "#{rsync_cache.call}/" "#{release_path}/")
85
+ on roles(:all).each do execute copy end
86
+ end
87
+
88
+ # Matches the naming scheme of git tasks.
89
+ # Plus was part of the public API in Capistrano::Rsync <= v0.2.1.
90
+ task :create_release => %w[release]
91
+
92
+ # internally needed by capistrano's "deploy.rake"
93
+ task :set_current_revision do
94
+ run_locally do
95
+ within fetch(:rsync_stage) do
96
+ rev = capture(:git, 'rev-parse', 'HEAD')
97
+ set :current_revision, rev
98
+ end
99
+ end
100
+ end
101
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-rsync-bladrak
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Andri Möll, Hugo Briand
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-10 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.0.0.pre14
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '4'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0.pre14
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '4'
33
+ description: ! "Deploy with Rsync to your server from any local (or remote) repository.
34
+ \n\nSaves you the need to install Git on your production machine and deploy all
35
+ of your development files each time! \n\nWorks with the new Capistrano v3! Suitable
36
+ for deploying any apps, be it Ruby or Node.js."
37
+ email: andri@dot.ee, h.briand@gmail.com
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - .gitignore
43
+ - CHANGELOG.md
44
+ - LICENSE
45
+ - Makefile
46
+ - README.md
47
+ - capistrano-rsync-bladrak.gemspec
48
+ - lib/capistrano/rsync.rb
49
+ - lib/capistrano/rsync/version.rb
50
+ homepage: https://github.com/Bladrak/capistrano-rsync
51
+ licenses:
52
+ - LAGPL
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 2.3.0
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: Deploy with Rsync from any local (or remote) repository. Capistrano v3 ready!
74
+ test_files: []