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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b51b97b1c6cf1f04d2d3c38b89f953e1aafb4e9f
|
4
|
+
data.tar.gz: 53fbe06bc4d402008d1e6732f8f51daec5c8d7a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
21
|
-
#{
|
22
|
-
--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
|
39
|
-
|
40
|
-
--host
|
59
|
+
--user=#{username} \\
|
60
|
+
#{password_string} \\
|
61
|
+
--host=#{host} \\
|
41
62
|
#{args}
|
42
63
|
SH
|
43
64
|
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.
|
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-
|
11
|
+
date: 2017-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|