social_count 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +1 -0
- data/lib/social_count/api_base.rb +23 -0
- data/lib/social_count/facebook_user.rb +47 -0
- data/lib/social_count/twitter_user.rb +37 -0
- data/lib/social_count/version.rb +3 -0
- data/lib/social_count.rb +26 -0
- data/social_count.gemspec +27 -0
- data/spec/social_count/credentials_spec.rb +39 -0
- data/spec/social_count/facebook_user_spec.rb +82 -0
- data/spec/social_count/twitter_user_spec.rb +42 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/support/credentials.rb.example +11 -0
- data/spec/support/test_credentials.rb +12 -0
- metadata +176 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Isaac Betesh
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# SocialCount
|
2
|
+
|
3
|
+
This gem is an incredibly ligh-weight wrapper for finding how many facebook friends and twitter followers someone has.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
gem 'social_count' # In your Gemfile
|
8
|
+
|
9
|
+
$ gem install social_count # Install locally
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
1) Configure your credentials:
|
14
|
+
|
15
|
+
# Instantiate the credentials object
|
16
|
+
SocialCount.credentials = SocialCount::Credentials.new
|
17
|
+
|
18
|
+
# Then set the following values
|
19
|
+
SocialCount.credentials.twitter_consumer_key
|
20
|
+
SocialCount.credentials.twitter_consumer_secret
|
21
|
+
SocialCount.credentials.twitter_oauth_token
|
22
|
+
SocialCount.credentials.twitter_oauth_token_secret
|
23
|
+
SocialCount.credentials.fb_app_id
|
24
|
+
SocialCount.credentials.fb_app_secret
|
25
|
+
|
26
|
+
2) Get the Facebook follower count of any business page:
|
27
|
+
|
28
|
+
SocialCount::FacebookUser.new('zuck').follower_count # Find out how many people are following Mark Zuckerberg
|
29
|
+
SocialCount::FacebookUser.new('zuck').friend_count # nil -- Mark has a business page because he's so famous
|
30
|
+
|
31
|
+
3) Get the Facebook friend count of any regular facebook user:
|
32
|
+
|
33
|
+
SocialCount::FacebookUser.new('jose.valim').friend_count # Find out how many friends Jose Valim has -- I wish he were as famous as Mark
|
34
|
+
SocialCount::FacebookUser.new('jose.valim').follower_count # nil
|
35
|
+
# I think there are more Devise users than Facebook users in China. As least that's on place where Jose is more famous than Mark
|
36
|
+
|
37
|
+
|
38
|
+
4) Get the Twitter follower count of any user:
|
39
|
+
|
40
|
+
SocialMedia::TwitterUser.new('tsa').follower_count # Find out how many people are following the Transportation security Administration
|
41
|
+
|
42
|
+
5) Check if someone is on Facebook:
|
43
|
+
|
44
|
+
orwell = SocialCount::FacebookUser.new('george_orwell')
|
45
|
+
orwell.valid? # False -- Not everyone is cool enough to be one Facebook
|
46
|
+
orwell.friend_count # nil
|
47
|
+
|
48
|
+
6) Check if someone is on Twitter:
|
49
|
+
|
50
|
+
nsa = SocialCount::TwitterUser.new('no_such_agency')
|
51
|
+
nsa.valid? # False -- Nobody can follow the NSA
|
52
|
+
nsa.follower_count # nil
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module SocialCount
|
4
|
+
class ApiBase
|
5
|
+
attr_reader :name
|
6
|
+
def initialize(name)
|
7
|
+
@name = name
|
8
|
+
end
|
9
|
+
class << self
|
10
|
+
def get_http_response(uri)
|
11
|
+
uri = URI.escape(uri)
|
12
|
+
url = URI.parse(uri)
|
13
|
+
http = Net::HTTP.new(url.host, url.port)
|
14
|
+
http.use_ssl = true
|
15
|
+
http.request(Net::HTTP::Get.new(uri))
|
16
|
+
end
|
17
|
+
private
|
18
|
+
def credentials
|
19
|
+
@credentials ||= SocialCount.credentials
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'fb_graph'
|
2
|
+
require 'social_count/api_base'
|
3
|
+
|
4
|
+
module SocialCount
|
5
|
+
class FacebookUser < ApiBase
|
6
|
+
DOMAIN = "https://graph.facebook.com"
|
7
|
+
def valid?
|
8
|
+
return @valid unless @valid.nil?
|
9
|
+
@valid = self.class.get_http_response("#{DOMAIN}/#{name}").is_a?(Net::HTTPOK)
|
10
|
+
end
|
11
|
+
def user
|
12
|
+
return unless valid?
|
13
|
+
@user ||= FbGraph::User.fetch(name, :access_token => URI.escape(self.class.access_token))
|
14
|
+
end
|
15
|
+
def id
|
16
|
+
return unless valid?
|
17
|
+
@id ||= user.identifier.to_i
|
18
|
+
end
|
19
|
+
def friend_count
|
20
|
+
run_query(:friend)
|
21
|
+
end
|
22
|
+
def follower_count
|
23
|
+
count = run_query(:subscriber)
|
24
|
+
count.zero? ? nil : count
|
25
|
+
end
|
26
|
+
private
|
27
|
+
def run_query(column)
|
28
|
+
return unless valid?
|
29
|
+
url = "#{DOMAIN}/fql?q=#{query(column)}"
|
30
|
+
response = self.class.get_http_response(url)
|
31
|
+
JSON.parse(response.body)["data"][0]["#{column}_count"]
|
32
|
+
end
|
33
|
+
def query(column)
|
34
|
+
"SELECT #{column}_count FROM user WHERE uid=#{id}"
|
35
|
+
end
|
36
|
+
|
37
|
+
class << self
|
38
|
+
def access_token
|
39
|
+
@access_token ||= get_http_response(access_url).body.split("access_token=")[1]
|
40
|
+
end
|
41
|
+
private
|
42
|
+
def access_url
|
43
|
+
@access_url ||= "#{DOMAIN}/oauth/access_token?client_id=#{credentials.fb_app_id}&client_secret=#{credentials.fb_app_secret}&grant_type=client_credentials"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'twitter_oauth'
|
2
|
+
require 'social_count/api_base'
|
3
|
+
|
4
|
+
module SocialCount
|
5
|
+
class TwitterUser < ApiBase
|
6
|
+
API_DOMAIN = "https://api.twitter.com"
|
7
|
+
USER_DOMAIN = "https://twitter.com"
|
8
|
+
CONSUMER_OPTIONS = { :site => API_DOMAIN, :scheme => :header }
|
9
|
+
|
10
|
+
def valid?
|
11
|
+
return @valid unless @valid.nil?
|
12
|
+
@valid = self.class.get_http_response("#{USER_DOMAIN}/#{name}").is_a?(Net::HTTPOK)
|
13
|
+
end
|
14
|
+
|
15
|
+
def follower_count
|
16
|
+
response = self.class.access_token.request(:get, follower_count_url)
|
17
|
+
JSON.parse(response.body)["followers_count"]
|
18
|
+
end
|
19
|
+
private
|
20
|
+
def follower_count_url
|
21
|
+
@follower_count_url ||= "#{API_DOMAIN}/1.1/users/show.json?screen_name=#{URI.escape(name)}"
|
22
|
+
end
|
23
|
+
|
24
|
+
class << self
|
25
|
+
def access_token
|
26
|
+
@access_token ||= OAuth::AccessToken.from_hash(consumer, token_hash)
|
27
|
+
end
|
28
|
+
private
|
29
|
+
def consumer
|
30
|
+
@consumer ||= OAuth::Consumer.new(credentials.twitter_consumer_key, credentials.twitter_consumer_secret, CONSUMER_OPTIONS)
|
31
|
+
end
|
32
|
+
def token_hash
|
33
|
+
@token_hash ||= { :oauth_token => credentials.twitter_oauth_token, :oauth_token_secret => credentials.twitter_oauth_token_secret }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/social_count.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "social_count/version"
|
2
|
+
require "social_count/facebook_user"
|
3
|
+
require "social_count/twitter_user"
|
4
|
+
|
5
|
+
module SocialCount
|
6
|
+
REQUIRED_CREDENTIALS = [:twitter_consumer_key, :twitter_consumer_secret, :twitter_oauth_token, :twitter_oauth_token_secret, :fb_app_id, :fb_app_secret]
|
7
|
+
class Error < StandardError; end
|
8
|
+
class Credentials
|
9
|
+
attr_reader *REQUIRED_CREDENTIALS
|
10
|
+
end
|
11
|
+
class << self
|
12
|
+
def credentials
|
13
|
+
raise SocialCount::Error, "You must set SocialCount.credentials before making an API call" if @credentials.nil?
|
14
|
+
@credentials
|
15
|
+
end
|
16
|
+
|
17
|
+
def credentials=(credentials)
|
18
|
+
validate_credentials(credentials)
|
19
|
+
@credentials = credentials
|
20
|
+
end
|
21
|
+
private
|
22
|
+
def validate_credentials(_credentials)
|
23
|
+
REQUIRED_CREDENTIALS.each { |attr| raise SocialCount::Error, "SocialCount.credentials must respond to #{attr}" unless _credentials.respond_to?(attr.to_s) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'social_count/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "social_count"
|
8
|
+
spec.version = SocialCount::VERSION
|
9
|
+
spec.authors = ["Isaac Betesh"]
|
10
|
+
spec.email = ["iybetesh@gmail.com"]
|
11
|
+
spec.description = %q{Want to know how popular you are? This gem helps you look up how many Facebook friends and Twitter followers you have.}
|
12
|
+
spec.summary = `cat README.md`
|
13
|
+
spec.homepage = "https://github.com/betesh/social_count"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "fb_graph"
|
22
|
+
spec.add_dependency "twitter_oauth", '~> 0.4.94'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module SocialCount
|
4
|
+
class << self
|
5
|
+
def reset_credentials
|
6
|
+
@credentials = nil
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def credentials_without(attr)
|
13
|
+
SocialCount::REQUIRED_CREDENTIALS.dup.tap { |a| a.delete(attr) }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe SocialCount::Credentials do
|
17
|
+
SocialCount::REQUIRED_CREDENTIALS.each do |credential|
|
18
|
+
it "should require credentials to have a #{credential}" do
|
19
|
+
credentials = Class.new do attr_reader *credentials_without(credential); end
|
20
|
+
expect{SocialCount.credentials = credentials.new}.to raise_error(SocialCount::Error, "SocialCount.credentials must respond to #{credential}")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "shouldn't change state when an exception is raised" do
|
25
|
+
credentials = Class.new do attr_reader *credentials_without(:twitter_consumer_secret); end
|
26
|
+
SocialCount.reset_credentials
|
27
|
+
expect{SocialCount.credentials = credentials.new}.to raise_error(SocialCount::Error, "SocialCount.credentials must respond to twitter_consumer_secret")
|
28
|
+
expect(SocialCount.instance_variable_get("@credentials")).to be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it "shouldn't allow access untill credentials have been set" do
|
32
|
+
SocialCount.reset_credentials
|
33
|
+
expect{SocialCount.credentials}.to raise_error(SocialCount::Error, "You must set SocialCount.credentials before making an API call")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "can be a SocialCount::Credentials instance" do
|
37
|
+
expect{SocialCount.credentials = SocialCount::Credentials.new}.to_not raise_error
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SocialCount::FacebookUser do
|
4
|
+
before(:all) do
|
5
|
+
SocialCount.credentials = TestCredentials::INSTANCE
|
6
|
+
end
|
7
|
+
|
8
|
+
def username
|
9
|
+
@username ||= 'zuck'
|
10
|
+
end
|
11
|
+
def access_token_did_not_match_specified_format
|
12
|
+
@access_token_did_not_match_specified_format ||= "Facebook Access Token #{@access_token} did not match specified format"
|
13
|
+
end
|
14
|
+
describe "class methods" do
|
15
|
+
it "should receive an access token" do
|
16
|
+
@access_token = SocialCount::FacebookUser.access_token.split("|")
|
17
|
+
@access_token.count.should eq(2), access_token_did_not_match_specified_format
|
18
|
+
@access_token[0].should eq(SocialCount.credentials.fb_app_id), access_token_did_not_match_specified_format
|
19
|
+
@access_token[1].should match(/[_A-Za-z0-9]{27}/), access_token_did_not_match_specified_format
|
20
|
+
end
|
21
|
+
end
|
22
|
+
describe "user that supports following" do
|
23
|
+
before(:all) do
|
24
|
+
@facebook = SocialCount::FacebookUser.new(username)
|
25
|
+
end
|
26
|
+
it "should be valid" do
|
27
|
+
@facebook.valid?.should be_true
|
28
|
+
end
|
29
|
+
it "should get user data" do
|
30
|
+
user = @facebook.user
|
31
|
+
user.username.should eq(username)
|
32
|
+
user.first_name.should eq('Mark')
|
33
|
+
user.last_name.should eq('Zuckerberg')
|
34
|
+
user.link.should eq("http://www.facebook.com/#{username}")
|
35
|
+
user.gender.should eq('male')
|
36
|
+
end
|
37
|
+
it "should get the user's id" do
|
38
|
+
@facebook.id.should eq(4)
|
39
|
+
end
|
40
|
+
it "should get the user's follower count" do
|
41
|
+
count = @facebook.follower_count
|
42
|
+
count.should be_a(Fixnum)
|
43
|
+
count.should eq(19528198)
|
44
|
+
end
|
45
|
+
it "should handle friend_count gracefully" do
|
46
|
+
@facebook.friend_count.should be_nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
describe "user that supports friending" do
|
50
|
+
before(:all) do
|
51
|
+
@facebook = SocialCount::FacebookUser.new('jose.valim')
|
52
|
+
end
|
53
|
+
it "should get the user's friend count" do
|
54
|
+
count = @facebook.friend_count
|
55
|
+
count.should be_a(Fixnum)
|
56
|
+
count.should eq(568)
|
57
|
+
end
|
58
|
+
it "should handle friend_count gracefully" do
|
59
|
+
@facebook.follower_count.should be_nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
describe "non-existent user" do
|
63
|
+
def non_existent_user
|
64
|
+
SocialCount::FacebookUser.new("george_orwell")
|
65
|
+
end
|
66
|
+
it "should fail gracefully" do
|
67
|
+
expect{non_existent_user}.to_not raise_error
|
68
|
+
end
|
69
|
+
it "should be invalid" do
|
70
|
+
non_existent_user.valid?.should be_false
|
71
|
+
end
|
72
|
+
it "should have nil user" do
|
73
|
+
non_existent_user.user.should be_nil
|
74
|
+
end
|
75
|
+
it "should have nil id" do
|
76
|
+
non_existent_user.id.should be_nil
|
77
|
+
end
|
78
|
+
it "should have nil friend_count" do
|
79
|
+
non_existent_user.friend_count.should be_nil
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SocialCount::TwitterUser do
|
4
|
+
before(:all) do
|
5
|
+
SocialCount.credentials = TestCredentials::INSTANCE
|
6
|
+
end
|
7
|
+
def username
|
8
|
+
@username ||= 'tsa'
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "existent user" do
|
12
|
+
before(:each) do
|
13
|
+
@twitter = SocialCount::TwitterUser.new(username)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should be valid" do
|
17
|
+
@twitter.valid?.should be_true
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should get the follow count" do
|
21
|
+
@twitter.follower_count.should eq(12171)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "non-existent user" do
|
26
|
+
def non_existent_user
|
27
|
+
SocialCount::TwitterUser.new('no_such_agency')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should fail gracefully" do
|
31
|
+
expect{non_existent_user}.to_not raise_error
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should be invalid" do
|
35
|
+
non_existent_user.valid?.should be_false
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should have nil follower_count" do
|
39
|
+
non_existent_user.follower_count.should be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
class TestCredentials
|
2
|
+
INSTANCE = TestCredentials.new(
|
3
|
+
# Configure these values before running specs
|
4
|
+
'MY_TWITTER_CONSUMER_KEY',
|
5
|
+
'MY_TWITTER_CONSUMER_SECRET',
|
6
|
+
'MY_TWITTER_OAUTH_TOKEN',
|
7
|
+
'MY_TWITTER_OAUTH_TOKEN_SECRET',
|
8
|
+
'MY_FACEBOOK_APP_ID',
|
9
|
+
'MY_FACEBOOK_APP_SECRET'
|
10
|
+
)
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class TestCredentials
|
2
|
+
attr_reader :twitter_consumer_key, :twitter_consumer_secret, :twitter_oauth_token, :twitter_oauth_token_secret, :fb_app_id, :fb_app_secret
|
3
|
+
def initialize twitter_consumer_key, twitter_consumer_secret, twitter_oauth_token, twitter_oauth_token_secret, fb_app_id, fb_app_secret
|
4
|
+
@twitter_consumer_key, @twitter_consumer_secret, @twitter_oauth_token, @twitter_oauth_token_secret, @fb_app_id, @fb_app_secret = twitter_consumer_key, twitter_consumer_secret, twitter_oauth_token, twitter_oauth_token_secret, fb_app_id, fb_app_secret
|
5
|
+
end
|
6
|
+
credentials_file = File.expand_path("#{__FILE__}/../credentials.rb")
|
7
|
+
unless File.exists?(credentials_file)
|
8
|
+
puts "Please configure your Facebook and Twitter application credentials by copying #{credentials_file}.example to #{credentials_file} and configuring the required values there appropriately."
|
9
|
+
puts "Then comment out the 'exit' line in #{File.expand_path(__FILE__)} before running rspec."
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: social_count
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Isaac Betesh
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-10-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fb_graph
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: twitter_oauth
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.4.94
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.4.94
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.3'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: Want to know how popular you are? This gem helps you look up how many
|
95
|
+
Facebook friends and Twitter followers you have.
|
96
|
+
email:
|
97
|
+
- iybetesh@gmail.com
|
98
|
+
executables: []
|
99
|
+
extensions: []
|
100
|
+
extra_rdoc_files: []
|
101
|
+
files:
|
102
|
+
- .gitignore
|
103
|
+
- Gemfile
|
104
|
+
- LICENSE.txt
|
105
|
+
- README.md
|
106
|
+
- Rakefile
|
107
|
+
- lib/social_count.rb
|
108
|
+
- lib/social_count/api_base.rb
|
109
|
+
- lib/social_count/facebook_user.rb
|
110
|
+
- lib/social_count/twitter_user.rb
|
111
|
+
- lib/social_count/version.rb
|
112
|
+
- social_count.gemspec
|
113
|
+
- spec/social_count/credentials_spec.rb
|
114
|
+
- spec/social_count/facebook_user_spec.rb
|
115
|
+
- spec/social_count/twitter_user_spec.rb
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
- spec/support/credentials.rb.example
|
118
|
+
- spec/support/test_credentials.rb
|
119
|
+
homepage: https://github.com/betesh/social_count
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
segments:
|
133
|
+
- 0
|
134
|
+
hash: 1024359385876280514
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
137
|
+
requirements:
|
138
|
+
- - ! '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
segments:
|
142
|
+
- 0
|
143
|
+
hash: 1024359385876280514
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 1.8.25
|
147
|
+
signing_key:
|
148
|
+
specification_version: 3
|
149
|
+
summary: ! '# SocialCount This gem is an incredibly ligh-weight wrapper for finding
|
150
|
+
how many facebook friends and twitter followers someone has. ## Installation gem
|
151
|
+
''social_count'' # In your Gemfile $ gem install social_count # Install locally ##
|
152
|
+
Usage 1) Configure your credentials: # Instantiate the credentials object SocialCount.credentials
|
153
|
+
= SocialCount::Credentials.new # Then set the following values SocialCount.credentials.twitter_consumer_key
|
154
|
+
SocialCount.credentials.twitter_consumer_secret SocialCount.credentials.twitter_oauth_token
|
155
|
+
SocialCount.credentials.twitter_oauth_token_secret SocialCount.credentials.fb_app_id
|
156
|
+
SocialCount.credentials.fb_app_secret 2) Get the Facebook follower count of any
|
157
|
+
business page: SocialCount::FacebookUser.new(''zuck'').follower_count # Find out
|
158
|
+
how many people are following Mark Zuckerberg SocialCount::FacebookUser.new(''zuck'').friend_count
|
159
|
+
# nil -- Mark has a business page because he''s so famous 3) Get the Facebook friend
|
160
|
+
count of any regular facebook user: SocialCount::FacebookUser.new(''jose.valim'').friend_count
|
161
|
+
# Find out how many friends Jose Valim has -- I wish he were as famous as Mark SocialCount::FacebookUser.new(''jose.valim'').follower_count
|
162
|
+
# nil # I think there are more Devise users than Facebook users in China. As least
|
163
|
+
that''s on place where Jose is more famous than Mark 4) Get the Twitter follower
|
164
|
+
count of any user: SocialMedia::TwitterUser.new(''tsa'').follower_count # Find
|
165
|
+
out how many people are following the Transportation security Administration 5)
|
166
|
+
Check if someone is on Facebook: orwell = SocialCount::FacebookUser.new(''george_orwell'')
|
167
|
+
orwell.valid? # False -- Not everyone is cool enough to be one Facebook orwell.friend_count
|
168
|
+
# nil 6) Check if someone is on Twitter: nsa = SocialCount::TwitterUser.new(''no_such_agency'')
|
169
|
+
nsa.valid? # False -- Nobody can follow the NSA nsa.follower_count # nil'
|
170
|
+
test_files:
|
171
|
+
- spec/social_count/credentials_spec.rb
|
172
|
+
- spec/social_count/facebook_user_spec.rb
|
173
|
+
- spec/social_count/twitter_user_spec.rb
|
174
|
+
- spec/spec_helper.rb
|
175
|
+
- spec/support/credentials.rb.example
|
176
|
+
- spec/support/test_credentials.rb
|