capistrano-sync-assets 0.0.9 → 0.1.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.
- checksums.yaml +4 -4
- data/Changelog.md +5 -0
- data/LICENCE +20 -0
- data/README.markdown +43 -1
- data/Rakefile +2 -0
- data/capistrano-sync-assets.gemspec +1 -0
- data/lib/capistrano/sync/assets/asset.rb +7 -7
- data/lib/capistrano/sync/assets/utils.rb +28 -24
- data/lib/capistrano/sync/assets/version.rb +1 -1
- data/lib/capistrano/sync/tasks/assets.rake +7 -6
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24550d4e7075ce4d8755f4f5ddf69dc3f718d214
|
4
|
+
data.tar.gz: e8659fa4585309e7ec1bd2d048c1591ebaa3adc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c5206e828b21012d4327f8401a31a5caa48e502c0c76a59edfef419d55e9377f102b928c8602e82c4655efa081451d82f609d8d5c5ea35095fda2b67b1d03af
|
7
|
+
data.tar.gz: 7d4fbf38619d792c0fda02b6b6f9c4369c93bbdf2c899658863eafdaedc18d067a88c722f1fd7647a5eb5d03487e0812bd5902a4241dce68d9d92f5972878121
|
data/Changelog.md
ADDED
data/LICENCE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2015 David Fu
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
CHANGED
@@ -1,5 +1,47 @@
|
|
1
1
|
Capistrano Assets sync
|
2
2
|
======================
|
3
3
|
|
4
|
-
|
4
|
+
a easy way to synchronize assets between local and remote. by default, it will backup the current asset by rename it end with 'bak'(eg, change 'system' to 'system_bak'), and delete the previous backup.
|
5
5
|
It only works with capistrano 3.
|
6
|
+
|
7
|
+
Usage
|
8
|
+
=======
|
9
|
+
|
10
|
+
#### In your Gemfile:
|
11
|
+
Add it to Gemfile on development group
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'capistrano-sync-assets', require: false, group: :development
|
15
|
+
```
|
16
|
+
|
17
|
+
#### In your Capfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require 'capistrano/sync/assets'
|
21
|
+
```
|
22
|
+
|
23
|
+
#### In your `deploy.rb` or `deploy/production.rb` or other environment deploy config
|
24
|
+
set the sync dirs, such as 'public/uploads', 'public/system'. NOTE that these dirs should be existed in `linked_dirs`, which means that this gem only sync the dirs in **shared/** directory.
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
set :sync_assets_dirs, fetch(:sync_assets_dirs, []).push('public/uploads')
|
28
|
+
```
|
29
|
+
|
30
|
+
then you can sync the assets between your local machine and server.
|
31
|
+
|
32
|
+
```
|
33
|
+
cap sync:assets:pull # Synchronize your local assets using remote assets
|
34
|
+
cap sync:assets:push # Synchronize your remote assets using local assets
|
35
|
+
```
|
36
|
+
|
37
|
+
Contributing
|
38
|
+
============
|
39
|
+
|
40
|
+
1. Fork it
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create new Pull Request
|
45
|
+
|
46
|
+
------
|
47
|
+
Copyright (c) 2015 [David lingzhi], released under the MIT license
|
data/Rakefile
ADDED
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.license = 'MIT'
|
11
11
|
s.authors = ['David Fu']
|
12
12
|
s.email = ['lexuszhi1990@gmail.com']
|
13
|
+
s.homepage = "https://github.com/lexuszhi1990/capistrano-sync-assets"
|
13
14
|
s.summary = %q{Capistrano 3 extensions for assets sync}
|
14
15
|
s.description = %q{A collection of capistrano tasks for syncing assets}
|
15
16
|
s.files = `git ls-files`.split("\n")
|
@@ -7,23 +7,23 @@ module Capistrano
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def pull(local_asset_dir, server_asset_dir)
|
10
|
-
system "rsync -avrt --recursive --times --compress --human-readable --progress --delete --rsh='ssh -p #{@port}' #{@user_host}:#{server_asset_dir} #{local_asset_dir}"
|
10
|
+
system "rsync -avrt --recursive --times --compress --human-readable --progress --delete --rsh='ssh -p #{@port}' #{@user_host}:#{server_asset_dir}/ #{local_asset_dir}/"
|
11
11
|
end
|
12
12
|
|
13
|
-
def push(
|
14
|
-
system "rsync -avrt --recursive --times --compress --human-readable --progress --delete --rsh='ssh -p #{@port}' #{local_asset_dir} #{@user_host}:#{server_asset_dir}"
|
13
|
+
def push(local_asset_dir, server_asset_dir)
|
14
|
+
system "rsync -avrt --recursive --times --compress --human-readable --progress --delete --rsh='ssh -p #{@port}' #{local_asset_dir}/ #{@user_host}:#{server_asset_dir}/"
|
15
15
|
end
|
16
16
|
|
17
17
|
def backup_local_asset(local_asset_dir)
|
18
18
|
local_backup_dir = "#{local_asset_dir}_bak"
|
19
19
|
system("rm -r #{local_backup_dir}") if Dir.exist?(local_backup_dir)
|
20
|
-
system("
|
20
|
+
system("mv #{local_asset_dir} #{local_backup_dir}") if Dir.exist?(local_asset_dir)
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
23
|
+
def backup_server_asset_cmd(server_asset_dir)
|
24
24
|
delete_exist_backup = "if [ -e #{server_asset_dir}_bak ]; then rm -r #{server_asset_dir}_bak; fi"
|
25
|
-
backup_assets = "if [ -e #{server_asset_dir} ]; then
|
26
|
-
|
25
|
+
backup_assets = "if [ -e #{server_asset_dir} ]; then mv #{server_asset_dir} #{server_asset_dir}_bak; fi"
|
26
|
+
[delete_exist_backup, backup_assets].join(";")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -1,28 +1,32 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
1
|
+
module Capistrano
|
2
|
+
module Sync
|
3
|
+
module Utils
|
4
|
+
class << self
|
5
|
+
def assets_dir(dir="")
|
6
|
+
# Benchmark.ips do |x|
|
7
|
+
# x.report("dir[0, dir.length-1]") do
|
8
|
+
# string = "/Users/david/bs_repos/tmp_repo/eio/"
|
9
|
+
# string[0, string.length-1]
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# x.report("split('/').join") do
|
13
|
+
# "/Users/david/bs_repos/tmp_repo/eio/".split('/').join("/")
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# x.compare!
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# Comparison:
|
20
|
+
# dir[0, dir.length-1]: 1844071.9 i/s
|
21
|
+
# split('/').join: 406966.0 i/s - 4.53x slower
|
22
|
+
dir.end_with?('/') ? dir[0, dir.length-1] : dir
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
def yes_or_no?(msg, prompt = "(y)es, (n)o")
|
26
|
+
ask(:answer, "#{msg} #{prompt}")
|
27
|
+
(fetch(:answer) =~ /^y$|^yes$/i) == 0
|
28
|
+
end
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
@@ -11,10 +11,11 @@ namespace :sync do
|
|
11
11
|
info "the assets dirs as #{sync_assets_dirs.join(', ')}"
|
12
12
|
asset = Capistrano::Sync::Asset.new(self)
|
13
13
|
sync_assets_dirs.each do |dir|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
# TODO: change the use of Capistrano::Sync::Utils to a light way
|
15
|
+
server_asset_dir = Capistrano::Sync::Utils.assets_dir "#{shared_path}/#{dir}"
|
16
|
+
local_asset_dir = Capistrano::Sync::Utils.assets_dir "#{Dir.pwd}/#{dir}"
|
17
|
+
if Capistrano::Sync::Utils.yes_or_no?("Are you SURE to upload the local assets to remote?")
|
18
|
+
execute asset.backup_server_asset_cmd(server_asset_dir)
|
18
19
|
asset.push(local_asset_dir, server_asset_dir)
|
19
20
|
end
|
20
21
|
end
|
@@ -31,8 +32,8 @@ namespace :sync do
|
|
31
32
|
info "the assets dirs as #{sync_assets_dirs.join(', ')}"
|
32
33
|
asset = Capistrano::Sync::Asset.new(self)
|
33
34
|
sync_assets_dirs.each do |dir|
|
34
|
-
server_asset_dir = Utils.assets_dir "#{shared_path}/#{dir}"
|
35
|
-
local_asset_dir = Utils.assets_dir "#{Dir.pwd}/#{dir}"
|
35
|
+
server_asset_dir = Capistrano::Sync::Utils.assets_dir "#{shared_path}/#{dir}"
|
36
|
+
local_asset_dir = Capistrano::Sync::Utils.assets_dir "#{Dir.pwd}/#{dir}"
|
36
37
|
info "backup: moving #{local_asset_dir} to #{local_asset_dir}_bak"
|
37
38
|
asset.backup_local_asset(local_asset_dir)
|
38
39
|
info "sync the #{local_asset_dir} from server #{server_asset_dir}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-sync-assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Fu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -38,7 +38,10 @@ extensions: []
|
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
40
40
|
- ".gitignore"
|
41
|
+
- Changelog.md
|
42
|
+
- LICENCE
|
41
43
|
- README.markdown
|
44
|
+
- Rakefile
|
42
45
|
- capistrano-sync-assets.gemspec
|
43
46
|
- lib/capistrano-sync-assets.rb
|
44
47
|
- lib/capistrano/sync/assets.rb
|
@@ -46,7 +49,7 @@ files:
|
|
46
49
|
- lib/capistrano/sync/assets/utils.rb
|
47
50
|
- lib/capistrano/sync/assets/version.rb
|
48
51
|
- lib/capistrano/sync/tasks/assets.rake
|
49
|
-
homepage:
|
52
|
+
homepage: https://github.com/lexuszhi1990/capistrano-sync-assets
|
50
53
|
licenses:
|
51
54
|
- MIT
|
52
55
|
metadata: {}
|