soywiki 0.5.0 → 0.5.1
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/bin/soywiki-rename +16 -6
- data/lib/soywiki.rb +1 -1
- metadata +2 -2
data/bin/soywiki-rename
CHANGED
@@ -42,7 +42,7 @@ def change_unqualified_inbound_links_in_same_namespace(oldname, newname)
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
RELATIVE_LINK_REGEX
|
45
|
+
RELATIVE_LINK_REGEX = /(\A|\s)([A-Z][a-z]+[A-Z]\w*)/
|
46
46
|
|
47
47
|
def absolutize_unqualified_outbound_links(oldname, newname)
|
48
48
|
MEMO << "Absolutizing unqualified inbound links"
|
@@ -50,14 +50,24 @@ def absolutize_unqualified_outbound_links(oldname, newname)
|
|
50
50
|
if File.exist?(target_file)
|
51
51
|
text = File.read(target_file)
|
52
52
|
begin
|
53
|
-
matches = text.scan(RELATIVE_LINK_REGEX).
|
54
|
-
|
55
|
-
|
53
|
+
matches = text.scan(RELATIVE_LINK_REGEX).map {|x| x[1]}.
|
54
|
+
select {|match| match.strip != "" }.
|
55
|
+
select {|match| File.exist?( oldname.namespace + "/#{match}" ) }
|
56
|
+
puts MEMO << " - In file #{target_file}: matches: #{matches.inspect}"
|
57
|
+
|
58
|
+
text = text.gsub(RELATIVE_LINK_REGEX) do |match|
|
59
|
+
if matches.include?($2)
|
60
|
+
res = "#$1#{oldname.namespace}.#{$2}"
|
61
|
+
MEMO << " - In file #{target_file}: #{$2} -> #{res.strip}"
|
62
|
+
res
|
63
|
+
else
|
64
|
+
MEMO << " - In file #{target_file}: skipping #{$2}"
|
65
|
+
match
|
66
|
+
end
|
56
67
|
end
|
57
68
|
File.open(target_file, 'w') {|f| f.puts text}
|
58
|
-
MEMO << " - In file #{target_file}: Absolutized these unqualified links: #{matches.inspect}"
|
59
69
|
rescue
|
60
|
-
puts "Error processing #{
|
70
|
+
puts "Error processing #{target_file}: #$!"
|
61
71
|
end
|
62
72
|
end
|
63
73
|
end
|
data/lib/soywiki.rb
CHANGED