activerecord-snapshot 0.3.2 → 0.3.3

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: 5e940ac1dd6c0727931c63986fd0d9ab647a8a97
4
- data.tar.gz: 581896f88fb4b33b80bdbf8332298dc1dbe01b96
3
+ metadata.gz: b51b97b1c6cf1f04d2d3c38b89f953e1aafb4e9f
4
+ data.tar.gz: 53fbe06bc4d402008d1e6732f8f51daec5c8d7a9
5
5
  SHA512:
6
- metadata.gz: 4c99693338d284f980b2d8a6a6c92475fbdbd43f2331853c16f0e92ddb71fa045890f23a80b6cfb60743808d33846de6ff4d738bbff637305df4a3a3db3ac55b
7
- data.tar.gz: 16be625dff9065a4862887082953c3a320645853c87eb4c1a6a0cee4e37db9eb62f421702ad205b65003bc9438693d68df6aea9d9474dfe2dfd141fb9248b9d3
6
+ metadata.gz: dcec9e3ef3029f1883bdf8973ca00f0e0ea2f06514b61e48ace9236e955175f394bd0abb0ad402fcc4b0843624996a4210af4438212c5722807ade46f49a1cd7
7
+ data.tar.gz: 5eee2391e5f2b426cfd1c88833ee6cb4e508eb0cf4ec5b33b83fcbb9c9f837fadb365f087fcdd8f0d43949df6599b1574ed78a2a9bdaebd6affaae0b6c74a15e
@@ -1,3 +1,5 @@
1
+ require 'shellwords'
2
+
1
3
  module ActiveRecord
2
4
  module Snapshot
3
5
  class MySQL
@@ -17,27 +19,46 @@ module ActiveRecord
17
19
  def import(input:)
18
20
  system(<<~SH)
19
21
  nice mysql \\
20
- --user #{username} \\
21
- #{password ? '--password' : ''} #{password} \\
22
- --host #{host} \\
22
+ --user=#{username} \\
23
+ #{password_string} \\
24
+ --host=#{host} \\
23
25
  #{database} < #{input}
24
26
  SH
25
27
  end
26
28
 
27
29
  private
28
30
 
29
- delegate :username, :password, :host, :database, to: :db_config
30
-
31
31
  def db_config
32
32
  ActiveRecord::Snapshot.config.db
33
33
  end
34
34
 
35
+ def escape(value)
36
+ Shellwords.escape(value)
37
+ end
38
+
39
+ def username
40
+ escape(db_config.username)
41
+ end
42
+
43
+ def password_string
44
+ return if db_config.password.blank?
45
+ "--password=#{escape(db_config.password)}"
46
+ end
47
+
48
+ def host
49
+ escape(db_config.host)
50
+ end
51
+
52
+ def database
53
+ escape(db_config.database)
54
+ end
55
+
35
56
  def dump_command(args = "")
36
57
  system(<<~SH)
37
58
  nice mysqldump \\
38
- --user #{username} \\
39
- --password #{password} \\
40
- --host #{host} \\
59
+ --user=#{username} \\
60
+ #{password_string} \\
61
+ --host=#{host} \\
41
62
  #{args}
42
63
  SH
43
64
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Snapshot
3
- VERSION = '0.3.2'
3
+ VERSION = '0.3.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-snapshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernardo Farah
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-22 00:00:00.000000000 Z
11
+ date: 2017-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties