wordmove 1.0.3 → 1.0.4
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/wordmove/sql_mover.rb +2 -2
- data/lib/wordmove/version.rb +1 -1
- data/spec/sql_mover_spec.rb +9 -0
- metadata +1 -1
data/lib/wordmove/sql_mover.rb
CHANGED
@@ -43,10 +43,10 @@ module Wordmove
|
|
43
43
|
def serialized_replace!(source_field, dest_field)
|
44
44
|
length_delta = source_field.length - dest_field.length
|
45
45
|
|
46
|
-
sql_content.gsub!(/s:(\d+):"#{Regexp.escape(source_field)}/) do |match|
|
46
|
+
sql_content.gsub!(/s:(\d+):([\\'"]+)#{Regexp.escape(source_field)}/) do |match|
|
47
47
|
source_length = $1.to_i
|
48
48
|
dest_length = source_length - length_delta
|
49
|
-
"s:#{dest_length}
|
49
|
+
"s:#{dest_length}:#{$2}#{dest_field}"
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
data/lib/wordmove/version.rb
CHANGED
data/spec/sql_mover_spec.rb
CHANGED
@@ -90,6 +90,15 @@ describe Wordmove::SqlMover do
|
|
90
90
|
sql_mover.serialized_replace!('http://dump.com', 'http://shrubbery.com')
|
91
91
|
sql_mover.sql_content.should == 's:4:"spam";s:25:"http://shrubbery.com/spam";s:6:"foobar";s:27:"http://shrubbery.com/foobar";s:8:"sausages"'
|
92
92
|
end
|
93
|
+
|
94
|
+
context "given multiple types of string quoting" do
|
95
|
+
let(:content) { "s:20:\\\"http://dump.com/spam\\\";s:6:'foobar';s:22:'http://dump.com/foobar';s:8:'sausages'" }
|
96
|
+
|
97
|
+
it "handles replacing just as well" do
|
98
|
+
sql_mover.serialized_replace!('http://dump.com', 'http://shrubbery.com')
|
99
|
+
sql_mover.sql_content.should == "s:25:\\\"http://shrubbery.com/spam\\\";s:6:'foobar';s:27:'http://shrubbery.com/foobar';s:8:'sausages'"
|
100
|
+
end
|
101
|
+
end
|
93
102
|
end
|
94
103
|
|
95
104
|
context ".simple_replace!" do
|