capistrano-db-tasks 0.5 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18ac3ae6cd8e72a0cf8aeb17906f23c009b38e84
4
- data.tar.gz: 648af7e955625ab548ff6d086bbbea56c8234f38
3
+ metadata.gz: 70686927e9b1dbb60f98bfd3c862de83d6fb7a29
4
+ data.tar.gz: 42b36085956d02a87c8b3d68f8c199ad53aa6851
5
5
  SHA512:
6
- metadata.gz: 44884aea8dc26dc0a9d66c10c428b4b543a01720a912bf6efabe4f325b12c105d1da0ac67c78f460db10864efa9ac60cef4012eba6a7ab6dd03fec2d389ecd28
7
- data.tar.gz: de3f9770a4c9cf2a35f9df7c61e70281feb7db5a2c0d23bc913b9ed37684c5e0c43d5c665412ffb6fc75014fca1df05d0b110376c40998e26a3b3a912714fa95
6
+ metadata.gz: fbfbbf4e4be63dbea1b7b73f89e2f7022fd1a8d46d5be64276bce4cb29448fdff1706307562f52b0c633116a1b1c4e241bed492ffc05c37f80053a54565dbde4
7
+ data.tar.gz: 744bada441f262c52724899049b55a880008daf60caee2ac4173a04fce956edc67a14ba5479db4cc41aa381602752b6fc6fab75fdc71b5828daf889b9f27e000
@@ -1,5 +1,5 @@
1
1
  Rails:
2
- Enabled: true
2
+ Enabled: false
3
3
 
4
4
  AllCops:
5
5
  TargetRubyVersion: 2.3
@@ -4,10 +4,15 @@ Reverse Chronological Order:
4
4
 
5
5
  ## master
6
6
 
7
- https://github.com/sgruhier/capistrano-db-tasks/compare/v0.5...HEAD
7
+ https://github.com/sgruhier/capistrano-db-tasks/compare/v0.6...HEAD
8
8
 
9
9
  * Your contribution here!
10
10
 
11
+ # 0.6 (Dec 14 2016)
12
+
13
+ * Configurable dump folder #101 #75 #61 (@artempartos, @gmhawash)
14
+ * Fixed previous release bugs (@sitnikovme, @slavajacobson)
15
+
11
16
  # 0.5 (Nov 29 2016)
12
17
 
13
18
  * Fixed iteration on remote/local assets dir #98 (@elthariel)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # CapistranoDbTasks | [![Code Climate](https://codeclimate.com/github/sgruhier/capistrano-db-tasks/badges/gpa.svg)](https://codeclimate.com/github/sgruhier/capistrano-db-tasks) [![Gem Version](https://badge.fury.io/rb/capistrano-db-tasks.svg)](http://badge.fury.io/rb/capistrano-db-tasks)
1
+ # CapistranoDbTasks | [![Gem Downloads](http://img.shields.io/gem/dt/capistrano-db_sync.svg)](https://rubygems.org/gems/capistrano-db_sync)[![Code Climate](https://codeclimate.com/github/sgruhier/capistrano-db-tasks/badges/gpa.svg)](https://codeclimate.com/github/sgruhier/capistrano-db-tasks) [![Gem Version](https://badge.fury.io/rb/capistrano-db-tasks.svg)](http://badge.fury.io/rb/capistrano-db-tasks)
2
2
 
3
3
  Add database AND assets tasks to capistrano to a Rails project. It only works with capistrano 3. Older versions until 0.3 works with capistrano 2.
4
4
 
@@ -39,6 +39,9 @@ set :db_ignore_tables, []
39
39
  # if you want to exclude table data (but not table schema) from dump
40
40
  set :db_ignore_data_tables, []
41
41
 
42
+ # configure location where the dump file should be created
43
+ set :db_dump_dir, "./db"
44
+
42
45
  # If you want to import assets, you can change default asset dir (default = system)
43
46
  # This directory must be in your shared directory on the server
44
47
  set :assets_dir, %w(public/assets public/att)
@@ -41,11 +41,11 @@ module Database
41
41
  end
42
42
 
43
43
  def current_time
44
- Time.zone.now.strftime("%Y-%m-%d-%H%M%S")
44
+ Time.now.strftime("%Y-%m-%d-%H%M%S")
45
45
  end
46
46
 
47
47
  def output_file
48
- @output_file ||= "db/#{database}_#{current_time}.sql.#{compressor.file_extension}"
48
+ @output_file ||= "#{database}_#{current_time}.sql.#{compressor.file_extension}"
49
49
  end
50
50
 
51
51
  def compressor
@@ -105,7 +105,7 @@ module Database
105
105
  class Remote < Base
106
106
  def initialize(cap_instance)
107
107
  super(cap_instance)
108
- @cap.info "Loading remote database config"
108
+ puts "Loading remote database config"
109
109
  @cap.within @cap.current_path do
110
110
  @cap.with rails_env: @cap.fetch(:rails_env) do
111
111
  dirty_config_content = @cap.capture(:rails, "runner \"puts '#{DBCONFIG_BEGIN_FLAG}' + ActiveRecord::Base.connection.instance_variable_get(:@config).to_yaml + '#{DBCONFIG_END_FLAG}'\"", '2>/dev/null')
@@ -117,19 +117,19 @@ module Database
117
117
  end
118
118
 
119
119
  def dump
120
- @cap.execute "cd #{@cap.current_path} && #{dump_cmd} | #{compressor.compress('-', output_file)}"
120
+ @cap.execute "cd #{@cap.current_path} && #{dump_cmd} | #{compressor.compress('-', db_dump_file_path)}"
121
121
  self
122
122
  end
123
123
 
124
124
  def download(local_file = "#{output_file}")
125
- @cap.download! dump_file_path, local_file
125
+ @cap.download! db_dump_file_path, local_file
126
126
  end
127
127
 
128
128
  def clean_dump_if_needed
129
129
  if @cap.fetch(:db_remote_clean)
130
- @cap.execute "rm -f #{dump_file_path}"
130
+ @cap.execute "rm -f #{db_dump_file_path}"
131
131
  else
132
- @cap.info "leaving #{dump_file_path} on the server (add \"set :db_remote_clean, true\" to deploy.rb to remove)"
132
+ puts "leaving #{db_dump_file_path} on the server (add \"set :db_remote_clean, true\" to deploy.rb to remove)"
133
133
  end
134
134
  end
135
135
 
@@ -143,15 +143,19 @@ module Database
143
143
 
144
144
  private
145
145
 
146
- def dump_file_path
147
- "#{@cap.current_path}/#{output_file}"
146
+ def db_dump_file_path
147
+ "#{db_dump_dir}/#{output_file}"
148
+ end
149
+
150
+ def db_dump_dir
151
+ @cap.fetch(:db_dump_dir) || "#{@cap.current_path}/db"
148
152
  end
149
153
  end
150
154
 
151
155
  class Local < Base
152
156
  def initialize(cap_instance)
153
157
  super(cap_instance)
154
- @cap.info "Loading local database config"
158
+ puts "Loading local database config"
155
159
  command = "#{Dir.pwd}/bin/rails runner \"puts '#{DBCONFIG_BEGIN_FLAG}' + ActiveRecord::Base.connection.instance_variable_get(:@config).to_yaml + '#{DBCONFIG_END_FLAG}'\""
156
160
  stdout, status = Open3.capture2(command)
157
161
  raise "Error running command (status=#{status}): #{command}" if status != 0
@@ -163,15 +167,15 @@ module Database
163
167
  # cleanup = true removes the mysqldump file after loading, false leaves it in db/
164
168
  def load(file, cleanup)
165
169
  unzip_file = File.join(File.dirname(file), File.basename(file, ".#{compressor.file_extension}"))
166
- @cap.info "executing local: #{compressor.decompress(file)} && #{import_cmd(unzip_file)}"
170
+ puts "executing local: #{compressor.decompress(file)} && #{import_cmd(unzip_file)}"
167
171
  execute("#{compressor.decompress(file)} && #{import_cmd(unzip_file)}")
168
172
  if cleanup
169
- @cap.info "removing #{unzip_file}"
173
+ puts "removing #{unzip_file}"
170
174
  File.unlink(unzip_file)
171
175
  else
172
- @cap.info "leaving #{unzip_file} (specify :db_local_clean in deploy.rb to remove)"
176
+ puts "leaving #{unzip_file} (specify :db_local_clean in deploy.rb to remove)"
173
177
  end
174
- @cap.info "Completed database import"
178
+ puts "Completed database import"
175
179
  end
176
180
 
177
181
  def dump
@@ -1,6 +1,6 @@
1
1
  module Util
2
2
  def self.prompt(msg, prompt = "(y)es, (n)o ")
3
3
  ask(:answer, "#{msg} #{prompt} ? ")
4
- (fetch(:answer) =~ /^y$|^yes$/i).zero?
4
+ (fetch(:answer) =~ /^y$|^yes$/i).to_i.zero?
5
5
  end
6
6
  end
@@ -1,3 +1,3 @@
1
1
  module CapistranoDbTasks
2
- VERSION = "0.5".freeze
2
+ VERSION = "0.6".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-db-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.5'
4
+ version: '0.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Gruhier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-29 00:00:00.000000000 Z
11
+ date: 2016-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano