Skip to content

Tolia/sharing_counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sharing counter

Installation

First start by adding this gem to your Gemfile:

gem 'sharing_counter'

And then execute

$ bundle

Configuring

For a Rails app, your config/initializers/sharing_counter.rb file should look like this:

SharingCounter.configure do |config|
 config.vk = { app_id: ENV['VK_API_KEY'] }
end

facebook[:measurement] can assume any value from 'total_count', 'like_count', 'comment_count' and 'total_count'. The default is 'total_count'

Usage

> counter = SharingCounter.get_count "https://theoryandpractice.ru"
=> {:url=>"https://theoryandpractice.ru", :data=>2014-04-29 15:29:51 +0400, :facebook=>1984, :twitter=>825, :vk=>0, :ok=>0, :delay=>0.570361}

> counter = SharingCounter.get_count "https://theoryandpractice.ru", [:facebook]
=> {:url=>"https://theoryandpractice.ru", :data=>2014-04-29 15:31:22 +0400, :facebook=>1984, :delay=>0.443431}

> counter = SharingCounter.get_count "https://theoryandpractice.ru", [:twitter]
=> {:url=>"https://theoryandpractice.ru", :data=>2014-04-29 15:37:49 +0400, :twitter=>825, :delay=>0.435011}

> counter = SharingCounter.get_count "https://theoryandpractice.ru", [:vk]
=> {:url=>"https://theoryandpractice.ru", :data=>2014-04-29 15:31:02 +0400, :vk=>0, :delay=>0.061093}

> counter = SharingCounter.get_count "https://theoryandpractice.ru", [:ok]
=> {:url=>"https://theoryandpractice.ru", :data=>2014-04-29 15:31:02 +0400, :ok=>0, :delay=>0.061093}