capones_recipes 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.5.0
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{capones_recipes}
8
- s.version = "0.4.3"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Roman Simecek"]
@@ -46,13 +46,13 @@ Capistrano::Configuration.instance.load do
46
46
  DESC
47
47
  task :db, :roles => :db, :only => { :primary => true } do
48
48
  # Use production on non-multistage
49
- stage ||= 'production'
49
+ set :stage, 'production' unless exists?(:stage)
50
50
 
51
51
  filename = "database.#{stage}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2"
52
52
  on_rollback { delete "#{shared_path}/sync/#{filename}" }
53
53
 
54
54
  # Remote DB dump
55
- username, password, database, host = database_config(stage)
55
+ username, password, database, host = remote_database_config(stage)
56
56
  host_option = host ? "--host='#{host}'" : ""
57
57
  run "mysqldump -u #{username} --password='#{password}' #{host_option} #{database} | bzip2 -9 > #{shared_path}/sync/#{filename}" do |channel, stream, data|
58
58
  puts data
@@ -76,7 +76,7 @@ Capistrano::Configuration.instance.load do
76
76
  DESC
77
77
  task :fs, :roles => :web, :once => true do
78
78
  # Use production on non-multistage
79
- stage ||= 'production'
79
+ set :stage, 'production' unless exists?(:stage)
80
80
 
81
81
  server, port = host_and_port
82
82
 
@@ -114,7 +114,7 @@ Capistrano::Configuration.instance.load do
114
114
  DESC
115
115
  task :db, :roles => :db, :only => { :primary => true } do
116
116
  # Use production on non-multistage
117
- stage ||= 'production'
117
+ set :stage, 'production' unless exists?(:stage)
118
118
 
119
119
  filename = "database.#{stage}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2"
120
120
 
@@ -124,7 +124,7 @@ Capistrano::Configuration.instance.load do
124
124
  end
125
125
 
126
126
  # Make a backup before importing
127
- username, password, database, host = database_config(stage)
127
+ username, password, database, host = remote_database_config(stage)
128
128
  host_option = host ? "--host='#{host}'" : ""
129
129
  run "mysqldump -u #{username} --password='#{password}' #{host_option} #{database} | bzip2 -9 > #{shared_path}/sync/#{filename}" do |channel, stream, data|
130
130
  puts data
@@ -139,7 +139,7 @@ Capistrano::Configuration.instance.load do
139
139
  system "rm -f #{filename}"
140
140
 
141
141
  # Remote DB import
142
- username, password, database, host = database_config(stage)
142
+ username, password, database, host = remote_database_config(stage)
143
143
  host_option = host ? "--host='#{host}'" : ""
144
144
  run "bzip2 -d -c #{shared_path}/sync/#{filename} | mysql -u #{username} --password='#{password}' #{host_option} #{database}; rm -f #{shared_path}/sync/#{filename}"
145
145
  purge_old_backups "database"
@@ -154,7 +154,7 @@ Capistrano::Configuration.instance.load do
154
154
  DESC
155
155
  task :fs, :roles => :web, :once => true do
156
156
  # Use production on non-multistage
157
- stage ||= 'production'
157
+ set :stage, 'production' unless exists?(:stage)
158
158
 
159
159
  server, port = host_and_port
160
160
  Array(fetch(:sync_directories, [])).each do |syncdir|
@@ -188,6 +188,18 @@ Capistrano::Configuration.instance.load do
188
188
  return database["#{db}"]['username'], database["#{db}"]['password'], database["#{db}"]['database'], database["#{db}"]['host']
189
189
  end
190
190
 
191
+ #
192
+ # Reads the database credentials from the remote config/database.yml file
193
+ # +db+ the name of the environment to get the credentials for
194
+ # Returns username, password, database
195
+ #
196
+ def remote_database_config(db)
197
+ env = rails_env || db
198
+ config = capture "cat #{deploy_to}/current/config/database.yml"
199
+ database = YAML::load(config)
200
+ return database["#{env}"]['username'], database["#{env}"]['password'], database["#{env}"]['database'], database["#{env}"]['host']
201
+ end
202
+
191
203
  #
192
204
  # Returns the actual host name to sync and port
193
205
  #
@@ -211,4 +223,4 @@ Capistrano::Configuration.instance.load do
211
223
  end
212
224
 
213
225
  end
214
- end
226
+ end
@@ -1,6 +1,6 @@
1
1
  Capistrano::Configuration.instance.load do
2
2
  before "deploy:setup", :settings_logic
3
- after "deploy:update_code", "settings_logic:symlink"
3
+ before "bundler:update", "settings_logic:symlink"
4
4
 
5
5
  namespace :settings_logic do
6
6
  desc "Create application yaml in capistrano shared path"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: capones_recipes
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.3
5
+ version: 0.5.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Roman Simecek
@@ -162,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
162
  requirements:
163
163
  - - ">="
164
164
  - !ruby/object:Gem::Version
165
- hash: 3879717130479855336
165
+ hash: -2613591455120783238
166
166
  segments:
167
167
  - 0
168
168
  version: "0"