dumpdb 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/dumpdb/settings.rb +1 -0
- data/lib/dumpdb/version.rb +1 -1
- data/test/settings_tests.rb +41 -0
- metadata +4 -4
data/lib/dumpdb/settings.rb
CHANGED
@@ -62,6 +62,7 @@ module Dumpdb::Settings
|
|
62
62
|
def value(script, placeholder_vals={})
|
63
63
|
val = super(script, script.source.to_hash.merge(placeholder_vals))
|
64
64
|
if script.ssh?
|
65
|
+
val = val.gsub("\\", "\\\\\\").gsub('"', '\"')
|
65
66
|
val = "ssh -A #{script.ssh_opts} #{script.ssh} \"#{val}\""
|
66
67
|
end
|
67
68
|
val
|
data/lib/dumpdb/version.rb
CHANGED
data/test/settings_tests.rb
CHANGED
@@ -126,6 +126,20 @@ module Dumpdb
|
|
126
126
|
assert_equal "this is the local db: devdb", cmd_val
|
127
127
|
end
|
128
128
|
|
129
|
+
should "not escape any double-quotes in the cmds" do
|
130
|
+
orig_cmd = "do_something --value=\"a_val\""
|
131
|
+
cmd_val = Settings::DumpCmd.new(Proc.new { orig_cmd }).value(@script)
|
132
|
+
|
133
|
+
assert_equal orig_cmd, cmd_val
|
134
|
+
end
|
135
|
+
|
136
|
+
should "not escape any backslashes in the cmds" do
|
137
|
+
orig_cmd = "do \\something"
|
138
|
+
cmd_val = Settings::DumpCmd.new(Proc.new { orig_cmd }).value(@script)
|
139
|
+
|
140
|
+
assert_equal orig_cmd, cmd_val
|
141
|
+
end
|
142
|
+
|
129
143
|
end
|
130
144
|
|
131
145
|
class RemoteDumpCmdTests < DumpCmdTests
|
@@ -142,6 +156,33 @@ module Dumpdb
|
|
142
156
|
assert_equal exp_cmd_str, cmd_val
|
143
157
|
end
|
144
158
|
|
159
|
+
should "escape any double-quotes in the cmds" do
|
160
|
+
orig_cmd = "do_something --value=\"a_val\""
|
161
|
+
exp_esc_cmd = "do_something --value=\\\"a_val\\\""
|
162
|
+
exp_cmd_str = "ssh -A #{@script.ssh_opts} #{@script.ssh} \"#{exp_esc_cmd}\""
|
163
|
+
cmd_val = Settings::DumpCmd.new(Proc.new { orig_cmd }).value(@script)
|
164
|
+
|
165
|
+
assert_equal exp_cmd_str, cmd_val
|
166
|
+
end
|
167
|
+
|
168
|
+
should "escape any backslashes in the cmds" do
|
169
|
+
orig_cmd = "do \\something"
|
170
|
+
exp_esc_cmd = "do \\\\something"
|
171
|
+
exp_cmd_str = "ssh -A #{@script.ssh_opts} #{@script.ssh} \"#{exp_esc_cmd}\""
|
172
|
+
cmd_val = Settings::DumpCmd.new(Proc.new { orig_cmd }).value(@script)
|
173
|
+
|
174
|
+
assert_equal exp_cmd_str, cmd_val
|
175
|
+
end
|
176
|
+
|
177
|
+
should "escape any backslashes before double-quotes in the cmds" do
|
178
|
+
orig_cmd = "do \\something --value=\"a_val\""
|
179
|
+
exp_esc_cmd = "do \\\\something --value=\\\"a_val\\\""
|
180
|
+
exp_cmd_str = "ssh -A #{@script.ssh_opts} #{@script.ssh} \"#{exp_esc_cmd}\""
|
181
|
+
cmd_val = Settings::DumpCmd.new(Proc.new { orig_cmd }).value(@script)
|
182
|
+
|
183
|
+
assert_equal exp_cmd_str, cmd_val
|
184
|
+
end
|
185
|
+
|
145
186
|
end
|
146
187
|
|
147
188
|
class RestoreCmdTests < CmdTests
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dumpdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kelly Redding
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-12-
|
19
|
+
date: 2012-12-20 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: assert
|