PageRankr 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -21,4 +21,5 @@ pkg
21
21
  ## PROJECT::SPECIFIC
22
22
  .idea
23
23
  doc
24
- .yardoc
24
+ .yardoc
25
+ .bundle
data/CHANGELOG.md CHANGED
@@ -1,4 +1,16 @@
1
1
  # Change Log
2
+ ## Version 1.6
3
+
4
+ * Added ability to get global alexa rank instead of just us alexa rank.
5
+
6
+ ## Version 1.5.1
7
+
8
+ * Added json gem requirement for rubies < 1.9
9
+
10
+ ## Version 1.5.0
11
+
12
+ * Use googles api to retrieve backlinks.
13
+ * Changed workflow for building gems.
2
14
 
3
15
  ## Version 1.4.3
4
16
 
data/Gemfile.lock CHANGED
@@ -1,17 +1,38 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- PageRankr (1.5.0)
4
+ PageRankr (1.6.0)
5
+ json (>= 1.4.6)
5
6
  nokogiri (>= 1.4.1)
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
9
10
  specs:
11
+ diff-lcs (1.1.2)
12
+ fuubar (0.0.2)
13
+ rspec (~> 2.0)
14
+ rspec-instafail (~> 0.1.4)
15
+ ruby-progressbar (~> 0.0.9)
16
+ json (1.4.6)
10
17
  nokogiri (1.4.3.1)
18
+ rspec (2.1.0)
19
+ rspec-core (~> 2.1.0)
20
+ rspec-expectations (~> 2.1.0)
21
+ rspec-mocks (~> 2.1.0)
22
+ rspec-core (2.1.0)
23
+ rspec-expectations (2.1.0)
24
+ diff-lcs (~> 1.1.2)
25
+ rspec-instafail (0.1.5)
26
+ rspec-mocks (2.1.0)
27
+ ruby-progressbar (0.0.9)
11
28
 
12
29
  PLATFORMS
13
30
  ruby
14
31
 
15
32
  DEPENDENCIES
16
33
  PageRankr!
34
+ bundler (>= 1.0.0)
35
+ fuubar (>= 0.0.1)
36
+ json (>= 1.4.6)
17
37
  nokogiri (>= 1.4.1)
38
+ rspec (~> 2.1.0)
data/PageRankr.gemspec CHANGED
@@ -1,42 +1,26 @@
1
1
  require File.expand_path("../lib/page_rankr/version", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
- s.name = %q{PageRankr}
5
- s.version = PageRankr::VERSION
4
+ s.name = "PageRankr"
5
+ s.version = PageRankr::VERSION
6
+ s.platform = Gem::Platform::RUBY
7
+ s.authors = ["Allen Madsen"]
8
+ s.email = ["blatyo@gmail.com"]
9
+ s.homepage = "http://github.com/blatyo/page_rankr"
10
+ s.summary = "Easy way to retrieve Google Page Rank, Alexa Rank, and backlink counts"
11
+ s.description = "Easy way to retrieve Google Page Rank, Alexa Rank, and backlink counts"
6
12
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Allen Madsen"]
9
- s.date = %q{2010-07-07}
10
- s.description = %q{Easy way to retrieve Google Page Rank, Alexa Rank, and backlink counts}
11
- s.email = %q{blatyo@gmail.com}
12
- s.extra_rdoc_files = [
13
- "LICENSE.md",
14
- "README.md"
15
- ]
16
-
17
- s.files = `git ls-files`.split("\n")
18
- s.test_files = `git ls-files`.split("\n").map{|f| f =~ /^spec\/(.*)/ ? $1 : nil}.compact
19
- s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
20
- s.homepage = %q{http://github.com/blatyo/page_rankr}
21
- s.rdoc_options = ["--charset=UTF-8"]
22
- s.require_paths = ["lib"]
23
- s.rubygems_version = %q{1.5.0}
24
- s.summary = %q{Easy way to retrieve Google Page Rank, Alexa Rank, and backlink counts}
13
+ s.required_rubygems_version = ">= 1.3.6"
14
+ s.add_development_dependency "rspec", "~> 2.1.0"
15
+ s.add_development_dependency "bundler", ">= 1.0.0"
16
+ s.add_development_dependency "fuubar", ">= 0.0.1"
25
17
 
26
- if s.respond_to? :specification_version then
27
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
28
- s.specification_version = 3
18
+ s.add_runtime_dependency "nokogiri", ">= 1.4.1"
19
+ s.add_runtime_dependency "json", ">= 1.4.6"
29
20
 
30
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
31
- s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.1"])
32
- s.add_runtime_dependency(%q<json>, [">= 1.4.6"])
33
- else
34
- s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
35
- s.add_dependency(%q<json>, [">= 1.4.6"])
36
- end
37
- else
38
- s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
39
- s.add_dependency(%q<json>, [">= 1.4.6"])
40
- end
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
24
+ s.require_paths = ["lib"]
41
25
  end
42
26
 
data/README.md CHANGED
@@ -10,7 +10,7 @@ Check out a little [web app][1] I wrote up that uses it or look at the [source][
10
10
  ## Get it!
11
11
 
12
12
  gem install PageRankr
13
-
13
+
14
14
  ## Use it!
15
15
 
16
16
  require 'page_rankr'
@@ -21,16 +21,16 @@ Backlinks are the result of doing a search with a query like "link:www.google.co
21
21
 
22
22
  PageRankr.backlinks('www.google.com', :google, :bing) #=> {:google=>161000, :bing=>208000000}
23
23
  PageRankr.backlinks('www.google.com', :yahoo) #=> {:yahoo=>256300062}
24
-
24
+
25
25
  If you don't specify a search engine, then all of them are used.
26
26
 
27
27
  # this
28
- PageRankr.backlinks('www.google.com')
29
- #=> {:google=>23000, :bing=>215000000, :yahoo=>250522337, :altavista=>137000000, :alltheweb=>74500000, :alexa=>727036}
30
-
28
+ PageRankr.backlinks('www.google.com')
29
+ #=> {:google=>23000, :bing=>215000000, :yahoo=>250522337, :altavista=>137000000, :alltheweb=>74500000, :alexa=>727036}
30
+
31
31
  # is equivalent to
32
32
  PageRankr.backlinks('www.google.com', :google, :bing, :yahoo, :altavista, :alltheweb, :alexa)
33
- #=> {:google=>23000, :bing=>215000000, :yahoo=>250522337, :altavista=>137000000, :alltheweb=>74500000, :alexa=>727036}
33
+ #=> {:google=>23000, :bing=>215000000, :yahoo=>250522337, :altavista=>137000000, :alltheweb=>74500000, :alexa=>727036}
34
34
 
35
35
  You can also use the alias `backlink` instead of `backlinks`.
36
36
  Valid search engines are: `:google, :bing, :yahoo, :altavista, :alltheweb, :alexa`. To get this list you can do:
@@ -39,10 +39,10 @@ Valid search engines are: `:google, :bing, :yahoo, :altavista, :alltheweb, :alex
39
39
 
40
40
  ### Ranks
41
41
 
42
- PageRankr.ranks('www.google.com', :alexa, :google) #=> {:alexa=>1, :google=>10}
43
-
42
+ PageRankr.ranks('www.google.com', :alexa, :google) #=> {:alexa=>{:us=>1, :global=>1}, :google=>10}
43
+
44
44
  # this also gives the same result
45
- PageRankr.ranks('www.google.com') #=> {:alexa=>1, :google=>10}
45
+ PageRankr.ranks('www.google.com') #=> {:alexa=>{:us=>1, :global=>1}, :google=>10}
46
46
 
47
47
  You can also use the alias `rank` instead of `ranks`.
48
48
  There are two valid rank trackers supported: `:alexa, :google`. To get this you can do:
@@ -76,11 +76,11 @@ If you ever come across a site that provides a rank or backlinks you can hook th
76
76
  def url(site)
77
77
  "http://example.com/?q=#{site}"
78
78
  end
79
-
79
+
80
80
  def xpath
81
81
  "//backlinks/text()"
82
82
  end
83
-
83
+
84
84
  def clean(backlink_count)
85
85
  #do some of my own cleaning
86
86
  super(backlink_count) # strips letters, commas, and a few other nasty things and converts it to an integer
@@ -88,11 +88,11 @@ If you ever come across a site that provides a rank or backlinks you can hook th
88
88
  end
89
89
  end
90
90
  end
91
-
92
- Then, just make sure you require the class and PageRankr and whenver you call PageRankr.backlinks it'll be able to use your class.
91
+
92
+ Then, just make sure you require the class and PageRankr and whenever you call PageRankr.backlinks it'll be able to use your class.
93
93
 
94
94
  ## Note on Patches/Pull Requests
95
-
95
+
96
96
  * Fork the project.
97
97
  * Make your feature addition or bug fix.
98
98
  * Add tests for it. This is important so I don't break it in a
@@ -101,18 +101,13 @@ Then, just make sure you require the class and PageRankr and whenver you call Pa
101
101
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
102
102
  * Send me a pull request. Bonus points for topic branches.
103
103
 
104
- ## TODO
105
- * <del>Get backlink counts for:</del>
106
- * <del>Google</del>
107
- * <del>Bing</del>
108
- * <del>Yahoo!</del>
109
- * <del>AltaVista</del>
110
- * <del>AllTheWeb</del>
111
- * <del>Alexa</del>
112
- * <del>Get Google Page Rank</del>
113
- * <del>Implement Hashing Algorithm</del>
114
- * <del>Get Alexa ranking</del>
104
+ ## TODO Version 2
115
105
  * Use API's where possible
106
+ * Use [Typhoeus](https://github.com/pauldix/typhoeus) to improve speed when requesting multiple ranks and/or backlinks
107
+ * Configuration
108
+ * API keys
109
+ * Alexa rank options
110
+ * Add compete rank tracker
116
111
 
117
112
  ## Contributors
118
113
  * [Druwerd](http://github.com/Druwerd) - Use Google Search API instead of scraping.
@@ -120,9 +115,9 @@ Then, just make sure you require the class and PageRankr and whenver you call Pa
120
115
  ## Shout Out
121
116
  Gotta give credit where credits due!
122
117
 
123
- * http://github.com/alexmipego/PageRankSharp
124
- * http://snipplr.com/view/18329/google-page-range-lookup/
125
- * http://www.sitetoolcenter.com/free-website-scripts/ajax-pr-checker.php
118
+ * [http://github.com/alexmipego/PageRankSharp](http://github.com/alexmipego/PageRankSharp)
119
+ * [http://snipplr.com/view/18329/google-page-range-lookup/](http://snipplr.com/view/18329/google-page-range-lookup/)
120
+ * [http://www.sitetoolcenter.com/free-website-scripts/ajax-pr-checker.php](http://www.sitetoolcenter.com/free-website-scripts/ajax-pr-checker.php)
126
121
 
127
122
  ## Copyright
128
123
 
data/Rakefile CHANGED
@@ -1,31 +1,5 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
3
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "PageRankr"
8
- gem.summary = %Q{Easy way to retrieve Google Page Rank, Alexa Rank, and backlink counts}
9
- gem.description = %Q{Easy way to retrieve Google Page Rank, Alexa Rank, and backlink counts}
10
- gem.email = "blatyo@gmail.com"
11
- gem.homepage = "http://github.com/blatyo/page_rankr"
12
- gem.authors = ["Allen Madsen"]
13
- gem.add_dependency "nokogiri", ">= 1.4.1"
14
- gem.add_development_dependency "yard", ">= 0"
15
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
- end
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
- end
21
-
22
- task :default => :yardoc
23
-
24
- begin
25
- require 'yard'
26
- YARD::Rake::YardocTask.new
27
- rescue LoadError
28
- task :yardoc do
29
- abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
30
- end
31
- end
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
@@ -6,11 +6,16 @@ module PageRankr
6
6
  class Ranks < Tracker
7
7
  class Alexa < Rank
8
8
  def initialize(site)
9
- @rank = Nokogiri::HTML(open(url(site))).search(xpath).to_s.to_i
9
+ @rank = {}
10
+ xpath.each_key do |key|
11
+ @rank[key] = Nokogiri::HTML(open(url(site))).search(xpath[key]).to_s.to_i
12
+ end
13
+ @rank
10
14
  end
11
15
 
12
16
  def xpath
13
- "//reach/@rank"
17
+ { :us => "//reach/@rank",
18
+ :global => "//popularity/@text" }
14
19
  end
15
20
 
16
21
  def url(site)
@@ -1,3 +1,3 @@
1
1
  module PageRankr
2
- VERSION = "1.5.1"
2
+ VERSION = "1.6.0"
3
3
  end
@@ -0,0 +1,91 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec::Matchers.define :be_in do |expected|
4
+ match do |actual|
5
+ expected === actual
6
+ end
7
+
8
+ failure_message_for_should do |actual|
9
+ "expected that #{actual} would be in #{expected}"
10
+ end
11
+ end
12
+
13
+ describe PageRankr do
14
+ describe "#rank_trackers" do
15
+ subject{ PageRankr.rank_trackers }
16
+
17
+ it{ should include(:alexa) }
18
+ it{ should include(:google) }
19
+ end
20
+
21
+ describe "#ranks" do
22
+ describe "success" do
23
+ subject{ PageRankr.ranks("google.com") }
24
+
25
+ it{ should have_key(:alexa) }
26
+ it{ should have_key(:google) }
27
+
28
+ let(:alexa_rank) { subject[:alexa] }
29
+ it{ alexa_rank.should have_key(:us) }
30
+ it{ alexa_rank.should have_key(:global) }
31
+
32
+ let(:alexa_us_rank) { alexa_rank[:us] }
33
+ it{ alexa_us_rank.should >= 1 }
34
+ let(:alexa_global_rank) { alexa_rank[:global] }
35
+ it{ alexa_global_rank.should >= 1 }
36
+
37
+ let(:google_rank) { subject[:google] }
38
+ it{ google_rank.should be_in(0..10)}
39
+ end
40
+
41
+ describe "failure" do
42
+ subject{ PageRankr.ranks("please-dont-register-a-site-that-breaks-this-test.com") }
43
+
44
+ it{ should have_key(:alexa) }
45
+ it{ should have_key(:google) }
46
+
47
+ let(:alexa_rank) { subject[:alexa] }
48
+ it{ alexa_rank.should have_key(:us) }
49
+ it{ alexa_rank.should have_key(:global) }
50
+
51
+ let(:alexa_us_rank) { alexa_rank[:us] }
52
+ it{ alexa_us_rank.should == 0 }
53
+ let(:alexa_global_rank) { alexa_rank[:global] }
54
+ it{ alexa_global_rank.should == 0 }
55
+
56
+ let(:google_rank) { subject[:google] }
57
+ it{ google_rank.should == -1 }
58
+ end
59
+ end
60
+
61
+ describe "#backlink_trackers" do
62
+ subject{ PageRankr.backlink_trackers }
63
+
64
+ it{ should include(:alexa) }
65
+ it{ should include(:alltheweb) }
66
+ it{ should include(:altavista) }
67
+ it{ should include(:bing) }
68
+ it{ should include(:google) }
69
+ it{ should include(:yahoo) }
70
+ end
71
+
72
+ describe "#backlinks" do
73
+ describe "success" do
74
+ subject{ PageRankr.backlinks("google.com") }
75
+
76
+ PageRankr.backlink_trackers.each do |tracker|
77
+ it{ should have_key(tracker) }
78
+ it{ subject[tracker].should >= 0 }
79
+ end
80
+ end
81
+
82
+ describe "failure" do
83
+ subject{ PageRankr.backlinks("please-dont-register-a-site-that-breaks-this-test.com") }
84
+
85
+ PageRankr.backlink_trackers.each do |tracker|
86
+ it{ should have_key(tracker) }
87
+ it{ subject[tracker].should == 0 }
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,8 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'page_rankr')
2
+ require 'rspec'
3
+ require 'fuubar'
4
+
5
+ Rspec.configure do |c|
6
+ c.formatter = Fuubar
7
+ c.color_enabled = true
8
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 5
8
- - 1
9
- version: 1.5.1
7
+ - 6
8
+ - 0
9
+ version: 1.6.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Allen Madsen
@@ -14,13 +14,58 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-07 00:00:00 -04:00
17
+ date: 2010-12-04 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: nokogiri
21
+ name: rspec
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 1
31
+ - 0
32
+ version: 2.1.0
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: bundler
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 1
45
+ - 0
46
+ - 0
47
+ version: 1.0.0
48
+ type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: fuubar
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
60
+ - 0
61
+ - 1
62
+ version: 0.0.1
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: nokogiri
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
24
69
  none: false
25
70
  requirements:
26
71
  - - ">="
@@ -31,11 +76,11 @@ dependencies:
31
76
  - 1
32
77
  version: 1.4.1
33
78
  type: :runtime
34
- version_requirements: *id001
79
+ version_requirements: *id004
35
80
  - !ruby/object:Gem::Dependency
36
81
  name: json
37
82
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
83
+ requirement: &id005 !ruby/object:Gem::Requirement
39
84
  none: false
40
85
  requirements:
41
86
  - - ">="
@@ -46,19 +91,17 @@ dependencies:
46
91
  - 6
47
92
  version: 1.4.6
48
93
  type: :runtime
49
- version_requirements: *id002
94
+ version_requirements: *id005
50
95
  description: Easy way to retrieve Google Page Rank, Alexa Rank, and backlink counts
51
- email: blatyo@gmail.com
96
+ email:
97
+ - blatyo@gmail.com
52
98
  executables: []
53
99
 
54
100
  extensions: []
55
101
 
56
- extra_rdoc_files:
57
- - LICENSE.md
58
- - README.md
102
+ extra_rdoc_files: []
103
+
59
104
  files:
60
- - .bundle/config
61
- - .document
62
105
  - .gitignore
63
106
  - .rvmrc
64
107
  - CHANGELOG.md
@@ -84,13 +127,15 @@ files:
84
127
  - lib/page_rankr/ranks/google/checksum.rb
85
128
  - lib/page_rankr/tracker.rb
86
129
  - lib/page_rankr/version.rb
130
+ - spec/page_rankr_spec.rb
131
+ - spec/spec_helper.rb
87
132
  has_rdoc: true
88
133
  homepage: http://github.com/blatyo/page_rankr
89
134
  licenses: []
90
135
 
91
136
  post_install_message:
92
- rdoc_options:
93
- - --charset=UTF-8
137
+ rdoc_options: []
138
+
94
139
  require_paths:
95
140
  - lib
96
141
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -107,8 +152,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
152
  - - ">="
108
153
  - !ruby/object:Gem::Version
109
154
  segments:
110
- - 0
111
- version: "0"
155
+ - 1
156
+ - 3
157
+ - 6
158
+ version: 1.3.6
112
159
  requirements: []
113
160
 
114
161
  rubyforge_project:
@@ -116,5 +163,6 @@ rubygems_version: 1.3.7
116
163
  signing_key:
117
164
  specification_version: 3
118
165
  summary: Easy way to retrieve Google Page Rank, Alexa Rank, and backlink counts
119
- test_files: []
120
-
166
+ test_files:
167
+ - spec/page_rankr_spec.rb
168
+ - spec/spec_helper.rb
data/.bundle/config DELETED
@@ -1,2 +0,0 @@
1
- ---
2
- BUNDLE_DISABLE_SHARED_GEMS: "1"
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE