capdrupal 0.9.6 → 0.9.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c94cf9149f6b6450d3a7de3ade14aac0e35e9bb
4
- data.tar.gz: 541cf834511583035b552bb2ad44732f1d679ca2
3
+ metadata.gz: 3209875e157bd6157a68282d0c439b10c69d09cb
4
+ data.tar.gz: 5b62f454802ef995effbfb92df6fc02ee0555b0d
5
5
  SHA512:
6
- metadata.gz: d9063d1560afa78b7f60bb62287526adc47ec0ae4888e7e3c9fbcbd5de2634beac94f1bf7cb1295589a31206aa17af91d5b85fa59cdf9a64a127b84ef9adc84d
7
- data.tar.gz: 7fefb0a106d047b306685b7ad4df191221b25b2f69d1bd21025fd74b27782389ce0a5b9f55ad12ca4038fe54122b7cbc72299d179d45d7289af7afd5db6eca87
6
+ metadata.gz: df1db6c6b1c08211dbfa297d3a7cd1052c812e8a2ec54c75279bd51ac13917c21e2aae8800b2aa35d8e9107ab3f792c5026181c19e98b8719b91fbe1d0aa6e6a
7
+ data.tar.gz: b8141fe494c8609a394829ad344ccb82c348d4e563c8cc978166d94c0dd898e85cfca89ddc91e2a679b207cb55083bcfcb41044b8bad5d8f758807b5cd7aaf72
data/README.markdown CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  This gem provides a number of tasks which are useful for deploying Drupal projects with [Capistrano](https://github.com/capistrano/capistrano).
4
4
 
5
+ # Capdrupal version
6
+
7
+
8
+ Capdrupal Gem Version | Branch | Capistrano Version | Drupal Version
9
+ --------------------- | ------ | ------------------ | --------------
10
+ 0.x | d7 | 2 | 7.x
11
+ 2.x | master | 3 | 8.x
12
+
5
13
 
6
14
  ## Installation
7
15
  [gems](http://rubygems.org) must be installed on your system first.
@@ -16,6 +24,28 @@ This gem provides a number of tasks which are useful for deploying Drupal projec
16
24
  $ cd capdrupal
17
25
  $ gem build capdrupal.gemspec
18
26
  $ gem install capdrupal-{version}.gem
27
+
28
+ ### Use Bundler to avoid conflict with Capistrano 3
29
+
30
+ This version use capistrano 2. Installation with [bundler](http://bundler.io/) let you use both version and avoid conflict.
31
+
32
+ Create a 'Gemfile' on the root of your project
33
+
34
+
35
+ group :development do
36
+ gem 'capistrano', '~> 2.15.5'
37
+ gem 'railsless-deploy'
38
+ gem 'capdrupal'
39
+ #other development gems...
40
+ end
41
+
42
+ Install the depencies
43
+
44
+ $ bundle install
45
+
46
+ Use capistrano throuw bundle
47
+
48
+ $ bundle exec cap deploy
19
49
 
20
50
 
21
51
  ## Configuration
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.5
1
+ 0.9.7
data/capdrupal.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'capdrupal'
5
- s.version = '0.9.6'
5
+ s.version = '0.9.7'
6
6
  s.license = 'MIT'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.description = <<-DESC
data/lib/capdrupal.rb CHANGED
@@ -19,23 +19,26 @@ Capistrano::Configuration.instance(:must_exist).load do
19
19
 
20
20
  _cset :runner_group, "www-data"
21
21
  _cset :group_writable, false
22
-
22
+
23
23
  _cset(:deploy_to) { "/var/www/#{application}" }
24
24
  _cset(:app_path) { "drupal" }
25
25
  _cset :shared_children, false
26
-
26
+
27
+ _cset :backup_path, "backups"
28
+ _cset :remote_tmp_dir, "/tmp"
29
+
27
30
  if download_drush
28
31
  depend :remote, :command, "curl"
29
32
  end
30
33
 
31
34
  after "deploy:finalize_update" do
32
-
35
+
33
36
  if download_drush
34
37
  drush.get
35
38
  end
36
-
39
+
37
40
  drupal.symlink_shared
38
-
41
+
39
42
  drush.site_offline
40
43
  drush.updatedb
41
44
  drush.cache_clear
@@ -46,7 +49,7 @@ Capistrano::Configuration.instance(:must_exist).load do
46
49
 
47
50
  # This is an optional step that can be defined.
48
51
  #after "deploy", "git:push_deploy_tag"
49
-
52
+
50
53
  namespace :deploy do
51
54
  desc <<-DESC
52
55
  Prepares one or more servers for deployment. Before you can use any \
@@ -71,7 +74,7 @@ Capistrano::Configuration.instance(:must_exist).load do
71
74
  end
72
75
  end
73
76
  end
74
-
77
+
75
78
  namespace :drupal do
76
79
  desc "Symlinks static directories and static files that need to remain between deployments"
77
80
  task :symlink_shared, :roles => :app, :except => { :no_release => true } do
@@ -95,7 +98,7 @@ Capistrano::Configuration.instance(:must_exist).load do
95
98
  end
96
99
  end
97
100
  end
98
-
101
+
99
102
  namespace :files do
100
103
  desc "Pull drupal sites files (from remote to local)"
101
104
  task :pull, :roles => :app, :except => { :no_release => true } do
@@ -130,7 +133,7 @@ Capistrano::Configuration.instance(:must_exist).load do
130
133
  end
131
134
 
132
135
  end
133
-
136
+
134
137
  namespace :drush do
135
138
 
136
139
  desc "Gets drush and installs it"
@@ -172,5 +175,85 @@ Capistrano::Configuration.instance(:must_exist).load do
172
175
  end
173
176
 
174
177
  end
175
-
178
+
179
+ # Inspired by Capifony project
180
+ namespace :database do
181
+ namespace :dump do
182
+ task :remote do
183
+ filename = "#{application}_dump.#{Time.now.utc.strftime("%Y%m%d%H%M%S")}.sql.gz"
184
+ sqlfile = "#{remote_tmp_dir}/#{filename}"
185
+
186
+ run "#{drush_cmd} -r #{latest_release}/#{app_path} sql-dump | gzip -9 > #{sqlfile}"
187
+
188
+ FileUtils::mkdir_p("#{backup_path}")
189
+
190
+ download(sqlfile, "#{backup_path}/#{filename}")
191
+
192
+ begin
193
+ FileUtils.ln_sf(filename, "#{backup_path}/#{application}_dump.latest.sql.gz")
194
+ rescue Exception # fallback for file systems that don't support symlinks
195
+ FileUtils.cp_r("#{backup_path}/#{filename}", "#{backup_path}/#{application}_dump.latest.sql.gz")
196
+ end
197
+
198
+ run "rm #{sqlfile}"
199
+ end
200
+
201
+ task :local do
202
+ filename = "#{application}.local_dump.#{Time.now.utc.strftime("%Y%m%d%H%M%S")}.sql.gz"
203
+ sqlfile = "#{backup_path}/#{filename}"
204
+
205
+ FileUtils::mkdir_p("#{backup_path}")
206
+
207
+ run_locally "cd #{app_path} && drush sql-dump | gzip -9 > ../#{sqlfile}"
208
+
209
+ begin
210
+ FileUtils.ln_sf(sqlfile, "#{backup_path}/#{application}.local_dump.latest.sql.gz")
211
+ rescue Exception # fallback for file systems that don't support symlinks
212
+ FileUtils.cp_r(sqlfile, "#{backup_path}/#{application}.local_dump.latest.sql.gz")
213
+ end
214
+
215
+ sqlfile
216
+ end
217
+ end
218
+
219
+ namespace :copy do
220
+ desc "Copy remote database into your local database"
221
+ task :to_local do
222
+ gzfile = "#{backup_path}/#{application}_dump.latest.sql.gz"
223
+ sqlfile = "#{backup_path}/#{application}_dump.sql"
224
+
225
+ database.dump.remote
226
+
227
+ # be sure the file not already exist before un-gziping it
228
+ if File.exist?(sqlfile)
229
+ FileUtils.rm(sqlfile)
230
+ end
231
+
232
+ f = File.new(sqlfile, "a+")
233
+ gz = Zlib::GzipReader.new(File.open(gzfile, "r"))
234
+ f << gz.read
235
+ f.close
236
+
237
+ run_locally "cd #{app_path} && drush sql-connect < ../#{sqlfile}"
238
+
239
+ FileUtils.rm(sqlfile)
240
+ end
241
+
242
+ desc "Copy local database to the remote database"
243
+ task :to_remote do
244
+ filename = "#{application}.local_dump.#{Time.now.utc.strftime("%Y%m%d%H%M%S")}.sql.gz"
245
+
246
+ if Capistrano::CLI.ui.agree("Do you really want to replace remote database by your local one? (y/N)") then
247
+ gzfile = database.dump.local
248
+
249
+ upload(gzfile, "#{remote_tmp_dir}/#{filename}")
250
+
251
+ mysqlcommand = capture("#{drush_cmd} -r #{latest_release}/#{app_path} sql-connect")
252
+ run "zcat #{remote_tmp_dir}/#{filename} | #{mysqlcommand}"
253
+
254
+ run "rm #{remote_tmp_dir}/#{filename}"
255
+ end
256
+ end
257
+ end
258
+ end
176
259
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capdrupal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.6
4
+ version: 0.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Perdrisat
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-06-14 00:00:00.000000000 Z
14
+ date: 2015-03-06 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: capistrano