capistrano-exts 1.3.3 → 1.3.4

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.3.3'
20
+ gem 'capistrano-exts', '>=1.3.4'
21
21
  ```
22
22
 
23
23
  Setup
@@ -54,15 +54,18 @@ Capistrano::Configuration.instance(:must_exist).load do
54
54
  ['%']
55
55
  end
56
56
 
57
- def random_tmp_file(data = nil)
57
+ def generate_random_file_name(data = nil)
58
58
  if data.present?
59
- data_hash = Digest::SHA1.hexdigest data
60
- "/tmp/#{fetch :application}_#{Time.now.strftime('%d-%m-%Y_%H-%M-%S')}_#{data_hash}"
59
+ "#{fetch :application}_#{Time.now.strftime('%d-%m-%Y_%H-%M-%S')}_#{Digest::SHA1.hexdigest data}"
61
60
  else
62
- "/tmp/#{fetch :application}_#{Time.now.strftime('%d-%m-%Y_%H-%M-%S')}"
61
+ "#{fetch :application}_#{Time.now.strftime('%d-%m-%Y_%H-%M-%S')}"
63
62
  end
64
63
  end
65
64
 
65
+ def random_tmp_file(data = nil)
66
+ "/tmp/#{generate_random_file_name data}"
67
+ end
68
+
66
69
  # Helper for some mysql tasks
67
70
  def mysql_credentials_formatted(mysql_credentials)
68
71
  return <<-EOS
@@ -148,8 +148,6 @@ Capistrano::Configuration.instance(:must_exist).load do
148
148
 
149
149
  desc "Import a database dump"
150
150
  task :import_db_dump, :roles => :db, :except => { :no_release => true } do
151
- on_rollback { run "rm -f /tmp/#{mysql_db_name}_dump.sql" }
152
-
153
151
  mysql_credentials = fetch :mysql_credentials
154
152
  mysql_db_name = fetch :mysql_db_name
155
153
 
@@ -161,12 +159,18 @@ Capistrano::Configuration.instance(:must_exist).load do
161
159
  exit 1
162
160
  else
163
161
  # The database dump name
164
- dump_sql_file = ARGV.delete_at(argv_file_index)
162
+ dump_sql_file = ARGV[argv_file_index]
163
+ # Read the dump
164
+ mysql_dump = File.read(dump_sql_file)
165
+ # Generate a random file
166
+ random_file = random_tmp_file mysql_dump
167
+ # Add a rollback hook
168
+ on_rollback { run "rm -f #{random_file}" }
165
169
 
166
170
  if mysql_credentials.present?
167
171
  drop_db
168
172
  create_db
169
- put File.read(dump_sql_file), "/tmp/#{mysql_db_name}_dump.sql"
173
+ put File.read(dump_sql_file), random_file
170
174
 
171
175
  run <<-CMD
172
176
  mysql \
@@ -175,11 +179,11 @@ Capistrano::Configuration.instance(:must_exist).load do
175
179
  --password='#{mysql_credentials[:pass]}' \
176
180
  --default-character-set=utf8 \
177
181
  '#{mysql_db_name}' < \
178
- /tmp/#{mysql_db_name}_dump.sql
182
+ #{random_file}
179
183
  CMD
180
184
 
181
185
  run <<-CMD
182
- rm -f '/tmp/#{mysql_db_name}_dump.sql'
186
+ rm -f '#{random_file}'
183
187
  CMD
184
188
 
185
189
  exit 0
@@ -3,7 +3,7 @@ module Capistrano
3
3
  module Version #:nodoc:
4
4
  MAJOR = 1
5
5
  MINOR = 3
6
- TINY = 3
6
+ TINY = 4
7
7
 
8
8
  ARRAY = [MAJOR, MINOR, TINY]
9
9
  STRING = ARRAY.join(".")
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.3.3
4
+ version: 1.3.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-04 00:00:00.000000000 Z
12
+ date: 2011-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
16
- requirement: &2153261160 !ruby/object:Gem::Requirement
16
+ requirement: &2152783480 !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: *2153261160
24
+ version_requirements: *2152783480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: i18n
27
- requirement: &2151926960 !ruby/object:Gem::Requirement
27
+ requirement: &2152683500 !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: *2151926960
35
+ version_requirements: *2152683500
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activesupport
38
- requirement: &2151925340 !ruby/object:Gem::Requirement
38
+ requirement: &2152629920 !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: *2151925340
46
+ version_requirements: *2152629920
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard
49
- requirement: &2151923700 !ruby/object:Gem::Requirement
49
+ requirement: &2152451100 !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: *2151923700
57
+ version_requirements: *2152451100
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard-bundler
60
- requirement: &2151922900 !ruby/object:Gem::Requirement
60
+ requirement: &2152414620 !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: *2151922900
68
+ version_requirements: *2152414620
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-rspec
71
- requirement: &2151922300 !ruby/object:Gem::Requirement
71
+ requirement: &2156285880 !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: *2151922300
79
+ version_requirements: *2156285880
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rspec
82
- requirement: &2151921340 !ruby/object:Gem::Requirement
82
+ requirement: &2151922700 !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: *2151921340
90
+ version_requirements: *2151922700
91
91
  description: Handy extensions for Capistrano
92
92
  email:
93
93
  - wael.nasreddine@gmail.com