Skip to content

Commit

Permalink
Added google +1 to social signals
Browse files Browse the repository at this point in the history
  • Loading branch information
odynvolk committed Dec 15, 2014
1 parent a07f6b5 commit b857dae
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -131,18 +131,18 @@ Social signals are a somewhat oversimplified way of telling how popular a site o
If you don't specify a social tracker, then all of them are used.

``` ruby
PageRankr.socials('www.google.com', :linked_in, :pinterest, :stumbled_upon, :twitter)
#=> {:linked_in=>1001, :pinterest=>75108, :stumple_upon=>255078, :twitter=>21933764}
PageRankr.socials('www.google.com', :google, :linked_in, :pinterest, :stumbled_upon, :twitter)
#=> {:google=>10000, :linked_in=>1001, :pinterest=>75108, :stumple_upon=>255078, :twitter=>21933764}

# this also gives the same result
PageRankr.socials('www.google.com')
#=> {:linked_in=>1001, :pinterest=>75108, :stumble_upon=>255078, :twitter=>21933764}
#=> {:google=>10000, :linked_in=>1001, :pinterest=>75108, :stumble_upon=>255078, :twitter=>21933764}
```

Valid social trackers are: `:linked_in, :pinterest, :stumble_upon, :twitter`. To get this you can do:
Valid social trackers are: `:google, :linked_in, :pinterest, :stumble_upon, :twitter`. To get this you can do:

``` ruby
PageRankr.social_trackers #=> [:linked_in, :pinterest, :stumble_upon, :twitter]
PageRankr.social_trackers #=> [:google, :linked_in, :pinterest, :stumble_upon, :twitter]
```


Expand Down
1 change: 1 addition & 0 deletions lib/page_rankr/socials.rb
@@ -1,5 +1,6 @@
require File.expand_path("../trackers", __FILE__)
require File.expand_path("../socials/facebook", __FILE__)
require File.expand_path("../socials/google", __FILE__)
require File.expand_path("../socials/linkedin", __FILE__)
require File.expand_path("../socials/pinterest", __FILE__)
require File.expand_path("../socials/stumble_upon", __FILE__)
Expand Down
30 changes: 30 additions & 0 deletions lib/page_rankr/socials/google.rb
@@ -0,0 +1,30 @@
require File.expand_path('../../social', __FILE__)

module PageRankr
class Socials
class Google
include Social

def url
# Yandex supplies Google +1 counts in a convenient matter
'http://share.yandex.ru/gpp.xml'
end

def params
{:url => tracked_url}
end

def regex
/(\d+)/
end

def supported_components
[:subdomain, :path, :scheme]
end

def name
:socials_google
end
end
end
end
39 changes: 39 additions & 0 deletions spec/fixtures/vcr_cassettes/failure_socials.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions spec/fixtures/vcr_cassettes/success_socials.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions spec/socials_spec.rb
Expand Up @@ -5,6 +5,7 @@
subject{ PageRankr.social_trackers }

it{ should include(:facebook) }
it{ should include(:google) }
it{ should include(:linked_in) }
it{ should include(:pinterest) }
it{ should include(:stumble_upon) }
Expand All @@ -20,12 +21,14 @@
end

it{ should have_key(:facebook) }
it{ should have_key(:google) }
it{ should have_key(:linked_in) }
it{ should have_key(:pinterest) }
it{ should have_key(:stumble_upon) }
it{ should have_key(:twitter) }

it{ subject[:facebook].should > 1000000 }
it{ subject[:google].should > 5000 }
it{ subject[:linked_in].should > 500 }
it{ subject[:pinterest].should > 70000 }
it{ subject[:stumble_upon].should > 20000 }
Expand All @@ -40,12 +43,14 @@
end

it{ should have_key(:facebook) }
it{ should have_key(:google) }
it{ should have_key(:linked_in) }
it{ should have_key(:pinterest) }
it{ should have_key(:stumble_upon) }
it{ should have_key(:twitter) }

it{ subject[:facebook].should be_nil }
it{ subject[:google].should == 0 }
it{ subject[:linked_in].should == 0 }
it{ subject[:pinterest].should == 0 }
it{ subject[:stumble_upon].should be_nil }
Expand Down

0 comments on commit b857dae

Please sign in to comment.