PageRankr 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - rbx-2.0
6
+ - ree
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Change Log
2
2
 
3
+ ## Version 3.0.1
4
+ * Improve PageRankr::Site
5
+
3
6
  ## Version 3.0.0
4
7
  * Refactor
5
8
  * Move the logic for the typhoeus request out of the individual trackers in Tracker to hide the complexity.
data/Gemfile CHANGED
@@ -2,4 +2,6 @@ source :gemcutter
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'ruby-debug19', :require => 'ruby-debug'
5
+ group :development do
6
+ gem 'ruby-debug19', :require => 'ruby-debug', :platforms => :mri_19
7
+ end
data/PageRankr.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.required_rubygems_version = ">= 1.3.6"
14
14
  s.add_development_dependency "rake"
15
- s.add_development_dependency "rspec", "~> 2.1.0"
15
+ s.add_development_dependency "rspec", "~> 2.6.0"
16
16
  s.add_development_dependency "bundler", ">= 1.0.0"
17
17
  s.add_development_dependency "fuubar", ">= 0.0.1"
18
18
  s.add_development_dependency "vcr"
@@ -7,7 +7,7 @@ module PageRankr
7
7
  include Rank
8
8
 
9
9
  def initialize(site)
10
- @checksum = Checksum.generate(site.to_s)
10
+ @checksum = Checksum.generate('info:' + site.to_s)
11
11
 
12
12
  super(site)
13
13
  end
@@ -4,17 +4,14 @@ module PageRankr
4
4
  class Checksum
5
5
  class << self
6
6
  def generate(site)
7
- bytes = byte_array('info:' + site)
7
+ bytes = byte_array(site)
8
8
  length = bytes.length
9
9
  a = b = 0x9E3779B9
10
10
  c = 0xE6359A60
11
+
11
12
  k, len = 0, length
12
13
  while(len >= 12)
13
- a = m(a + bytes[k + 0] + (bytes[k + 1] << 8) + (bytes[k + 2] << 16) + (bytes[k + 3] << 24))
14
- b = m(b + bytes[k + 4] + (bytes[k + 5] << 8) + (bytes[k + 6] << 16) + (bytes[k + 7] << 24))
15
- c = m(c + bytes[k + 8] + (bytes[k + 9] << 8) + (bytes[k + 10] << 16) + (bytes[k + 11] << 24))
16
-
17
- a, b, c = mix(a, b, c)
14
+ a, b, c = mix(*shift(a, b, c, k, bytes))
18
15
  k += 12
19
16
  len -= 12
20
17
  end
@@ -38,6 +35,14 @@ module PageRankr
38
35
  v % 0x100000000
39
36
  end
40
37
 
38
+ def shift(a, b, c, k, bytes)
39
+ a = m(a + bytes[k + 0] + (bytes[k + 1] << 8) + (bytes[k + 2] << 16) + (bytes[k + 3] << 24))
40
+ b = m(b + bytes[k + 4] + (bytes[k + 5] << 8) + (bytes[k + 6] << 16) + (bytes[k + 7] << 24))
41
+ c = m(c + bytes[k + 8] + (bytes[k + 9] << 8) + (bytes[k + 10] << 16) + (bytes[k + 11] << 24))
42
+
43
+ [a, b, c]
44
+ end
45
+
41
46
  def mix(a, b, c)
42
47
  a, b, c = m(a), m(b), m(c)
43
48
 
@@ -6,14 +6,17 @@ module PageRankr
6
6
  def initialize(site)
7
7
  super(PublicSuffixService.parse(clean(site)))
8
8
  valid? or raise DomainInvalid, "The domain provided is invalid."
9
+ rescue PublicSuffixService::DomainInvalid => e
10
+ raise DomainInvalid, "The domain provided is invalid."
9
11
  end
10
12
 
11
13
  private
12
14
 
13
15
  def clean(site)
14
- site = site.split("://").last # remove protocol
15
- site = site.split("/").first # remove path
16
- site.split("?").first # remove params
16
+ site = site || ''
17
+ site = site.split("://").last || '' # remove protocol
18
+ site = site.split("/").first || '' # remove path
19
+ site.split("?").first || '' # remove params
17
20
  end
18
21
  end
19
22
 
@@ -1,3 +1,3 @@
1
1
  module PageRankr
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
@@ -135,4 +135,12 @@ describe PageRankr do
135
135
  end
136
136
  end
137
137
  end
138
+
139
+ describe "::Site" do
140
+ [nil, '', 'batman.thedarkknight'].each do |value|
141
+ it "should raise an exception when given #{value}" do
142
+ expect{PageRankr::Site(value)}.should raise_error(PageRankr::DomainInvalid)
143
+ end
144
+ end
145
+ end
138
146
  end
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ SAMPLES = {
4
+ 'RDwuPEHIrgTSfjFwIrNQQWlBe' => '62055409506',
5
+ 'EpQgoYSvBcBsgApYnXvimwbUumJeajtPwVpyK' => '63696758529',
6
+ 'wNKCeCesYrBWVHOebbHYUXtYKUJsYZ' => '62499718143',
7
+ 'WcuHBErnmnlobkoljovgcipTEoxNKNkozMyrBoHumbaIRlDTX' => '62990136296',
8
+ 'zmZMVOZeOSAjllPQebawJvTyx' => '62600475104',
9
+ 'zIhqWNkSWVDtGyZJNAhXrsxvr' => '61779137032',
10
+ 'HUJRIlqBoPiacanILngyPhvvwLYUTzXrLPGfFBXL' => '63164171011',
11
+ 'FmaqTt' => '63696846590',
12
+ 'bbjjofINMufjVmSDbiYKuEErqjbYYdcrftUieapFlWzxoYsMGz' => '6428000023',
13
+ 'ydczxaBUFUtKxKJIxDrPvqxBiaqYPv' => '6759338533',
14
+ 'ccYqbRnRDPPDHVMsckdGnbpGAuPbUNIbETxP' => '63618603088',
15
+ 'LMmlBvFBXGvMxkjBfNVBLqmaCr' => '62431570439',
16
+ 'jjiEggColBhBYwuiePcDpBTQwwlvFzKwmp' => '62648705831',
17
+ 'SMdamRDmvkJVeNTebaagEXxTXkSCnZiCkkVhnqHvdSAPtNfyr' => '6878476314',
18
+ 'vOmJIIbRUvYjaNjssTuZXgRIOgoL' => '62170208114',
19
+ 'BwaSRvqktWSqgEMltozGwmjvxVxVQCSyvWtsmyjwHCOLVUC' => '64152263835',
20
+ 'YfgEaPPyBTjouR' => '61911140243',
21
+ 'DgheQaizjMialWKddArxjAAabMmqRBecpWEITApW' => '6192924161',
22
+ 'aLDGcvrIyQBcULWAfXPUf' => '64117571081',
23
+ 'INZIhnvQsNRYBFTxMgVXa' => '6555275853',
24
+ 'XUWkScxADSi' => '6350572650',
25
+ 'spCHnLtDAsCZsknhvb' => '61624563975',
26
+ 'zwMlYkrXxUXAfibWDzGhNZQkfQrUYRTWI' => '61602088851',
27
+ 'VQOXivprmVdolPLVwHKOuYvTmioXZXGezRqtckeDn' => '62545550187',
28
+ 'HZKigUSAFnrOLYlevkfnUfHfBgLTvlCJf' => '6769537725',
29
+ 'AVNOlRWJWaFDDXftjswFgi' => '63208473934',
30
+ 'LMIdcsdjebQzLFUNshdANQcIYVYuN' => '64007570819',
31
+ 'srzhYNeleTqUfZs' => '62437029261',
32
+ 'PRmyimgSzJxjSkiyAmdVcbSmCupU' => '61858587900',
33
+ 'zDFRVUuKvN' => '63966306432',
34
+ 'tTAAuluIGwiMKlpomnbFWbLQlhgjhncMIyWtvcJHVWbeoc' => '63823152059',
35
+ 'eGwAubHVWzCqHdhZYuPlEkOKjQvPnEztyD' => '6495782915',
36
+ 'bHCitHCtfRgUZcdnPMMjeMKIyByCoTbvpQmAh' => '6875882828',
37
+ 'xbJKX' => '61447129925',
38
+ 'rNXiXkmPFeZcHNNfiAuDnJLC' => '6411099889',
39
+ 'wnOb' => '6466687088',
40
+ 'bVNaQhWifmkUe' => '61080905374',
41
+ 'NpXUdZY' => '6271405864',
42
+ 'APJkWZOI' => '63718750842',
43
+ 'OBwoI' => '64211141471',
44
+ 'WJWBrvLPtPvzYWJZWXDyuRAFVKldUfukd' => '62941406460',
45
+ 'yJmQUYAaUflHgOZIRLWTpwlYhrdwOZcvyYmqQYsnRGDmz' => '62977926381',
46
+ 'FJDGohessfwGmSBsWAwdCmtiDjabJfAqGxZdDkXXDv' => '62678453226',
47
+ 'UwBkNFMXRhAOtEgmHpPYdSIcEINvQPtSoHnBNExlXoeKtMxAgFzB' => '63584282177',
48
+ 'BX' => '6816754104',
49
+ 'ifcdHujBOWnTwzbNFuBuh' => '6150630468',
50
+ 'nmkszzBXQIfK' => '63370482677',
51
+ 'wdLFQxGR' => '6615323',
52
+ 'kXxpmTyiLNJfYHlMwxWoMgaAjhIdCQga' => '6539671864',
53
+ 'qbYyPjyqIhGxebMRjBGAACzFVoTsQRNwyECQelaGymV' => '61636842386',
54
+ 'www.google.com' => '63801972318',
55
+ 'https://github.com' => '61980590130',
56
+ }
57
+
58
+
59
+ describe PageRankr::Ranks::Google::Checksum do
60
+ describe "#generate" do
61
+ SAMPLES.each do |input, output|
62
+ it "should generate #{output} as a checksum for #{input}" do
63
+ PageRankr::Ranks::Google::Checksum.generate(input).should == output
64
+ end
65
+ end
66
+ end
67
+ end
data/spec/spec_helper.rb CHANGED
@@ -8,7 +8,7 @@ VCR.config do |c|
8
8
  c.stub_with :typhoeus
9
9
  end
10
10
 
11
- Rspec.configure do |c|
11
+ RSpec.configure do |c|
12
12
  c.formatter = Fuubar
13
13
  c.color_enabled = true
14
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: PageRankr
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-08 00:00:00.000000000Z
12
+ date: 2011-10-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70100460194300 !ruby/object:Gem::Requirement
16
+ requirement: &70212255999580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70100460194300
24
+ version_requirements: *70212255999580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70100460193680 !ruby/object:Gem::Requirement
27
+ requirement: &70212255999040 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 2.1.0
32
+ version: 2.6.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70100460193680
35
+ version_requirements: *70212255999040
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70100460193080 !ruby/object:Gem::Requirement
38
+ requirement: &70212255998540 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70100460193080
46
+ version_requirements: *70212255998540
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: fuubar
49
- requirement: &70100460192520 !ruby/object:Gem::Requirement
49
+ requirement: &70212255998020 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.0.1
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70100460192520
57
+ version_requirements: *70212255998020
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: vcr
60
- requirement: &70100460192120 !ruby/object:Gem::Requirement
60
+ requirement: &70212255997640 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70100460192120
68
+ version_requirements: *70212255997640
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: nokogiri
71
- requirement: &70100460191520 !ruby/object:Gem::Requirement
71
+ requirement: &70212255996960 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.4.1
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70100460191520
79
+ version_requirements: *70212255996960
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: json
82
- requirement: &70100460190660 !ruby/object:Gem::Requirement
82
+ requirement: &70212255989460 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.4.6
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70100460190660
90
+ version_requirements: *70212255989460
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: public_suffix_service
93
- requirement: &70100460189840 !ruby/object:Gem::Requirement
93
+ requirement: &70212255988960 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 0.9.0
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70100460189840
101
+ version_requirements: *70212255988960
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: typhoeus
104
- requirement: &70100460189000 !ruby/object:Gem::Requirement
104
+ requirement: &70212255988400 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 0.2.1
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70100460189000
112
+ version_requirements: *70212255988400
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: jsonpath
115
- requirement: &70100460187520 !ruby/object:Gem::Requirement
115
+ requirement: &70212255987800 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: 0.4.2
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *70100460187520
123
+ version_requirements: *70212255987800
124
124
  description: Easy way to retrieve Google Page Rank, Alexa Rank, backlink counts, and
125
125
  index counts.
126
126
  email:
@@ -131,6 +131,7 @@ extra_rdoc_files: []
131
131
  files:
132
132
  - .gitignore
133
133
  - .rvmrc
134
+ - .travis.yml
134
135
  - CHANGELOG.md
135
136
  - Gemfile
136
137
  - LICENSE.md
@@ -168,6 +169,7 @@ files:
168
169
  - spec/fixtures/vcr_cassettes/success_indexes.yml
169
170
  - spec/fixtures/vcr_cassettes/success_ranks.yml
170
171
  - spec/page_rankr_spec.rb
172
+ - spec/ranks/google/checksum_spec.rb
171
173
  - spec/spec_helper.rb
172
174
  homepage: http://github.com/blatyo/page_rankr
173
175
  licenses: []
@@ -204,4 +206,5 @@ test_files:
204
206
  - spec/fixtures/vcr_cassettes/success_indexes.yml
205
207
  - spec/fixtures/vcr_cassettes/success_ranks.yml
206
208
  - spec/page_rankr_spec.rb
209
+ - spec/ranks/google/checksum_spec.rb
207
210
  - spec/spec_helper.rb