seo_params 0.0.3 → 0.0.5

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/README.md CHANGED
@@ -32,32 +32,33 @@ Or install it yourself as:
32
32
  ### Fetch main SEO params
33
33
 
34
34
  ``` ruby
35
- SeoParams.all("gihub.com")
35
+ SeoParams.all("github.com")
36
36
  # => {"pr"=>7, "gp"=>42200000, "tic"=>3700, "yap"=>627199, "tweets"=>532, "likes"=>"5,2 т.", "ar"=>276, "dmoz"=>"yes"}
37
37
  ```
38
38
  Short description:
39
39
  `pr` - Google PageRank,
40
40
  `gp` - pages in Google index,
41
41
  `tic` - Yandex tIC,
42
- `yap` - pages in Yandex index.
43
- `tweets` - Twitter tweets
44
- `likes` - Facebook likes, on Russian in my case
45
- `ar` - Alexa rank
46
- `dmoz` - presence in the DMOZ directory
42
+ `yap` - pages in Yandex index,
43
+ `tweets` - Twitter tweets,
44
+ `likes` - Facebook likes, on Russian in my case,
45
+ `ar` - Alexa rank,
46
+ `dmoz` - presence in the DMOZ directory,
47
+ `plus_ones` - number of Google +1s.
47
48
 
48
49
  ### Fetch specific SEO parameter
49
50
 
50
51
  To fetch only Google PageRank:
51
52
 
52
53
  ``` ruby
53
- SeoParams.pr("gihub.com")
54
+ SeoParams.pr("github.com")
54
55
  # => 7
55
56
  ```
56
57
 
57
58
  To fetch only pages in Google index:
58
59
 
59
60
  ``` ruby
60
- SeoParams.gp("gihub.com")
61
+ SeoParams.gp("github.com")
61
62
  # => 44000000
62
63
  ```
63
64
  This request gives sometimes very strange results
@@ -65,42 +66,51 @@ This request gives sometimes very strange results
65
66
  To fetch only Yandex tIC:
66
67
 
67
68
  ``` ruby
68
- SeoParams.tic("gihub.com")
69
+ SeoParams.tic("github.com")
69
70
  # => 3700
70
71
  ```
71
72
 
72
73
  To fetch only pages in Google index:
73
74
 
74
75
  ``` ruby
75
- SeoParams.yap("gihub.com")
76
+ SeoParams.yap("github.com")
76
77
  # => 627119
77
78
  ```
78
79
 
79
80
  To fetch only tweets
80
81
 
81
82
  ``` ruby
82
- SeoParams.tweets("gihub.com")
83
+ SeoParams.tweets("github.com")
83
84
  # => 532
84
85
  ```
85
86
 
86
87
  To fetch only likes
87
88
 
88
89
  ``` ruby
89
- SeoParams.likes("gihub.com")
90
+ SeoParams.likes("github.com")
90
91
  # => "5,2 т."
91
92
  ```
92
93
 
93
94
  DMOZ:
94
95
 
95
96
  ``` ruby
96
- SeoParams.dmoz("gihub.com")
97
+ SeoParams.dmoz("github.com")
97
98
  # => "yes"
98
99
  ```
99
100
 
101
+ Google +1:
102
+
103
+ To fetch count of +1s
104
+
105
+ ``` ruby
106
+ SeoParams.plus_ones("github.com")
107
+ # => 3000
108
+ ```
109
+
100
110
  ### Check Netcraft parametrs
101
111
 
102
112
  ``` ruby
103
- SeoParams.netcraft("gihub.com")
113
+ SeoParams.netcraft("github.com")
104
114
  # => {"ip"=>"207.97.227.239", "siterank"=>9359, "country"=>"US", "nameserver"=>"ns1.p16.dynect.net", "firstseen"=>"August 2011", "dnsadmin"=>"hostmaster@github.com", "domainregistrator"=>"godaddy.com", "reversedns"=>"github.com", "organisation"=>"GitHub, Inc.", "nsorganisation"=>"Dynamic Network Services, Inc., 150 Dow St, Manchester, 03101, United States"}
105
115
  ```
106
116
 
@@ -12,7 +12,12 @@ module SeoParams
12
12
  end
13
13
 
14
14
  def rank
15
- rank = @response.css("popularity").attr("text").content().to_i
15
+ begin
16
+ rank = @response.css("popularity").attr("text").content().to_i
17
+ rescue
18
+ rank = nil
19
+ end
20
+ rank
16
21
  end
17
22
 
18
23
  def dmoz
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'nokogiri'
3
+ require 'open-uri'
4
+ require "cgi"
5
+
6
+ module SeoParams
7
+
8
+ class GooglePlus
9
+
10
+ def initialize(url)
11
+ @url = url.match(/^(https?:\/\/)/) ? url : 'http://' + url
12
+ end
13
+
14
+ def plus_ones
15
+ api_url = "https://plusone.google.com/_/+1/fastbutton?url=#{CGI.escape(@url)}"
16
+ response = Nokogiri::HTML(open(api_url))
17
+ total_plus_ones = response.css("#aggregateCount")
18
+ convert_count(total_plus_ones.text())
19
+ end
20
+
21
+ private
22
+
23
+ def convert_count(count_string)
24
+ multiplier = case count_string[/(\D\z)/]
25
+ when 'M'; 1000000
26
+ when 'k'; 1000
27
+ else; 1
28
+ end
29
+ (count_string.to_f * multiplier).to_i
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -1,3 +1,3 @@
1
1
  module SeoParams
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/seo_params.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  require File.expand_path('../seo_params/google', __FILE__)
4
+ require File.expand_path('../seo_params/google_plus', __FILE__)
4
5
  require File.expand_path('../seo_params/yandex', __FILE__)
5
6
  require File.expand_path('../seo_params/alexa', __FILE__)
6
7
  require File.expand_path('../seo_params/facebook', __FILE__)
@@ -21,6 +22,7 @@ module SeoParams
21
22
  h["likes"] = likes(url)
22
23
  h["ar"] = ar(url)
23
24
  h["dmoz"] = dmoz(url)
25
+ h["plus_ones"] = plus_ones(url)
24
26
  h
25
27
  end
26
28
 
@@ -79,6 +81,10 @@ module SeoParams
79
81
  Netcraft.new(url).all
80
82
  end
81
83
 
84
+ def plus_ones(url)
85
+ GooglePlus.new(url).plus_ones
86
+ end
87
+
82
88
  end
83
89
 
84
90
  end
metadata CHANGED
@@ -1,25 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seo_params
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
4
  prerelease:
5
+ version: 0.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Alexander Podkidyshev aka none
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-19 00:00:00.000000000 Z
12
+ date: 2012-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: nokogiri
15
+ type: :runtime
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: 1.5.0
22
- type: :runtime
23
22
  prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
24
  none: false
@@ -27,15 +26,15 @@ dependencies:
27
26
  - - ! '>='
28
27
  - !ruby/object:Gem::Version
29
28
  version: 1.5.0
29
+ name: nokogiri
30
30
  - !ruby/object:Gem::Dependency
31
- name: PageRankr
31
+ type: :runtime
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: 3.2.1
38
- type: :runtime
39
38
  prerelease: false
40
39
  version_requirements: !ruby/object:Gem::Requirement
41
40
  none: false
@@ -43,15 +42,15 @@ dependencies:
43
42
  - - ! '>='
44
43
  - !ruby/object:Gem::Version
45
44
  version: 3.2.1
45
+ name: PageRankr
46
46
  - !ruby/object:Gem::Dependency
47
- name: em-http-request
47
+ type: :runtime
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
51
  - - ! '>='
52
52
  - !ruby/object:Gem::Version
53
53
  version: 1.0.3
54
- type: :runtime
55
54
  prerelease: false
56
55
  version_requirements: !ruby/object:Gem::Requirement
57
56
  none: false
@@ -59,15 +58,15 @@ dependencies:
59
58
  - - ! '>='
60
59
  - !ruby/object:Gem::Version
61
60
  version: 1.0.3
61
+ name: em-http-request
62
62
  - !ruby/object:Gem::Dependency
63
- name: em-synchrony
63
+ type: :runtime
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
67
  - - ! '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: 1.0.2
70
- type: :runtime
71
70
  prerelease: false
72
71
  version_requirements: !ruby/object:Gem::Requirement
73
72
  none: false
@@ -75,6 +74,7 @@ dependencies:
75
74
  - - ! '>='
76
75
  - !ruby/object:Gem::Version
77
76
  version: 1.0.2
77
+ name: em-synchrony
78
78
  description: ! '"Easy way to retrieve main SEO parameters."'
79
79
  email:
80
80
  - alexander.podkidyshev@gmail.com
@@ -91,6 +91,7 @@ files:
91
91
  - lib/seo_params/alexa.rb
92
92
  - lib/seo_params/facebook.rb
93
93
  - lib/seo_params/google.rb
94
+ - lib/seo_params/google_plus.rb
94
95
  - lib/seo_params/netcraft.rb
95
96
  - lib/seo_params/twitter.rb
96
97
  - lib/seo_params/version.rb