wordmove 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wordmove/sql_mover.rb +13 -4
- data/lib/wordmove/version.rb +1 -1
- data/spec/sql_mover_spec.rb +9 -0
- metadata +2 -2
data/lib/wordmove/sql_mover.rb
CHANGED
@@ -41,10 +41,19 @@ module Wordmove
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def serialized_replace!(source_field, dest_field)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
length_delta = source_field.length - dest_field.length
|
45
|
+
|
46
|
+
sql_content.gsub!(/s:(\d+):([\\]*['"])(.*?)\2;/) do |match|
|
47
|
+
length = $1.to_i
|
48
|
+
delimiter = $2
|
49
|
+
string = $3
|
50
|
+
|
51
|
+
string.gsub!(/#{Regexp.escape(source_field)}/) do |match|
|
52
|
+
length -= length_delta
|
53
|
+
dest_field
|
54
|
+
end
|
55
|
+
|
56
|
+
%(s:#{length}:#{delimiter}#{string}#{delimiter};)
|
48
57
|
end
|
49
58
|
end
|
50
59
|
|
data/lib/wordmove/version.rb
CHANGED
data/spec/sql_mover_spec.rb
CHANGED
@@ -109,6 +109,15 @@ describe Wordmove::SqlMover do
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
+
context "given strings with escaped content" do
|
113
|
+
let(:content) { 's:6:"dump\"\"";' }
|
114
|
+
|
115
|
+
it "should calculate the correct final length" do
|
116
|
+
sql_mover.serialized_replace!('dump', 'sausage')
|
117
|
+
sql_mover.sql_content.should == 's:9:"sausage\"\"";'
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
112
121
|
context "given multiple types of string quoting" do
|
113
122
|
let(:content) { "a:3:{s:20:\\\"http://dump.com/spam\\\";s:6:'foobar';s:22:'http://dump.com/foobar';s:8:'sausages';}" }
|
114
123
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wordmove
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colored
|