social_count 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDg1MDdkOTUxZTlhZjM1ZTZiODM1MmI0Y2EzM2ZkZmU1NGMwZWY5NQ==
4
+ MTQyOGI2ZWRmMDMzZjM1MzE1MjA0YWJiNmViMzQ4NjBkMTMwNGQyZg==
5
5
  data.tar.gz: !binary |-
6
- ZjE4YzY1NGFiMjUwODRhYWFiNmFlOTU1NmMxMDZmNDkyOWNiZDAyMA==
6
+ NjRiYjFmNTM5OWZlYWRmZGI4ZWRhOGJiZTk3ZDExOTU2ZTk2ZTYwOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2Y5MDc1MzVlYzQ2MmEyY2FhZTU0MjQxZjhmNDRlNThkMDBiYTY5ZjJhNGU4
10
- MmE5OGFmNDA0YjQ4OGU3NmZmNjEyNjBkOTg1MDM4NmMxNzJkMGZlNzY3OWFk
11
- MjUyMDJlZDZjOGJhOWU2NTE3ZjYyNGY2OTE1ZGFhMzI1YjJiMzk=
9
+ MTM3YjU5ZTM4MDc2NzY5M2NhNjQzMWQxMTU2ZGQ4MWI2ZTU5OWQzN2IxMTFi
10
+ YzY0NTI1OWIyNGIwZTRlNTFkZDMxZmUwOTRjYjEzOTFkMDU0ZTllYWVmYTQ0
11
+ MmJhNGUwMjJjMWM2ZGIzYzIxZGJmNTc1MDZkMDhjNzllMGIwYTQ=
12
12
  data.tar.gz: !binary |-
13
- NzA3OGJjZDUzMzRmMjk4NjhmZTUxOWFkZWY5NTUwNTMxYWM5M2UyNDQ3NTdm
14
- YTczNjI3N2JhODBmNzBmMjJjYWEwZDVlMzY1NDhiMDNkZjUwNTA2YWRkYTJj
15
- Njc4Y2EzYjY0YzZiYTczYTM0Nzc5Yzc4OWUwMmM0ODVjZGIwMTA=
13
+ NmRlYTIyNzUwYjcwYTNlYmNkY2EyNGRhYTM4NjdkNzU3OTkzM2ViNjcyOWRh
14
+ ZDYzMDA0MGZjNGVmMmRkNmJkMjk4MGRjZGJlOGM4OTJlNjcyNDE0YWYyYzEw
15
+ ZWQ2ODZmOTNlYjQ3NWExNThmNmUyYzIxYjVmNzhmOGEwYjUwNDU=
@@ -9,7 +9,8 @@ module SocialCount
9
9
 
10
10
  def valid?
11
11
  return @valid unless @valid.nil?
12
- @valid = self.class.get_http_response("#{USER_DOMAIN}/#{name}").is_a?(Net::HTTPOK)
12
+ url ="#{USER_DOMAIN}/#{name}"
13
+ @valid = self.class.get_http_response(url).is_a?(Net::HTTPOK)
13
14
  end
14
15
 
15
16
  def follower_count
@@ -22,7 +23,10 @@ module SocialCount
22
23
 
23
24
  private
24
25
  def follower_count_url
25
- @follower_count_url ||= "#{API_DOMAIN}/1.1/users/show.json?screen_name=#{URI.escape(name)}"
26
+ @follower_count_url ||= "#{API_DOMAIN}/1.1/users/show.json?screen_name=#{URI.escape(name_without_at)}"
27
+ end
28
+ def name_without_at
29
+ @name_without_at ||= '@' == name[0] ? name[1..-1] : name
26
30
  end
27
31
 
28
32
  class << self
@@ -1,3 +1,3 @@
1
1
  module SocialCount
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "activesupport"
22
- spec.add_dependency "fb_graph"
22
+ spec.add_dependency "fb_graph", '~> 2.7.11'
23
23
  spec.add_dependency "twitter_oauth", '~> 0.4.94'
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.3"
@@ -55,7 +55,7 @@ describe SocialCount::FacebookUser do
55
55
  user.username.should eq(username)
56
56
  user.first_name.should eq('Mark')
57
57
  user.last_name.should eq('Zuckerberg')
58
- user.link.should eq("http://www.facebook.com/#{username}")
58
+ user.link.should eq("https://www.facebook.com/#{username}")
59
59
  user.gender.should eq('male')
60
60
  end
61
61
  it "should get the user's id" do
@@ -16,9 +16,6 @@ describe SocialCount::TwitterUser do
16
16
  before(:all) do
17
17
  SocialCount.credentials = TestCredentials::INSTANCE
18
18
  end
19
- def username
20
- @username ||= 'tsa'
21
- end
22
19
 
23
20
  describe "name" do
24
21
  it "cannot be an empty string" do
@@ -29,20 +26,6 @@ describe SocialCount::TwitterUser do
29
26
  end
30
27
  end
31
28
 
32
- describe "existent user" do
33
- before(:each) do
34
- @twitter = SocialCount::TwitterUser.new(username)
35
- end
36
-
37
- it "should be valid" do
38
- @twitter.valid?.should be_true
39
- end
40
-
41
- it "should get the follow count" do
42
- @twitter.follower_count.should eq(12872)
43
- end
44
- end
45
-
46
29
  describe "non-existent user" do
47
30
  def non_existent_user
48
31
  SocialCount::TwitterUser.new('no_such_agency')
@@ -61,19 +44,35 @@ describe SocialCount::TwitterUser do
61
44
  end
62
45
  end
63
46
 
64
- describe "expired credentials" do
65
- before(:all) do
66
- @old_credentials = SocialCount.credentials
67
- SocialCount::TwitterUser.reset_credentials
68
- SocialCount.credentials = TestCredentials::EXPIRED_CREDENTIALS
69
- @twitter = SocialCount::TwitterUser.new(username)
70
- end
71
- it "should raise an exception" do
72
- expect{@twitter.follower_count}.to raise_error(SocialCount::TwitterApiError, "Code(s): 32\nSee code explanations at https://dev.twitter.com/docs/error-codes-responses")
47
+ ['@tsa', 'tsa'].each do |username|
48
+ describe "existent user" do
49
+ before(:each) do
50
+ @twitter = SocialCount::TwitterUser.new(username)
51
+ end
52
+
53
+ it "should be valid" do
54
+ @twitter.valid?.should be_true
55
+ end
56
+
57
+ it "should get the follow count" do
58
+ @twitter.follower_count.should eq(12872)
59
+ end
73
60
  end
74
- after(:all) do
75
- SocialCount.credentials = @old_credentials
76
- SocialCount::TwitterUser.reset_credentials
61
+
62
+ describe "expired credentials" do
63
+ before(:all) do
64
+ @old_credentials = SocialCount.credentials
65
+ SocialCount::TwitterUser.reset_credentials
66
+ SocialCount.credentials = TestCredentials::EXPIRED_CREDENTIALS
67
+ @twitter = SocialCount::TwitterUser.new(username)
68
+ end
69
+ it "should raise an exception" do
70
+ expect{@twitter.follower_count}.to raise_error(SocialCount::TwitterApiError, "Code(s): 32\nSee code explanations at https://dev.twitter.com/docs/error-codes-responses")
71
+ end
72
+ after(:all) do
73
+ SocialCount.credentials = @old_credentials
74
+ SocialCount::TwitterUser.reset_credentials
75
+ end
77
76
  end
78
77
  end
79
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_count
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Isaac Betesh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-01 00:00:00.000000000 Z
11
+ date: 2014-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: fb_graph
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 2.7.11
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 2.7.11
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: twitter_oauth
43
43
  requirement: !ruby/object:Gem::Requirement