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.
Files changed (3) hide show
  1. data/bin/soywiki-rename +16 -6
  2. data/lib/soywiki.rb +1 -1
  3. metadata +2 -2
@@ -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 =/(\A|\s)([A-Z][a-z]+[A-Z]\w*)/
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).select {|match| File.exist?( oldname.namespace + ".#{match}" ) }
54
- matches.each do |match|
55
- text = text.gsub(match, oldname.namespace + '.\1')
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 #{file}: #$!"
70
+ puts "Error processing #{target_file}: #$!"
61
71
  end
62
72
  end
63
73
  end
@@ -1,7 +1,7 @@
1
1
  require 'string_ext'
2
2
 
3
3
  module Soywiki
4
- VERSION = '0.5.0'
4
+ VERSION = '0.5.1'
5
5
  WIKI_WORD = /\b([a-z][\w_]+\.)?[A-Z][a-z]+[A-Z]\w*\b/
6
6
  HYPERLINK = %r|\bhttps?://[^ >)\n\]]+|
7
7
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 0
9
- version: 0.5.0
8
+ - 1
9
+ version: 0.5.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Choi