cap_sync 0.0.2 → 0.0.3

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.
Files changed (4) hide show
  1. data/README.rdoc +9 -5
  2. data/cap_sync.gemspec +1 -1
  3. data/lib/cap_sync.rb +24 -5
  4. metadata +10 -5
@@ -10,7 +10,11 @@ Install the gem:
10
10
 
11
11
  Add following line to your Capfile:
12
12
 
13
- gem 'cap_sync'; require 'cap_sync'
13
+ if gem 'cap_sync'
14
+ require 'cap_sync'
15
+ else
16
+ puts '* Warning: Execute "gem install cap_sync" to make sync:db and sync:data work'
17
+ end
14
18
 
15
19
  = Syncing database
16
20
 
@@ -42,14 +46,14 @@ You can modify it in your deploy.rb as follows:
42
46
  Rsync's local and remote folders. By default, does incremental implicit synchronization.
43
47
 
44
48
  Available variables and defaults:
49
+ :sync_method => :rsync, # :rsync - sync with rsync, :cap - sync with capistrano
45
50
  :sync_folders => {"#{shared_path}/system" => "public/system"}, # Folders to sync remote => local
46
51
  :rsync_cmd => "rsync", # rsync command
47
52
  :rsync_flags => "-rv --stats --delete" # rsync flags
48
53
 
49
54
  = Todo
50
55
 
51
- 1. Correctly handle multiple servers.
56
+ 1. Correctly handle multiple servers (database).
52
57
  2. Tests.
53
- 3. Get gem to autoload, without require.
54
- 4. Sync multiple databases.
55
- 5. Sync up and down.
58
+ 3. Sync multiple databases.
59
+ 4. Sync up and down.
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "cap_sync"
6
- s.version = '0.0.2'
6
+ s.version = '0.0.3'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.author = "Victor Sokolov"
9
9
  s.email = "gzigzigzeo@gmail.com"
@@ -12,7 +12,8 @@ Capistrano::Configuration.instance(:must_exist).load do
12
12
 
13
13
  :sync_folders => {"#{shared_path}/system" => "public/system"}, # Folders to sync remote => local
14
14
  :rsync_cmd => "rsync", # rsync command
15
- :rsync_flags => "-rv --stats --delete" # rsync flags
15
+ :rsync_flags => "-rv --stats --delete", # rsync flags
16
+ :sync_method => :rsync # :rsync or :cap
16
17
  }.each do |var, value|
17
18
  self.set(var, value) unless exists?(var)
18
19
  end
@@ -35,10 +36,28 @@ Capistrano::Configuration.instance(:must_exist).load do
35
36
 
36
37
  desc "Sync remote production data with local development machine"
37
38
  task :data do
38
- sync_folders.each do |remote, local|
39
- host = find_servers(:roles => :web).first.host
40
- system("#{rsync_cmd} #{rsync_flags} #{user}@#{host}:#{remote}/. #{local}")
41
- end
39
+ if sync_method == :rsync
40
+ sync_folders.each do |remote, local|
41
+ host = find_servers(:roles => :web).first.host
42
+ system("#{rsync_cmd} #{rsync_flags} #{user}@#{host}:#{remote}/. #{local}")
43
+ end
44
+ elsif sync_method == :cap
45
+ sync_folders.each do |remote, local|
46
+ ::FileUtils.rm_rf(local, :verbose => true)
47
+ download(remote, local, :recursive => true) do |event, downloader, *args|
48
+ case event
49
+ when :close then
50
+ puts "finished with #{args[0].remote}"
51
+ when :mkdir then
52
+ puts "creating directory #{args[0]}"
53
+ when :finish then
54
+ puts "all done!"
55
+ end
56
+ end
57
+ end
58
+ else
59
+ raise ArgumentError, "Unknown sync method: should be :cap or :sync"
60
+ end
42
61
  end
43
62
  end
44
63
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cap_sync
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 25
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 2
9
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - Victor Sokolov
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-03-12 00:00:00 +03:00
18
+ date: 2011-04-27 00:00:00 +04:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -43,23 +44,27 @@ rdoc_options: []
43
44
  require_paths:
44
45
  - lib
45
46
  required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
46
48
  requirements:
47
49
  - - ">="
48
50
  - !ruby/object:Gem::Version
51
+ hash: 3
49
52
  segments:
50
53
  - 0
51
54
  version: "0"
52
55
  required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
53
57
  requirements:
54
58
  - - ">="
55
59
  - !ruby/object:Gem::Version
60
+ hash: 3
56
61
  segments:
57
62
  - 0
58
63
  version: "0"
59
64
  requirements: []
60
65
 
61
66
  rubyforge_project:
62
- rubygems_version: 1.3.6
67
+ rubygems_version: 1.6.0
63
68
  signing_key:
64
69
  specification_version: 3
65
70
  summary: Recipes to clone database & public data from production server to developement machine