PageRankr 1.1.0 → 1.2.0

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.
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
- # Version 1.1.0
3
+ ## Version 1.2.0
4
+
5
+ * Changed backlinks method with no search engines specified to use all of them
6
+ * Changed ranks method with no search engines specified to use all of them
7
+ * Added alias rank for ranks
8
+ * Added alias backlink for backlinks
9
+
10
+ ## Version 1.1.0
4
11
 
5
12
  * Fixed google xpath for backlinks
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{PageRankr}
8
- s.version = "1.1.0"
8
+ s.version = "1.2.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"]
data/README.md CHANGED
@@ -16,13 +16,28 @@ Backlinks are the result of doing a search with a query like "link:www.google.co
16
16
 
17
17
  PageRankr.backlinks('www.google.com', :google, :bing) #=> {:google=>161000, :bing=>208000000}
18
18
  PageRankr.backlinks('www.google.com', :yahoo) #=> {:yahoo=>256300062}
19
+
20
+ If you don't specify a search engine, then all of them are used.
21
+
22
+ # this
23
+ PageRankr.backlinks('www.google.com')
24
+ #=> {:google=>23000, :bing=>215000000, :yahoo=>250522337, :altavista=>137000000, :alltheweb=>74500000, :alexa=>727036}
25
+
26
+ # is equivalent to
27
+ PageRankr.backlinks('www.google.com', :google, :bing, :yahoo, :altavista, :alltheweb, :alexa)
28
+ #=> {:google=>23000, :bing=>215000000, :yahoo=>250522337, :altavista=>137000000, :alltheweb=>74500000, :alexa=>727036}
19
29
 
30
+ You can also use the alias `backlink` instead of `backlinks`.
20
31
  Valid search engines are: `:google, :bing, :yahoo, :altavista, :alltheweb, :alexa`.
21
32
 
22
33
  ### Ranks
23
34
 
24
35
  PageRankr.ranks('www.google.com', :alexa, :google) #=> {:alexa=>1, :google=>10}
36
+
37
+ # this also gives the same result
38
+ PageRankr.ranks('www.google.com') #=> {:alexa=>1, :google=>10}
25
39
 
40
+ You can also use the alias `rank` instead of `ranks`.
26
41
  There are two valid rank trackers supported: `:alexa, :google`.
27
42
  Alexa ranks are descending where 1 is the most popular. If a site has an alexa rank of 0 then the site is unranked.
28
43
  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.
@@ -49,8 +64,7 @@ Google page ranks are in the range 0-10 where 10 is the most popular. If a site
49
64
  * <del>Get Google Page Rank</del>
50
65
  * <del>Implement Hashing Algorithm</del>
51
66
  * <del>Get Alexa ranking</del>
52
- * docs
53
- * tests (need to find way around counts changing)
67
+ * Major refactorings (Version 2)
54
68
 
55
69
  ## Shout Out
56
70
  Gotta give credit where credits due!
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -8,8 +8,11 @@ module PageRankr
8
8
  def backlinks(site, *search_engines)
9
9
  Backlinks.lookup site, *search_engines
10
10
  end
11
+ alias_method :backlink, :backlinks
11
12
 
12
13
  def ranks(site, *rank_trackers)
14
+ rank_trackers = [:google, :alexa] if rank_trackers.empty?
15
+
13
16
  ranks = {}
14
17
  rank_trackers.each do |tracker|
15
18
  case tracker
@@ -21,5 +24,6 @@ module PageRankr
21
24
  end
22
25
  ranks
23
26
  end
27
+ alias_method :rank, :ranks
24
28
  end
25
29
  end
@@ -4,6 +4,8 @@ require 'nokogiri'
4
4
 
5
5
  module PageRankr
6
6
  class Backlinks
7
+ SEARCH_ENGINES = [:google, :bing, :yahoo, :altavista, :alltheweb, :alexa]
8
+
7
9
  SEARCH_ENGINE_URLS = {
8
10
  :google => "http://www.google.com/search?q=link%3A",
9
11
  :bing => "http://www.bing.com/search?q=link%3A",
@@ -23,6 +25,8 @@ module PageRankr
23
25
  }
24
26
 
25
27
  def self.lookup(site, *search_engines)
28
+ search_engines = SEARCH_ENGINES if search_engines.empty?
29
+
26
30
  backlinks = {}
27
31
  search_engines.each do |engine|
28
32
  next unless SEARCH_ENGINE_URLS[engine]
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 1.1.0
9
+ version: 1.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Allen Madsen