PageRankr 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## Version 1.4.0
4
+
5
+ * Made it easier to get at the list of supported trackers.
6
+ * Refactoring
7
+
3
8
  ## Version 1.3.0
4
9
 
5
10
  * Lots of refactoring. Should be much easier to extend and temporarily fix if needed.
data/PageRankr.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{PageRankr}
8
- s.version = "1.3.0"
8
+ s.version = "1.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Allen Madsen"]
12
- s.date = %q{2010-07-05}
12
+ s.date = %q{2010-07-06}
13
13
  s.description = %q{Easy way to retrieve Google Page Rank, Alexa Rank, and backlink counts}
14
14
  s.email = %q{blatyo@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -37,7 +37,9 @@ Gem::Specification.new do |s|
37
37
  "lib/page_rankr/ranks.rb",
38
38
  "lib/page_rankr/ranks/alexa.rb",
39
39
  "lib/page_rankr/ranks/google.rb",
40
- "lib/page_rankr/ranks/google/checksum.rb"
40
+ "lib/page_rankr/ranks/google/checksum.rb",
41
+ "lib/page_rankr/ranks/rank.rb",
42
+ "lib/page_rankr/tracker.rb"
41
43
  ]
42
44
  s.homepage = %q{http://github.com/blatyo/page_rankr}
43
45
  s.rdoc_options = ["--charset=UTF-8"]
data/README.md CHANGED
@@ -28,7 +28,9 @@ If you don't specify a search engine, then all of them are used.
28
28
  #=> {:google=>23000, :bing=>215000000, :yahoo=>250522337, :altavista=>137000000, :alltheweb=>74500000, :alexa=>727036}
29
29
 
30
30
  You can also use the alias `backlink` instead of `backlinks`.
31
- Valid search engines are: `:google, :bing, :yahoo, :altavista, :alltheweb, :alexa`.
31
+ Valid search engines are: `:google, :bing, :yahoo, :altavista, :alltheweb, :alexa`. To get this list you can do:
32
+
33
+ PageRankr.backlink_trackers #=> [:alexa, :alltheweb, :altavista, :bing, :google, :yahoo]
32
34
 
33
35
  ### Ranks
34
36
 
@@ -38,7 +40,10 @@ Valid search engines are: `:google, :bing, :yahoo, :altavista, :alltheweb, :alex
38
40
  PageRankr.ranks('www.google.com') #=> {:alexa=>1, :google=>10}
39
41
 
40
42
  You can also use the alias `rank` instead of `ranks`.
41
- There are two valid rank trackers supported: `:alexa, :google`.
43
+ There are two valid rank trackers supported: `:alexa, :google`. To get this you can do:
44
+
45
+ PageRankr.rank_trackers #=> [:alexa, :google]
46
+
42
47
  Alexa ranks are descending where 1 is the most popular. If a site has an alexa rank of 0 then the site is unranked.
43
48
  Google page ranks are in the range 0-10 where 10 is the most popular. If a site is unindexed then the rank will be -1.
44
49
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.4.0
data/lib/page_rankr.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require File.join("page_rankr", "tracker")
1
2
  require File.join("page_rankr", "backlinks")
2
3
  require File.join("page_rankr", "ranks")
3
4
 
@@ -12,5 +13,13 @@ module PageRankr
12
13
  Ranks.new.lookup site, *rank_trackers
13
14
  end
14
15
  alias_method :rank, :ranks
16
+
17
+ def rank_trackers
18
+ Ranks.new.rank_trackers
19
+ end
20
+
21
+ def backlink_trackers
22
+ Backlinks.new.backlink_trackers
23
+ end
15
24
  end
16
25
  end
@@ -7,26 +7,12 @@ require File.join("page_rankr", "backlinks", "google")
7
7
  require File.join("page_rankr", "backlinks", "yahoo")
8
8
 
9
9
  module PageRankr
10
- class Backlinks
11
- attr_accessor :search_engines
10
+ class Backlinks < Tracker
11
+ alias_method :backlink_trackers, :site_trackers
12
12
 
13
13
  def initialize
14
- @search_engines = self.class.constants
15
- @search_engines.delete(:Backlink)
16
- end
17
-
18
- def lookup(site, *engines)
19
- engines = search_engines if engines.empty?
20
-
21
- backlinks = {}
22
- engines.each do |engine|
23
- name, klass = engine.to_s.capitalize, self.class
24
-
25
- next unless klass.const_defined? name
26
-
27
- backlinks[engine.to_s.downcase.to_sym] = klass.const_get(name).new(site).backlinks
28
- end
29
- backlinks
14
+ super
15
+ @site_trackers.delete(:backlink)
30
16
  end
31
17
  end
32
18
  end
@@ -1,7 +1,7 @@
1
1
  require 'cgi'
2
2
 
3
3
  module PageRankr
4
- class Backlinks
4
+ class Backlinks < Tracker
5
5
  class Alexa < Backlink
6
6
  def url(site)
7
7
  "http://data.alexa.com/data?cli=10&dat=snbamz&url=#{CGI.escape(site)}"
@@ -1,7 +1,7 @@
1
1
  require 'cgi'
2
2
 
3
3
  module PageRankr
4
- class Backlinks
4
+ class Backlinks < Tracker
5
5
  class Alltheweb < Backlink
6
6
  def url(site)
7
7
  "http://www.alltheweb.com/search?q=link%3A#{CGI.escape(site)}"
@@ -1,7 +1,7 @@
1
1
  require 'cgi'
2
2
 
3
3
  module PageRankr
4
- class Backlinks
4
+ class Backlinks < Tracker
5
5
  class Altavista < Backlink
6
6
  def url(site)
7
7
  "http://www.altavista.com/web/results?q=link%3A#{CGI.escape(site)}"
@@ -2,9 +2,10 @@ require 'nokogiri'
2
2
  require 'open-uri'
3
3
 
4
4
  module PageRankr
5
- class Backlinks
5
+ class Backlinks < Tracker
6
6
  class Backlink
7
7
  attr_reader :backlinks
8
+ alias_method :tracked, :backlinks
8
9
 
9
10
  def initialize(site)
10
11
  @backlinks = clean Nokogiri::HTML(open url(site)).at(xpath).to_s
@@ -1,7 +1,7 @@
1
1
  require 'cgi'
2
2
 
3
3
  module PageRankr
4
- class Backlinks
4
+ class Backlinks < Tracker
5
5
  class Bing < Backlink
6
6
  def url(site)
7
7
  "http://www.bing.com/search?q=link%3A#{CGI.escape(site)}"
@@ -1,7 +1,7 @@
1
1
  require 'cgi'
2
2
 
3
3
  module PageRankr
4
- class Backlinks
4
+ class Backlinks < Tracker
5
5
  class Google < Backlink
6
6
  def url(site)
7
7
  "http://www.google.com/search?q=link%3A#{CGI.escape(site)}"
@@ -1,7 +1,7 @@
1
1
  require 'cgi'
2
2
 
3
3
  module PageRankr
4
- class Backlinks
4
+ class Backlinks < Tracker
5
5
  class Yahoo < Backlink
6
6
  def url(site)
7
7
  "http://siteexplorer.search.yahoo.com/search?p=#{CGI.escape(site)}"
@@ -1,26 +1,14 @@
1
+ require File.join("page_rankr", "ranks", "rank")
1
2
  require File.join("page_rankr", "ranks", "alexa")
2
3
  require File.join("page_rankr", "ranks", "google")
3
4
 
4
5
  module PageRankr
5
- class Ranks
6
- attr_reader :rank_trackers
6
+ class Ranks < Tracker
7
+ alias_method :rank_trackers, :site_trackers
7
8
 
8
9
  def initialize
9
- @rank_trackers = self.class.constants
10
- end
11
-
12
- def lookup(site, *trackers)
13
- trackers = rank_trackers if trackers.empty?
14
-
15
- ranks = {}
16
- trackers.each do |tracker|
17
- name, klass = tracker.to_s.capitalize, self.class
18
-
19
- next unless klass.const_defined? name
20
-
21
- ranks[tracker.to_s.downcase.to_sym] = klass.const_get(name).new(site).rank
22
- end
23
- ranks
10
+ super
11
+ @site_trackers.delete(:rank)
24
12
  end
25
13
  end
26
14
  end
@@ -3,10 +3,8 @@ require 'cgi'
3
3
  require 'nokogiri'
4
4
 
5
5
  module PageRankr
6
- class Ranks
7
- class Alexa
8
- attr_reader :rank
9
-
6
+ class Ranks < Tracker
7
+ class Alexa < Rank
10
8
  def initialize(site)
11
9
  @rank = Nokogiri::HTML(open(url(site))).search(xpath).to_s.to_i
12
10
  end
@@ -2,10 +2,8 @@ require "open-uri"
2
2
  require File.join("page_rankr", "ranks", "google", "checksum")
3
3
 
4
4
  module PageRankr
5
- class Ranks
6
- class Google
7
- attr_reader :rank
8
-
5
+ class Ranks < Tracker
6
+ class Google < Rank
9
7
  def initialize(site)
10
8
  checksum = Checksum.generate(site)
11
9
  begin
@@ -1,6 +1,6 @@
1
1
  module PageRankr
2
- class Ranks
3
- class Google
2
+ class Ranks < Tracker
3
+ class Google < Rank
4
4
  class Checksum
5
5
  class << self
6
6
  def generate(site)
@@ -0,0 +1,8 @@
1
+ module PageRankr
2
+ class Ranks < Tracker
3
+ class Rank
4
+ attr_reader :rank
5
+ alias_method :tracked, :rank
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,23 @@
1
+ module PageRankr
2
+ class Tracker
3
+ attr_accessor :site_trackers
4
+
5
+ def initialize
6
+ @site_trackers = self.class.constants.collect{|tracker| tracker.to_s.downcase.to_sym}
7
+ end
8
+
9
+ def lookup(site, *trackers)
10
+ trackers = site_trackers if trackers.empty?
11
+
12
+ tracked = {}
13
+ trackers.each do |tracker|
14
+ name, klass = tracker.to_s.capitalize, self.class
15
+
16
+ next unless klass.const_defined? name
17
+
18
+ tracked[tracker] = klass.const_get(name).new(site).tracked
19
+ end
20
+ tracked
21
+ end
22
+ end
23
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 3
7
+ - 4
8
8
  - 0
9
- version: 1.3.0
9
+ version: 1.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Allen Madsen
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-05 00:00:00 -04:00
17
+ date: 2010-07-06 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -76,6 +76,8 @@ files:
76
76
  - lib/page_rankr/ranks/alexa.rb
77
77
  - lib/page_rankr/ranks/google.rb
78
78
  - lib/page_rankr/ranks/google/checksum.rb
79
+ - lib/page_rankr/ranks/rank.rb
80
+ - lib/page_rankr/tracker.rb
79
81
  has_rdoc: true
80
82
  homepage: http://github.com/blatyo/page_rankr
81
83
  licenses: []