linky 0.0.5 → 0.0.8

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/lib/linky/linky.rb +3 -3
  2. data/spec/linky_spec.rb +12 -0
  3. metadata +6 -6
data/lib/linky/linky.rb CHANGED
@@ -33,7 +33,7 @@ class Linky
33
33
 
34
34
 
35
35
  # break the string into three parts
36
- prefix, keyword, postfix = break_on_boundary match[1], haystack.to_s
36
+ prefix, keyword, postfix = break_on_boundary match[1], haystack.text
37
37
 
38
38
  haystack.content = prefix
39
39
  haystack.add_next_sibling Nokogiri::HTML::DocumentFragment.parse(new_needle)
@@ -54,8 +54,8 @@ class Linky
54
54
  end
55
55
 
56
56
  def break_on_boundary(boundary, string)
57
- match = string.match /^(.*?\b)(#{boundary})(\b.*)?$/
58
- return match[1], match[2], match[3]
57
+ match = string.match /\b(#{boundary})\b/
58
+ return $`, match[1], $'
59
59
  end
60
60
  end
61
61
  end
data/spec/linky_spec.rb CHANGED
@@ -36,4 +36,16 @@ describe Linky, "#link" do
36
36
  new_html = Linky.link "California", "topics/california", html
37
37
  new_html.should == "<p><a href=\"topics/california\">California</a> <a href=\"topics/cabernet-sauvignon\">Cabernet Sauvignon</a>&#x97;an awesome wine</p>"
38
38
  end
39
+
40
+ it "should include text after next line char" do
41
+ html = %(Hi.\nI like ice cream. She likes it too.\n I think.)
42
+ new_html = Linky.link "cream", "topics/cream", html
43
+ new_html.should == %(Hi.\nI like ice <a href="topics/cream">cream</a>. She likes it too.\n I think.)
44
+ end
45
+
46
+ it "should preserve html entity" do
47
+ html = "apple &amp; orange"
48
+ new_html = Linky.link "apple", "topics/apple", html
49
+ new_html.should == %(<a href="topics/apple">apple</a> &amp; orange)
50
+ end
39
51
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linky
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
4
+ hash: 15
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 8
10
+ version: 0.0.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Parker
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-07 00:00:00 -05:00
18
+ date: 2011-02-16 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  requirements: []
79
79
 
80
80
  rubyforge_project:
81
- rubygems_version: 1.3.7
81
+ rubygems_version: 1.5.0
82
82
  signing_key:
83
83
  specification_version: 3
84
84
  summary: A library for safely linking keywords to urls within HTML content.