googlepagerank 1.0.0 → 1.0.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.
data.tar.gz.sig CHANGED
Binary file
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ Hoe.new('googlepagerank', GooglePageRank::VERSION) do |p|
9
9
  # p.developer('FIX', 'FIX@example.com')
10
10
  p.name = "googlepagerank"
11
11
  p.author = "Francisco Dieguez"
12
- p.description = "Google PageRank for Ruby."
12
+ p.description = "Google PageRank Gem for Ruby."
13
13
  p.email = 'fran.dieguez@glug.es'
14
14
  p.summary = "Google PageRank for Ruby."
15
15
  p.url = "http://www.mabishu.com/projects/googlepagerank"
@@ -1,7 +1,26 @@
1
1
  #!/usr/bin/ruby
2
+
3
+ # == Synopsis
4
+ #
5
+ # Fetch the Google PageRank for a given url
6
+ #
7
+ # ==
8
+ #
9
+ # googlepagerank [ -h | --help ] [ -s ] -u url
10
+ #
11
+ # url::
12
+ # String of a URL, +url+, for fetch
13
+
14
+ # == Author
15
+ # Fran Diéguez
16
+ #
17
+ # == Copyright
18
+ # Copyright (c) 2088 Fran Diéguez.
19
+ # Licensed under MIT License.
20
+
21
+
2
22
  require "rubygems"
3
- #require "googlepagerank"
4
- load "../lib/googlepagerank.rb"
23
+ require "googlepagerank"
5
24
  require "getoptlong"
6
25
  opt_url=""
7
26
  opt_silent=0;
@@ -3,19 +3,19 @@
3
3
  require "net/http"
4
4
 
5
5
  class GooglePageRank
6
- VERSION = '1.0.0'
6
+ VERSION = '1.0.1'
7
7
 
8
8
  M=0x100000000 # modulo for unsigned int 32bit(4byte)
9
-
9
+
10
10
  def self.m1(a,b,c,d)
11
11
  return (((a+(M-b)+(M-c))%M)^(d%M))%M # mix/power mod
12
12
  end
13
-
13
+
14
14
  def self.c2i(s="",k=0)
15
15
  # char codes to int. Little Endian
16
16
  return ((s[k+3].to_i*0x100+s[k+2].to_i)*0x100+s[k+1].to_i)*0x100+s[k].to_i
17
17
  end
18
-
18
+
19
19
  def self.mix(a,b,c)
20
20
  a=a%M; b=b%M; c=c%M
21
21
  a = m1(a,b,c, c >> 13); b = m1(b,c,a, a << 8); c = m1(c,a,b, b >> 13);
@@ -35,7 +35,25 @@ class GooglePageRank
35
35
  return c;
36
36
  end
37
37
 
38
- # Old Version of get, after they changed the format
38
+ # Calculates the PageRank for the given _url_
39
+ # ATENTION: Old version, use the GooglePageRak.get() instead
40
+ #
41
+ # :call-seq:
42
+ # GooglePageRank.get0("url",[port],[proxy_url],[proxy_port]) -> Fixnum
43
+ #
44
+ # If an error ocurrs with the connection
45
+ # or the domain isn't indexed returns -1
46
+ # ==== Parameters
47
+ # url<String>::
48
+ # port<Fixnum>::
49
+ # proxy<String>::
50
+ # proxy_port<Fixnum>::
51
+ # ==== Returns
52
+ # Fixnum:: The PageRank for the given url.
53
+ # ==== Examples
54
+ # GooglePageRank.get0("www.mabishu.com") # => 4
55
+ # GooglePageRank.get0("www.mabishu.com", 80) # => 4
56
+ # GooglePageRank.get0("www.mabishu.com", 80, "http://proxy.example.com", 8080) # => 4
39
57
  def self.get0(url="http://sample/index.html",port=80,proxy=nil,proxy_port=nil)
40
58
  # get Google PageRank
41
59
  # old version
@@ -58,7 +76,27 @@ class GooglePageRank
58
76
  if (p.size>0) then return p.to_i; else return -1; end
59
77
  end
60
78
 
61
- # Nueva version de get (16 july 2007)
79
+
80
+
81
+ # Calculates the PageRank for the given _url_
82
+ # New algorithm version (16 july 2007)
83
+ #
84
+ # :call-seq:
85
+ # GooglePageRank.get("url",[port],[proxy_url],[proxy_port]) -> Fixnum
86
+ #
87
+ # If an error ocurrs with the connection
88
+ # or the domain isn't indexed returns -1
89
+ # ==== Parameters
90
+ # url<String>::
91
+ # port<Fixnum>::
92
+ # proxy<String>::
93
+ # proxy_port<Fixnum>::
94
+ # ==== Returns
95
+ # Fixnum:: The PageRank for the given url.
96
+ # ==== Examples
97
+ # GooglePageRank.get("www.mabishu.com") # => 4
98
+ # GooglePageRank.get("www.mabishu.com", 80) # => 4
99
+ # GooglePageRank.get("www.mabishu.com", 80, "http://proxy.example.com", 8080) # => 4
62
100
  def self.get(url="http://sample/index.html",port=80,proxy=nil,proxy_port=nil)
63
101
  # get Google PageRank
64
102
  # 2007.07.10
@@ -68,7 +106,6 @@ class GooglePageRank
68
106
  #g_path=sprintf("/search?client=navclient-auto&failedip=216.239.51.102;821&ch=6%u&q=info:%s", ch, url);
69
107
  g_path=sprintf("/search?client=navclient-auto&features=Rank&failedip=216.239.51.102;821&q=info:%s&ch=6%u", url, ch);
70
108
  p="" # rank
71
- puts g_path
72
109
  # printf("%s\n",g_path)
73
110
  # http://www.google.co.jp/search?client=navclient-auto&ch=63055969557&features=Rank&q=info:http://www.hyperposition.com/se3blog/
74
111
  # http://www.google.co.jp/search?client=navclient-auto&features=Rank&q=info:http://www.hyperposition.com/&ch=6768349016
@@ -7,6 +7,6 @@ class TestGooglePageRank < Test::Unit::TestCase
7
7
  assert_equal(9, GooglePageRank.get("www.apple.com",80,nil,nil))
8
8
  end
9
9
  def test_invalid_page
10
- assert_equal(-1, GooglePageRank.get("",80,nil,nil))
10
+ assert_equal(-1, GooglePageRank.get("wwwtesting.com",80,nil,nil))
11
11
  end
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googlepagerank
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francisco Dieguez
@@ -30,7 +30,7 @@ cert_chain:
30
30
  EHxmDQrhRAnf3g==
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2008-04-12 00:00:00 +02:00
33
+ date: 2008-04-13 00:00:00 +02:00
34
34
  default_executable:
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
@@ -42,7 +42,7 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 1.5.1
44
44
  version:
45
- description: Google PageRank for Ruby.
45
+ description: Google PageRank Gem for Ruby.
46
46
  email: fran.dieguez@glug.es
47
47
  executables:
48
48
  - googlepagerank
metadata.gz.sig CHANGED
Binary file