postrank-uri 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/postrank-uri.rb CHANGED
@@ -83,7 +83,7 @@ module PostRank
83
83
  end
84
84
 
85
85
  def extract_href(text, host = nil)
86
- urls = {}
86
+ urls = []
87
87
  Nokogiri.HTML(text).search('a').each do |a|
88
88
  begin
89
89
  url = normalize(c18n(unescape(a.attr('href'))))
@@ -92,7 +92,7 @@ module PostRank
92
92
  url.host = host
93
93
  end
94
94
 
95
- urls[url.to_s] = a.text
95
+ urls.push [url.to_s, a.text]
96
96
  rescue
97
97
  next
98
98
  end
@@ -1,5 +1,5 @@
1
1
  module PostRank
2
2
  module URI
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
@@ -186,14 +186,13 @@ describe PostRank::URI do
186
186
 
187
187
  context "href extract" do
188
188
  it "should extract links from html text" do
189
- l = PostRank::URI.extract_href("<a href='google.com'>link to google</a> with text <a href='b.com'>stuff</a>")
190
- l.keys.size.should == 2
189
+ g,b = PostRank::URI.extract_href("<a href='google.com'>link to google</a> with text <a href='b.com'>stuff</a>")
191
190
 
192
- l.keys.should include('http://google.com/')
193
- l.keys.should include('http://b.com/')
191
+ g.first.should == 'http://google.com/'
192
+ b.first.should == 'http://b.com/'
194
193
 
195
- l['http://google.com/'].should == 'link to google'
196
- l['http://b.com/'].should == 'stuff'
194
+ g.last.should == 'link to google'
195
+ b.last.should == 'stuff'
197
196
  end
198
197
 
199
198
  it "should handle empty hrefs" do
@@ -210,10 +209,9 @@ describe PostRank::URI do
210
209
  end
211
210
 
212
211
  it "should resolve relative paths if host is provided" do
213
- l = PostRank::URI.extract_href("<a href='/stuff'>link to stuff</a>", "igvita.com")
214
-
215
- l.size.should == 1
216
- l['http://igvita.com/stuff'].should == 'link to stuff'
212
+ i = PostRank::URI.extract_href("<a href='/stuff'>link to stuff</a>", "igvita.com").first
213
+ i.first.should == 'http://igvita.com/stuff'
214
+ i.last.should == 'link to stuff'
217
215
  end
218
216
  end
219
217
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 1
9
- version: 1.0.1
8
+ - 2
9
+ version: 1.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ilya Grigorik