capistrano-exts 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -17,7 +17,7 @@ gem install capistrano-exts
17
17
  or add it to your Gemfile
18
18
 
19
19
  ```ruby
20
- gem 'capistrano-exts', '>=1.6.0'
20
+ gem 'capistrano-exts', '>=1.7.0'
21
21
  ```
22
22
 
23
23
  Setup
@@ -86,6 +86,38 @@ Capistrano::Configuration.instance.load do
86
86
  # Parse multistages
87
87
  multistages[stage].each { |config, value| set config, value }
88
88
  end
89
+
90
+ # Synchronisations tasks
91
+ # Don't you just love metaprogramming? I know I fucking do!
92
+ stages.each do |target_stage|
93
+ stages.reject { |s| s == target_stage }.each do |source_stage|
94
+ desc "Synchronise #{target_stage} with #{source_stage}"
95
+ task "sync_#{target_stage}_with_#{source_stage}", :roles => :app, :except => { :no_release => true } do
96
+ # Ask for a confirmation
97
+ response = ask("I am going to synchronise '#{target_stage}' with '#{source_stage}', it means I will overwrite both the database and the contents of '#{target_stage}' with those of '#{source_stage}', are you really sure you would like to continue (Yes, [No], Abort)", default:'N')
98
+ if response =~ /(no?)|(a(bort)?|\n)/i
99
+ abort "Canceled by the user."
100
+ end
101
+
102
+ # Generate a random folder name
103
+ random_folder = random_tmp_file
104
+
105
+ # Create the folder
106
+ FileUtils.mkdir_p random_folder
107
+
108
+ # Get the database/contents of the source
109
+ system "bundle exec cap #{source_stage} mysql:export_db_dump #{random_folder}/database.sql"
110
+ system "bundle exec cap #{source_stage} contents:export #{random_folder}/contents.tar.gz"
111
+
112
+ # Send them to the target
113
+ system "echo 'yes' | bundle exec cap #{target_stage} mysql:import_db_dump #{random_folder}/database.sql"
114
+ system "echo 'yes' | bundle exec cap #{target_stage} contents:import #{random_folder}/contents.tar.gz"
115
+
116
+ # Remove the entire folder
117
+ FileUtils.rm_rf random_folder
118
+ end
119
+ end
120
+ end
89
121
  end
90
122
 
91
123
  on :start, "multistage:ensure", :except => stages + ['multistage:setup', 'multistage:parse_multistages']
@@ -2,7 +2,7 @@ module Capistrano
2
2
  module Extensions
3
3
  module Version #:nodoc:
4
4
  MAJOR = 1
5
- MINOR = 6
5
+ MINOR = 7
6
6
  TINY = 0
7
7
 
8
8
  ARRAY = [MAJOR, MINOR, TINY]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-exts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-09-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
16
- requirement: &2156442460 !ruby/object:Gem::Requirement
16
+ requirement: &2152478500 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.8.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156442460
24
+ version_requirements: *2152478500
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: i18n
27
- requirement: &2156453940 !ruby/object:Gem::Requirement
27
+ requirement: &2152477960 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.6.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2156453940
35
+ version_requirements: *2152477960
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activesupport
38
- requirement: &2156453160 !ruby/object:Gem::Requirement
38
+ requirement: &2152477500 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 3.1.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2156453160
46
+ version_requirements: *2152477500
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard
49
- requirement: &2156451240 !ruby/object:Gem::Requirement
49
+ requirement: &2152476860 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.6.2
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2156451240
57
+ version_requirements: *2152476860
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard-bundler
60
- requirement: &2156479320 !ruby/object:Gem::Requirement
60
+ requirement: &2152476180 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.1.3
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2156479320
68
+ version_requirements: *2152476180
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-rspec
71
- requirement: &2156475160 !ruby/object:Gem::Requirement
71
+ requirement: &2152475460 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.4.3
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2156475160
79
+ version_requirements: *2152475460
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rspec
82
- requirement: &2156486700 !ruby/object:Gem::Requirement
82
+ requirement: &2152474740 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: 2.6.0
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2156486700
90
+ version_requirements: *2152474740
91
91
  description: Handy extensions for Capistrano
92
92
  email:
93
93
  - wael.nasreddine@gmail.com