capistrano-syncfiles 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 14f3dd6c418570a81f704b80c94b67ae9d2657db
4
+ data.tar.gz: b52c8d0ba32469a41d38300f8350e92f7c9c026a
5
+ SHA512:
6
+ metadata.gz: f5b4ae710b0e4483ad71c7fa9dde612d7b92529d98c5f82db5b246b7c48f3717d7c3262f5bf4c93f773a53a83d2856325c578a159131668242e1e30a197372fa
7
+ data.tar.gz: b6051c8550ea65b4ae978197a3b0a46e97abe54503ecb3c2dcb1bceaa63a5b5bd38a7f08b2b5ecf733efa567e8bc58d7a0ee88af0b4516889b5dfa0552d1a765
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+
20
+ Gemfile.lock
21
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 creative-workflow
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # capistrano-syncfiles
2
+
3
+ This gem provides up and down file syncing with rsync or tar. This could be usefull if you are in a shared hosting environment.
4
+
5
+ ## Installation
6
+ First make sure you install the capistrano-syncfiles by adding it to your `Gemfile`:
7
+
8
+ gem "capistrano-syncfiles"
9
+
10
+ Add to Capfile
11
+
12
+ require 'capistrano/syncfiles'
13
+
14
+ ## Configuration (deploy.rb)
15
+ Configure your files and folders like these:
16
+ ```
17
+ set :syncfiles, {
18
+ 'wordpress/wp-content/uploads' => { # local path
19
+ remote: 'wordpress/wp-content/uploads', # remote path
20
+ exclude: ['fvm', 'ithemes-security', 'wc-logs'] # excluded files
21
+ }
22
+ }
23
+
24
+ set :syncfiles_roles, :all # roles to run on, default: :all
25
+
26
+ set :syncfiles_temp_file # applies only to tar strategy, default: "/tmp/transfere-#{local_path.hash}.tar.gz"
27
+
28
+ set :syncfiles_tar_verbose # applies only to tar strategy, default: true
29
+ ```
30
+
31
+ ## Usage
32
+ The following tasks will be added
33
+ ```
34
+ cap syncfiles:rsync:down
35
+ cap syncfiles:rsync:up
36
+ cap syncfiles:tar:down
37
+ cap syncfiles:tar:up
38
+ ```
39
+
40
+ You can invoke this tasks(Rake) as you do normally: https://github.com/ruby/rake
41
+
42
+ Capistrano tasks: http://capistranorb.com/documentation/getting-started/flow/
43
+
44
+ ### License
45
+ The MIT License (MIT)
46
+
47
+ ### Changelog
48
+
49
+ 0.1.0
50
+ -----
51
+
52
+ - Initial release
data/Rakefile ADDED
File without changes
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "capistrano-syncfiles"
6
+ s.version = "0.1.0"
7
+ s.licenses = ["MIT"]
8
+ s.authors = ["Tom Hanoldt"]
9
+ s.email = ["tom@creative-workflow.berlin"]
10
+ s.homepage = "https://github.com/creative-workflow/capistrano-syncfiles"
11
+ s.summary = %q{This gem provides up and down file syncing with rsync or tar. This could be usefull if you are in a shared hosting environment.}
12
+ s.description = %q{This gem provides up and down file syncing with rsync or tar. This could be usefull if you are in a shared hosting environment.}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ # specify any dependencies here; for example:
20
+ s.add_dependency "capistrano", "~> 3.0"
21
+ end
@@ -0,0 +1 @@
1
+ load File.expand_path("tasks/syncfiles.rake", File.dirname(__FILE__))
@@ -0,0 +1,6 @@
1
+ namespace :syncfiles do
2
+ tasks = Dir[File.expand_path("syncfiles/*.rake", File.dirname(__FILE__))]
3
+ tasks.each do |task|
4
+ load task
5
+ end
6
+ end
@@ -0,0 +1,44 @@
1
+ namespace :rsync do
2
+ def build_server_string(role)
3
+ user = role.user + "@" if !role.user.nil?
4
+ "#{user}#{role.hostname}"
5
+ end
6
+
7
+ desc "Synchronise local and remote wp content folders via rsync"
8
+ task :up do
9
+ files = fetch(:syncfiles)
10
+ files.each do |local_path, config|
11
+ remote_path = config[:remote]
12
+ exclude_dir = Array(config[:exclude])
13
+ exclude_args = exclude_dir.map { |dir| "--exclude '#{dir}'"}
14
+ sync_roles = fetch(:syncfiles_roles, :all)
15
+
16
+ on release_roles sync_roles do |role|
17
+ server = build_server_string(role)
18
+
19
+ cmd = ["rsync -avzO #{local_path}/ #{server}:#{release_path}/#{remote_path}", *exclude_args]
20
+ puts cmd.join(' ')
21
+ system cmd.join(' ')
22
+ end
23
+ end
24
+ end
25
+
26
+ desc "Synchronise local and remote wp content folders via rsync"
27
+ task :down do
28
+ files = fetch(:syncfiles)
29
+ files.each do |local_path, config|
30
+ remote_path = config[:remote]
31
+ exclude_dir = Array(config[:exclude])
32
+ exclude_args = exclude_dir.map { |dir| "--exclude '#{dir}'"}
33
+ sync_roles = fetch(:syncfiles_roles, :all)
34
+
35
+ on release_roles sync_roles do |role|
36
+ server = build_server_string(role)
37
+
38
+ cmd = ["rsync -avzO #{server}:#{release_path}/#{remote_path}/ #{local_path}", *exclude_args]
39
+ puts cmd.join(' ')
40
+ system cmd.join(' ')
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,54 @@
1
+ namespace :tar do
2
+ desc "Synchronise local and remote wp content folders via rsync"
3
+ task :up do
4
+ files = fetch(:syncfiles)
5
+ files.each do |local_path, config|
6
+ archive_name = "transfere-#{local_path.hash}.tar.gz"
7
+ tar_verbose = fetch(:syncfiles_tar_verbose, true) ? "v" : ""
8
+ exclude_dir = Array(config[:exclude])
9
+ exclude_args = exclude_dir.map { |dir| "--exclude '#{dir}'"}
10
+
11
+ cmd = ["tar -c#{tar_verbose}zf #{archive_name} -C #{local_path} .", *exclude_args]
12
+ puts cmd.join(' ')
13
+ system cmd.join(' ')
14
+
15
+ tmp_file = fetch(:syncfiles_temp_file, "/tmp/#{archive_name}")
16
+ remote_path = config[:remote]
17
+ sync_roles = fetch(:syncfiles_roles, :all)
18
+
19
+ on release_roles sync_roles do
20
+ upload!(archive_name, tmp_file)
21
+ execute :tar, "-xzf", tmp_file, "-C", "#{release_path}/#{remote_path}"
22
+ execute :rm, tmp_file
23
+ end
24
+ system "rm -f #{archive_name}"
25
+ end
26
+ end
27
+
28
+ desc "Synchronise local and remote wp content folders via rsync"
29
+ task :down do
30
+ files = fetch(:syncfiles)
31
+ files.each do |local_path, config|
32
+ remote_path = config[:remote]
33
+ archive_name = "transfere-#{remote_path.hash}.tar.gz"
34
+ tmp_file = fetch(:syncfiles_temp_file, "/tmp/#{archive_name}")
35
+ tar_verbose = fetch(:syncfiles_tar_verbose, true) ? "v" : ""
36
+ exclude_dir = Array(config[:exclude])
37
+ exclude_args = exclude_dir.map { |dir| "--exclude '#{dir}'"}
38
+ sync_roles = fetch(:syncfiles_roles, :all)
39
+
40
+ on primary sync_roles do
41
+ execute :tar, "-c#{tar_verbose}zf", tmp_file, "-C", "#{release_path}/#{remote_path} .", *exclude_args
42
+
43
+ download!(tmp_file, archive_name)
44
+ execute :rm, tmp_file
45
+ end
46
+
47
+ cmd = "tar -xz#{tar_verbose}f #{archive_name} -C #{local_path}"
48
+ puts cmd
49
+ system cmd
50
+
51
+ system "rm -f #{archive_name}"
52
+ end
53
+ end
54
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-syncfiles
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Hanoldt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-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.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ description: This gem provides up and down file syncing with rsync or tar. This could
28
+ be usefull if you are in a shared hosting environment.
29
+ email:
30
+ - tom@creative-workflow.berlin
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".gitignore"
36
+ - Gemfile
37
+ - LICENSE
38
+ - README.md
39
+ - Rakefile
40
+ - capistrano-syncfiles.gemspec
41
+ - lib/capistrano/syncfiles.rb
42
+ - lib/capistrano/tasks/syncfiles.rake
43
+ - lib/capistrano/tasks/syncfiles/rsync.rake
44
+ - lib/capistrano/tasks/syncfiles/tar.rake
45
+ homepage: https://github.com/creative-workflow/capistrano-syncfiles
46
+ licenses:
47
+ - MIT
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 2.6.12
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: This gem provides up and down file syncing with rsync or tar. This could
69
+ be usefull if you are in a shared hosting environment.
70
+ test_files: []