capistrano-scm-rsync 0.1.0
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.
- checksums.yaml +7 -0
- data/.editorconfig +13 -0
- data/.gitattributes +6 -0
- data/.gitignore +4 -0
- data/.rspec +3 -0
- data/.rubocop.yml +19 -0
- data/.simplecov +21 -0
- data/.travis.yml +14 -0
- data/Gemfile +17 -0
- data/README.md +74 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/capistrano-scm-rsync.gemspec +23 -0
- data/lib/capistrano/scm/rsync.rb +89 -0
- data/lib/capistrano/scm/tasks/rsync.rake +26 -0
- data/lib/tasks/bundler.rake +1 -0
- data/lib/tasks/default.rake +1 -0
- data/lib/tasks/lint.rake +2 -0
- data/lib/tasks/rubocop.rake +7 -0
- data/lib/tasks/spec.rake +5 -0
- metadata +77 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fc812c38bbc6dafa63a18dddf31bbf6219393f3b
|
4
|
+
data.tar.gz: 398f5faaee863dd56bc4b1274fc90fe00871ef0d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8e95aca1feb28c0af635409dc178e38aff374598af0d84e860c089334c1e7be9f6596785fb827dafb616166ef75dbabd7f0f96376092bc37cef0a4422a5d2cd7
|
7
|
+
data.tar.gz: 46df3f733da3483e681f9ff3227e61bb75a77b09e6cf1c12ab31ee00cbacfd726883cb239388ffe60ad52101519f4ec688224bc011092a6012fe8a188e08464d
|
data/.editorconfig
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# This file is for unifying the coding style for different editors and IDEs.
|
2
|
+
# More information at http://EditorConfig.org
|
3
|
+
|
4
|
+
# No .editorconfig files above the root directory
|
5
|
+
root = true
|
6
|
+
|
7
|
+
[*]
|
8
|
+
indent_style = space
|
9
|
+
charset = utf-8
|
10
|
+
trim_trailing_whitespace = true
|
11
|
+
insert_final_newline = true
|
12
|
+
indent_style = space
|
13
|
+
indent_size = 2
|
data/.gitattributes
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisplayCopNames: true
|
3
|
+
|
4
|
+
require: rubocop-rspec
|
5
|
+
|
6
|
+
Style/Documentation:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Metrics/LineLength:
|
10
|
+
Max: 120
|
11
|
+
|
12
|
+
RSpec/NamedSubject:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
RSpec/ExampleLength:
|
16
|
+
Max: 10
|
17
|
+
|
18
|
+
RSpec/NestedGroups:
|
19
|
+
MaxNesting: 4
|
data/.simplecov
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
require 'coveralls'
|
5
|
+
|
6
|
+
SimpleCov.start do
|
7
|
+
track_files('lib/**/*.rb')
|
8
|
+
|
9
|
+
add_filter do |file|
|
10
|
+
relative_path = Pathname.new(file.filename)
|
11
|
+
.relative_path_from(Pathname.new(SimpleCov.root))
|
12
|
+
relative_path.to_s =~ %r{^spec/}
|
13
|
+
end
|
14
|
+
|
15
|
+
coverage_dir('coverage')
|
16
|
+
|
17
|
+
format = [::SimpleCov::Formatter::HTMLFormatter]
|
18
|
+
format << Coveralls::SimpleCov::Formatter if Coveralls.will_run?
|
19
|
+
|
20
|
+
formatter(::SimpleCov::Formatter::MultiFormatter.new(format))
|
21
|
+
end
|
data/.travis.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.1
|
5
|
+
- 2.2
|
6
|
+
- 2.3.3
|
7
|
+
|
8
|
+
before_install: gem install bundler
|
9
|
+
after_success:
|
10
|
+
- bundle exec codeclimate-test-reporter
|
11
|
+
|
12
|
+
addons:
|
13
|
+
code_climate:
|
14
|
+
repo_token: 22322d923b03d8476d20a367aac12ade706f39686d4fc08b9a19978276cb68f1
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in capistrano-scm-rsync.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem 'bundler', '~> 1.13'
|
8
|
+
gem 'rake', '~> 10.0'
|
9
|
+
gem 'rspec', '~> 3.0'
|
10
|
+
|
11
|
+
gem 'rubocop', '~> 0.46'
|
12
|
+
gem 'rubocop-rspec'
|
13
|
+
|
14
|
+
gem 'codeclimate-test-reporter'
|
15
|
+
gem 'coveralls'
|
16
|
+
gem 'simplecov'
|
17
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Capistrano::Scm::Rsync
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/capistrano-scm-rsync)
|
4
|
+
[](https://travis-ci.org/agross/capistrano-scm-rsync)
|
5
|
+
[](https://gemnasium.com/agross/capistrano-scm-rsync)
|
6
|
+
[](https://codeclimate.com/github/agross/capistrano-scm-rsync)
|
7
|
+
[](https://coveralls.io/r/agross/capistrano-scm-rsync)
|
8
|
+
|
9
|
+
`capistrano-scm-rsync` allows you to use rsync to deploy your application to your servers.
|
10
|
+
|
11
|
+
* Tested against Ruby 2.x
|
12
|
+
* Ruby < 2.0 is not supported
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add it to your `Gemfile`:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'capistrano-scm-rsync'
|
20
|
+
```
|
21
|
+
|
22
|
+
```sh
|
23
|
+
$ bundle install
|
24
|
+
```
|
25
|
+
|
26
|
+
Use the plugin with capistrano by adding it to your `Capfile`:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require 'capistrano/scm/rsync'
|
30
|
+
install_plugin Capistrano::SCM::Rsync
|
31
|
+
```
|
32
|
+
|
33
|
+
## Configuration
|
34
|
+
|
35
|
+
In your `config/deploy.rb`:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
set :rsync_options,
|
39
|
+
# The local directory to be copied to the server.
|
40
|
+
source: 'app',
|
41
|
+
# The cache directory on the server that receives files
|
42
|
+
# from the source directory. Relative to shared_path or
|
43
|
+
# an absolute path.
|
44
|
+
# Saves you rsyncing your whole app folder each time. If
|
45
|
+
# set to nil Capistrano::SCM::Rsync will sync directly to
|
46
|
+
# the release_path.
|
47
|
+
cache: 'cache',
|
48
|
+
# Arguments passed to rsync when...
|
49
|
+
args: {
|
50
|
+
# ...copying the local directory to the server.
|
51
|
+
local_to_remote: [],
|
52
|
+
# ...copying the cache directory to the release_path.
|
53
|
+
cache_to_release: %w(--archive --acls --xattrs)
|
54
|
+
}
|
55
|
+
```
|
56
|
+
|
57
|
+
## Example
|
58
|
+
|
59
|
+
See https://github.com/dnugleipzig/deploy.
|
60
|
+
|
61
|
+
## Development
|
62
|
+
|
63
|
+
* Source hosted at [GitHub](https://github.com/agross/capistrano-scm-rsync)
|
64
|
+
* Report issues/Questions/Feature requests on [GitHub Issues](https://github.com/agross/capistrano-scm-rsync/issues)
|
65
|
+
|
66
|
+
Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make.
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
1. Fork it http://github.com/agross/capistrano-scm-rsync/fork
|
71
|
+
1. Create your feature branch (`git checkout -b my-new-feature`)
|
72
|
+
1. Commit your changes (`git commit -am 'Add some feature'`)
|
73
|
+
1. Push to the branch (`git push origin my-new-feature`)
|
74
|
+
1. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Dir['lib/tasks/*.rake'].each { |file| load(file) }
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'capistrano/scm/rsync'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'capistrano-scm-rsync'
|
7
|
+
spec.version = '0.1.0'
|
8
|
+
spec.authors = ['Alexander Groß']
|
9
|
+
spec.email = %w(agross@therightstuff.de)
|
10
|
+
|
11
|
+
spec.summary = 'capistrano deployments using rsync as the SCM'
|
12
|
+
spec.description = 'Uses rsync to copy a local directory to your deployment servers'
|
13
|
+
spec.homepage = 'https://github.com/agross/capistrano-scm-rsync'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = %w(lib)
|
21
|
+
|
22
|
+
spec.add_dependency 'capistrano', '~> 3.7'
|
23
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'capistrano/scm/plugin'
|
2
|
+
|
3
|
+
module Capistrano
|
4
|
+
class SCM
|
5
|
+
class Rsync < ::Capistrano::SCM::Plugin
|
6
|
+
def set_defaults
|
7
|
+
set_if_empty :rsync_options,
|
8
|
+
# The local directory to be copied to the server.
|
9
|
+
source: 'app',
|
10
|
+
# The cache directory on the server that receives files
|
11
|
+
# from the source directory. Relative to shared_path or
|
12
|
+
# an absolute path.
|
13
|
+
# Saves you rsyncing your whole app folder each time. If
|
14
|
+
# set to nil Capistrano::SCM::Rsync will sync directly to
|
15
|
+
# the release_path.
|
16
|
+
cache: 'cache',
|
17
|
+
# Arguments passed to rsync when...
|
18
|
+
args: {
|
19
|
+
# ...copying the local directory to the server.
|
20
|
+
local_to_remote: [],
|
21
|
+
# ...copying the cache directory to the release_path.
|
22
|
+
cache_to_release: %w(--archive --acls --xattrs)
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def define_tasks
|
27
|
+
eval_rakefile(File.expand_path('../tasks/rsync.rake', __FILE__))
|
28
|
+
end
|
29
|
+
|
30
|
+
def register_hooks
|
31
|
+
after 'deploy:new_release_path', 'rsync:create_release'
|
32
|
+
before 'deploy:set_current_revision', 'rsync:set_current_revision'
|
33
|
+
end
|
34
|
+
|
35
|
+
def copy_local_to_remote(role)
|
36
|
+
if dry_run?
|
37
|
+
puts "Would execute: #{rsync_command(role).inspect}"
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
41
|
+
RakeFileUtils.sh(*rsync_command(role))
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_release
|
45
|
+
# Skip copying if we've already synced straight to the release directory.
|
46
|
+
return unless remote_cache
|
47
|
+
|
48
|
+
copy = [
|
49
|
+
'rsync',
|
50
|
+
fetch(:rsync_options)[:args][:cache_to_release],
|
51
|
+
File.join(remote_directory, '/').shellescape,
|
52
|
+
'.'
|
53
|
+
].flatten
|
54
|
+
|
55
|
+
backend.execute(*copy)
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def rsync_command(role)
|
61
|
+
rsync = %w(rsync) + fetch(:rsync_options)[:args][:local_to_remote]
|
62
|
+
rsync << File.join(fetch(:rsync_options)[:source], '/')
|
63
|
+
rsync << "#{remote_user(role)}#{role.hostname}:#{remote_directory}"
|
64
|
+
end
|
65
|
+
|
66
|
+
def remote_user(role)
|
67
|
+
user = if role.user
|
68
|
+
role.user
|
69
|
+
elsif fetch(:ssh_options)[:user]
|
70
|
+
fetch(:ssh_options)[:user]
|
71
|
+
end
|
72
|
+
|
73
|
+
"#{user}@" unless user.nil?
|
74
|
+
end
|
75
|
+
|
76
|
+
def remote_cache
|
77
|
+
fetch(:rsync_options)[:cache]
|
78
|
+
end
|
79
|
+
|
80
|
+
def remote_directory
|
81
|
+
return release_path unless remote_cache
|
82
|
+
|
83
|
+
cache = remote_cache
|
84
|
+
cache = File.join(shared_path, cache) if cache && cache !~ %r{^/}
|
85
|
+
cache
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# This trick lets us access the Rsync plugin within `on` blocks.
|
2
|
+
rsync_plugin = self
|
3
|
+
|
4
|
+
namespace :rsync do
|
5
|
+
desc 'Copy the local source directory to the remote cache or release directory'
|
6
|
+
task :copy_local_to_remote do
|
7
|
+
on release_roles(:all) do |role|
|
8
|
+
rsync_plugin.copy_local_to_remote(role)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'Create new release'
|
13
|
+
task create_release: [:copy_local_to_remote] do
|
14
|
+
on release_roles(:all) do
|
15
|
+
execute :mkdir, '-p', release_path
|
16
|
+
|
17
|
+
within release_path do
|
18
|
+
rsync_plugin.create_release
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
task :set_current_revision do
|
24
|
+
set_if_empty :current_revision, now
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1 @@
|
|
1
|
+
task default: [:lint, :spec]
|
data/lib/tasks/lint.rake
ADDED
data/lib/tasks/spec.rake
ADDED
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-scm-rsync
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Groß
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-18 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.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.7'
|
27
|
+
description: Uses rsync to copy a local directory to your deployment servers
|
28
|
+
email:
|
29
|
+
- agross@therightstuff.de
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".editorconfig"
|
35
|
+
- ".gitattributes"
|
36
|
+
- ".gitignore"
|
37
|
+
- ".rspec"
|
38
|
+
- ".rubocop.yml"
|
39
|
+
- ".simplecov"
|
40
|
+
- ".travis.yml"
|
41
|
+
- Gemfile
|
42
|
+
- README.md
|
43
|
+
- Rakefile
|
44
|
+
- bin/console
|
45
|
+
- bin/setup
|
46
|
+
- capistrano-scm-rsync.gemspec
|
47
|
+
- lib/capistrano/scm/rsync.rb
|
48
|
+
- lib/capistrano/scm/tasks/rsync.rake
|
49
|
+
- lib/tasks/bundler.rake
|
50
|
+
- lib/tasks/default.rake
|
51
|
+
- lib/tasks/lint.rake
|
52
|
+
- lib/tasks/rubocop.rake
|
53
|
+
- lib/tasks/spec.rake
|
54
|
+
homepage: https://github.com/agross/capistrano-scm-rsync
|
55
|
+
licenses: []
|
56
|
+
metadata: {}
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 2.5.2
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: capistrano deployments using rsync as the SCM
|
77
|
+
test_files: []
|