postrank-uri 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/postrank-uri.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'addressable/uri'
4
4
  require 'domainatrix'
5
+ require 'digest/md5'
5
6
  require 'nokogiri'
6
7
  require 'yaml'
7
8
 
@@ -117,6 +118,10 @@ module PostRank
117
118
  string ? uri.to_s : uri
118
119
  end
119
120
 
121
+ def hash(uri)
122
+ Digest::MD5.hexdigest(clean(uri))
123
+ end
124
+
120
125
  def normalize(uri)
121
126
  u = parse(uri)
122
127
  u.path = u.path.squeeze('/')
@@ -1,5 +1,5 @@
1
1
  module PostRank
2
2
  module URI
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.5"
4
4
  end
5
5
  end
@@ -117,7 +117,6 @@ describe PostRank::URI do
117
117
  end
118
118
 
119
119
  context "clean" do
120
-
121
120
  def c(uri)
122
121
  PostRank::URI.clean(uri)
123
122
  end
@@ -141,7 +140,20 @@ describe PostRank::URI do
141
140
  c(orig).should == clean
142
141
  end
143
142
  end
143
+ end
144
+
145
+ context "hash" do
146
+ def h(uri)
147
+ PostRank::URI.hash(uri)
148
+ end
149
+
150
+ it "should compute MD5 hash of the normalized URI" do
151
+ hash = '021a1032b1ea631a7c33d1a0ccc562bf'
144
152
 
153
+ h('http://EverBurnign.Com/feed/post/1').should == hash
154
+ h('Everburnign.com/feed/post/1').should == hash
155
+ h('everburnign.com/feed/post/1').should == hash
156
+ end
145
157
  end
146
158
 
147
159
  context "extract" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 4
9
- version: 1.0.4
8
+ - 5
9
+ version: 1.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ilya Grigorik
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-26 00:00:00 -05:00
17
+ date: 2011-02-02 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency