popularity 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +10 -0
  3. data/.travis.yml +10 -3
  4. data/Gemfile +4 -20
  5. data/LICENSE.txt +18 -17
  6. data/README.md +10 -9
  7. data/Rakefile +1 -29
  8. data/bin/console +14 -0
  9. data/bin/setup +8 -0
  10. data/lib/popularity/version.rb +3 -0
  11. data/popularity.gemspec +40 -116
  12. metadata +59 -58
  13. data/Gemfile.lock +0 -126
  14. data/lib/popularity/networks/twitter.rb +0 -15
  15. data/spec/cassettes/facebook.yml +0 -50
  16. data/spec/cassettes/github-valid.yml +0 -105
  17. data/spec/cassettes/google_plus.yml +0 -89
  18. data/spec/cassettes/medium-valid.yml +0 -110
  19. data/spec/cassettes/pinterest.yml +0 -44
  20. data/spec/cassettes/reddit-comment.yml +0 -207
  21. data/spec/cassettes/reddit-post.yml +0 -174
  22. data/spec/cassettes/reddit.yml +0 -183
  23. data/spec/cassettes/result-container-test.yml +0 -97
  24. data/spec/cassettes/rubygems-valid.yml +0 -66
  25. data/spec/cassettes/search-multi.yml +0 -1211
  26. data/spec/cassettes/search.yml +0 -598
  27. data/spec/cassettes/soundcloud-valid.yml +0 -682
  28. data/spec/cassettes/twitter.yml +0 -64
  29. data/spec/cassettes/unknown-reddit-post.yml +0 -68
  30. data/spec/facebook_spec.rb +0 -23
  31. data/spec/github_spec.rb +0 -39
  32. data/spec/google_plus_spec.rb +0 -27
  33. data/spec/medium_spec.rb +0 -47
  34. data/spec/pinterest_spec.rb +0 -27
  35. data/spec/reddit_comment_spec.rb +0 -60
  36. data/spec/reddit_post_spec.rb +0 -64
  37. data/spec/reddit_spec.rb +0 -118
  38. data/spec/results_container_spec.rb +0 -61
  39. data/spec/rubygems_spec.rb +0 -50
  40. data/spec/search_spec.rb +0 -79
  41. data/spec/soundcloud_spec.rb +0 -66
  42. data/spec/spec_helper.rb +0 -98
  43. data/spec/twitter_spec.rb +0 -19
@@ -1,64 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://cdn.api.twitter.com/1/urls/count.json?url=http://google.com
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - "*/*; q=0.5, application/xml"
12
- Accept-Encoding:
13
- - gzip
14
- User-Agent:
15
- - unirest-ruby/1.1
16
- response:
17
- status:
18
- code: 200
19
- message: OK
20
- headers:
21
- Date:
22
- - Thu, 09 Apr 2015 17:30:25 GMT
23
- Server:
24
- - tsa_a
25
- Cache-Control:
26
- - must-revalidate, max-age=900
27
- Content-Encoding:
28
- - gzip
29
- Content-Type:
30
- - application/json;charset=utf-8
31
- Expires:
32
- - Thu, 09 Apr 2015 17:44:35 GMT
33
- Last-Modified:
34
- - Thu, 09 Apr 2015 17:29:35 GMT
35
- Strict-Transport-Security:
36
- - max-age=631138519
37
- X-Connection-Hash:
38
- - d92a3da2734891d68f5a79f0d1800a3b
39
- X-Response-Time:
40
- - '11'
41
- Content-Length:
42
- - '71'
43
- Accept-Ranges:
44
- - bytes
45
- Via:
46
- - 1.1 varnish
47
- Age:
48
- - '51'
49
- X-Served-By:
50
- - cache-tw-dfw1-cr1-3-TWDFW1
51
- X-Cache:
52
- - HIT
53
- X-Cache-Hits:
54
- - '1'
55
- Vary:
56
- - Accept-Encoding
57
- body:
58
- encoding: ASCII-8BIT
59
- string: !binary |-
60
- H4sIAAAAAAAAAKpWSs4vzStRsjI0NDU11FEqLcpRslLKKCkpsIrRj9FPz89P
61
- z0nVS87PjdFXqgUAAAD//wMABIYJ+C0AAAA=
62
- http_version:
63
- recorded_at: Thu, 09 Apr 2015 17:30:25 GMT
64
- recorded_with: VCR 2.9.3
@@ -1,68 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://www.reddit.com/r/search/search.json?q=url:http://jeffkeen.me/totallyunknown
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - "*/*; q=0.5, application/xml"
12
- Accept-Encoding:
13
- - gzip
14
- User-Agent:
15
- - unirest-ruby/1.1
16
- response:
17
- status:
18
- code: 200
19
- message: OK
20
- headers:
21
- Date:
22
- - Thu, 09 Apr 2015 21:56:46 GMT
23
- Content-Type:
24
- - application/json; charset=UTF-8
25
- Transfer-Encoding:
26
- - chunked
27
- Connection:
28
- - keep-alive
29
- Set-Cookie:
30
- - __cfduid=d50f20e6118c05422f5d59fe19256efb91428616606; expires=Fri, 08-Apr-16
31
- 21:56:46 GMT; path=/; domain=.reddit.com; HttpOnly
32
- X-Ua-Compatible:
33
- - IE=edge
34
- X-Frame-Options:
35
- - SAMEORIGIN
36
- X-Content-Type-Options:
37
- - nosniff
38
- X-Xss-Protection:
39
- - 1; mode=block
40
- Access-Control-Allow-Origin:
41
- - "*"
42
- Access-Control-Expose-Headers:
43
- - X-Reddit-Tracking, X-Moose
44
- X-Reddit-Tracking:
45
- - https://pixel.redditmedia.com/pixel/of_destiny.png?v=NPjKlQn6h%2F0gWlAsQzt7u95XdyAaw8SNbh8xp5HZg3KKYA9i7jpvVCL6GuG0jB8s%2F51Z0Ey4yao%3D
46
- X-Moose:
47
- - majestic
48
- Cache-Control:
49
- - no-cache
50
- Cf-Cache-Status:
51
- - MISS
52
- Vary:
53
- - Accept-Encoding
54
- Server:
55
- - cloudflare-nginx
56
- Cf-Ray:
57
- - 1d4976c03d7903ee-DFW
58
- Content-Encoding:
59
- - gzip
60
- body:
61
- encoding: ASCII-8BIT
62
- string: !binary |-
63
- H4sIAAAAAAAAAy3JwQ2AIAxG4VWa/8wEzOAGxgPaIo1YEsATYXdj4vF9b+BS
64
- Y3jCoq2rnXAEDj3A08BdOIWWvv35kTRzFYOndXOEELtUeLInZ0fYJZYqf8/5
65
- AmghW1ZbAAAA
66
- http_version:
67
- recorded_at: Thu, 09 Apr 2015 21:56:47 GMT
68
- recorded_with: VCR 2.9.3
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Popularity::Facebook do
4
- context "valid url" do
5
- use_vcr_cassette "facebook"
6
-
7
- subject {
8
- Popularity::Facebook.new('http://google.com')
9
- }
10
-
11
- it "should return correct comment count" do
12
- expect(10121).to equal subject.comments
13
- end
14
-
15
- it "should return correct share count" do
16
- expect(12085903).to equal subject.shares
17
- end
18
-
19
- it "should calculate the correct total" do
20
- expect(subject.total).to equal (subject.shares + subject.comments)
21
- end
22
- end
23
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Popularity::Github do
4
- context "non-github url" do
5
- use_vcr_cassette "github-invalid"
6
-
7
- subject {
8
- Popularity::Github.new('http://google.com')
9
- }
10
-
11
- it "should be invalid" do
12
- expect(subject.valid?).to eq(false)
13
- end
14
-
15
- it "should have no response" do
16
- expect(subject.response).to eq(false)
17
- end
18
- end
19
-
20
- context "github url" do
21
- use_vcr_cassette "github-valid"
22
-
23
- subject {
24
- Popularity::Github.new('http://github.com/jkeen/tracking_number')
25
- }
26
-
27
- it "should be valid" do
28
- expect(subject.valid?).to eq(true)
29
- end
30
-
31
- it "should have response" do
32
- expect(subject.response).to_not eq(false)
33
- end
34
-
35
- it "should have correct number of stars" do
36
- expect(18).to eq(subject.stars)
37
- end
38
- end
39
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Popularity::GooglePlus do
4
- context "valid url" do
5
- use_vcr_cassette "google_plus"
6
-
7
- subject {
8
- Popularity::GooglePlus.new('http://google.com')
9
- }
10
-
11
- it "should return correct plus-one count" do
12
- expect(11180649).to eq subject.plus_ones
13
- end
14
-
15
- it "should calculate the correct total" do
16
- expect(subject.plus_ones).to equal subject.total
17
- end
18
-
19
- context "json" do
20
- let(:json) { subject.as_json }
21
-
22
- it "should have required attributes in json" do
23
- expect(subject.plus_ones).to eq(json["plus_ones"])
24
- end
25
- end
26
- end
27
- end
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Popularity::Medium do
4
- context "non-medium url" do
5
- use_vcr_cassette "medium-invalid"
6
-
7
- subject {
8
- Popularity::Medium.new('http://google.com')
9
- }
10
-
11
- it "should be invalid" do
12
- expect(subject.valid?).to eq(false)
13
- end
14
-
15
- it "should have no resposne" do
16
- expect(subject.response).to eq(false)
17
- end
18
- end
19
-
20
- context "medium url" do
21
- use_vcr_cassette "medium-valid"
22
-
23
- subject {
24
- Popularity::Medium.new('https://medium.com/@jeffkeen/call-me-sometime-64ed463c02f0')
25
- }
26
-
27
- it "should be valid" do
28
- expect(subject.valid?).to eq(true)
29
- end
30
-
31
- it "should have response" do
32
- expect(subject.response).to_not eq(false)
33
- end
34
-
35
- it "should have correct number of recommends" do
36
- expect(13).to eq(subject.recommends)
37
- end
38
-
39
- context "json" do
40
- let(:json) { subject.as_json }
41
-
42
- it "should have required attributes in json" do
43
- expect(subject.recommends).to eq(json["recommends"])
44
- end
45
- end
46
- end
47
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Popularity::Pinterest do
4
- context "valid url" do
5
- use_vcr_cassette "pinterest"
6
-
7
- subject {
8
- Popularity::Pinterest.new('http://google.com')
9
- }
10
-
11
- it "should return correct pin count" do
12
- expect(11278).to eq subject.pins
13
- end
14
-
15
- it "should calculate the correct total" do
16
- expect(subject.total).to eq subject.pins
17
- end
18
-
19
- context "json" do
20
- let(:json) { subject.as_json }
21
-
22
- it "should have required attributes in json" do
23
- expect(subject.pins).to eq(json["pins"])
24
- end
25
- end
26
- end
27
- end
@@ -1,60 +0,0 @@
1
-
2
- require 'spec_helper'
3
-
4
- describe Popularity::RedditComment do
5
- context "non-reddit url" do
6
- use_vcr_cassette "reddit-comment"
7
-
8
- subject {
9
- Popularity::RedditComment.new('http://google.com')
10
- }
11
-
12
- it "should be invalid" do
13
- expect(subject.valid?).to eq(false)
14
- end
15
-
16
- it "should have no resposne" do
17
- expect(subject.response).to eq(false)
18
- end
19
- end
20
-
21
- context "non-comment url" do
22
- use_vcr_cassette "reddit-comment"
23
-
24
- subject {
25
- Popularity::RedditComment.new('http://www.reddit.com/r/Fitness/comments/30wleu/me_and_my_wife_joined_the_gym_9_months_ago_we')
26
- }
27
-
28
- it "should be invalid" do
29
- expect(subject.valid?).to eq(false)
30
- end
31
-
32
- it "should have no resposne" do
33
- expect(subject.response).to eq(false)
34
- end
35
- end
36
-
37
- context "reddit url" do
38
- use_vcr_cassette "reddit-comment"
39
-
40
- subject {
41
- Popularity::RedditComment.new('http://www.reddit.com/r/Fitness/comments/30wleu/me_and_my_wife_joined_the_gym_9_months_ago_we/cpwrwat')
42
- }
43
-
44
- it "should be valid" do
45
- expect(subject.valid?).to eq(true)
46
- end
47
-
48
- it "should have response" do
49
- expect(subject.response).to_not eq(false)
50
- end
51
-
52
- it "should have correct score" do
53
- expect(500).to eq(subject.score)
54
- end
55
-
56
- it "should have correct total" do
57
- expect(subject.total).to eq(subject.score)
58
- end
59
- end
60
- end
@@ -1,64 +0,0 @@
1
-
2
- require 'spec_helper'
3
-
4
- describe Popularity::RedditPost do
5
- context "non-reddit url" do
6
- use_vcr_cassette "reddit-post"
7
-
8
- subject {
9
- Popularity::RedditPost.new('http://google.com')
10
- }
11
-
12
- it "should be invalid" do
13
- expect(subject.valid?).to eq(false)
14
- end
15
-
16
- it "should have no resposne" do
17
- expect(subject.response).to eq(false)
18
- end
19
- end
20
-
21
- context "non-post url" do
22
- use_vcr_cassette "reddit-post"
23
-
24
- subject {
25
- Popularity::RedditPost.new('http://www.reddit.com/r/Fitness/comments/30wleu/me_and_my_wife_joined_the_gym_9_months_ago_we/cpwrwat')
26
- }
27
-
28
- it "should be invalid" do
29
- expect(subject.valid?).to eq(false)
30
- end
31
-
32
- it "should have no resposne" do
33
- expect(subject.response).to eq(false)
34
- end
35
- end
36
-
37
- context "reddit url" do
38
- use_vcr_cassette "reddit-post"
39
-
40
- subject {
41
- Popularity::RedditPost.new('http://www.reddit.com/r/funny/comments/2naq2t/every_time_my_brother_leaves_me_a_voicemail_he/')
42
- }
43
-
44
- it "should be valid" do
45
- expect(subject.valid?).to eq(true)
46
- end
47
-
48
- it "should have response" do
49
- expect(subject.response).to_not eq(false)
50
- end
51
-
52
- it "should have correct number of comments" do
53
- expect(36).to eq(subject.comments)
54
- end
55
-
56
- it "should have correct score" do
57
- expect(629).to eq(subject.score)
58
- end
59
-
60
- it "should have correct total" do
61
- expect(subject.total).to eq(subject.score + subject.comments)
62
- end
63
- end
64
- end
@@ -1,118 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Popularity::RedditShare do
4
- context "valid url" do
5
- use_vcr_cassette "reddit"
6
-
7
- subject {
8
- Popularity::RedditShare.new('http://google.com')
9
- }
10
-
11
- it "should have multiple results" do
12
- expect(25).to eq(subject.results.size)
13
- end
14
-
15
- it "should roll up score counts" do
16
- totals = subject.results.collect { |r| r.score }
17
- expect(totals.reduce(:+)).to eq subject.score
18
- end
19
-
20
- it "should roll up comment counts" do
21
- totals = subject.results.collect { |r| r.comments }
22
- expect(totals.reduce(:+)).to eq subject.comments
23
- end
24
-
25
- it "should allow access to underlying results" do
26
- expect(4687).to eq(subject.results.first.score)
27
- end
28
-
29
- context "json" do
30
- let(:json) { subject.as_json }
31
-
32
- it "should include post count in json" do
33
- expect(json["posts"]).to eq(25)
34
- end
35
-
36
- it "should have comments in json" do
37
- expect(json["comments"]).to_not be_nil
38
- end
39
-
40
- it "should have score in json" do
41
- expect(json["score"]).to_not be_nil
42
- end
43
-
44
- it "should have _results in json" do
45
- expect(json["_results"]).to_not be_nil
46
- end
47
-
48
- context "results" do
49
- let(:json_results) { subject.as_json["_results"] }
50
-
51
- it "should equal number of results" do
52
- expect(subject.results.size).to eq(json_results.size)
53
- end
54
-
55
- it "should contain the result urls" do
56
- subject.results.each_with_index do |result, index|
57
- json_result = json_results[index]
58
-
59
- expect(json_result.keys.first).to eq(result.url)
60
- end
61
- end
62
-
63
- it "should contain the correct values" do
64
- subject.results.each_with_index do |result, index|
65
- json_result = json_results[index]
66
- expect(json_result.values.first["score"]).to eq(result.score)
67
- expect(json_result.values.first["comments"]).to eq(result.comments)
68
- expect(json_result.values.first["total"]).to eq(result.total)
69
- end
70
- end
71
- end
72
- end
73
-
74
- context "unknown url" do
75
- use_vcr_cassette "unknown-reddit-post"
76
- subject {
77
- Popularity::RedditShare.new('http://jeffkeen.me/totallyunknown')
78
- }
79
-
80
- it "should be valid" do
81
- expect(subject.valid?).to eq(true)
82
- end
83
-
84
- it "should have response" do
85
- expect(subject.response).to_not eq(false)
86
- end
87
-
88
- it "should have correct number of comments" do
89
- expect(0).to eq(subject.comments)
90
- end
91
-
92
- it "should have correct score" do
93
- expect(0).to eq(subject.score)
94
- end
95
-
96
- it "should have correct total" do
97
- expect(subject.total).to eq(subject.score + subject.comments + subject.posts)
98
- end
99
-
100
- context "json" do
101
- let(:json) { subject.as_json }
102
-
103
- it "should include post count in json" do
104
- expect(0).to eq(json["posts"])
105
- end
106
-
107
- it "should comments in json" do
108
- expect(0).to eq(json["comments"])
109
- end
110
-
111
- it "should score in json" do
112
- expect(0).to eq(json["score"])
113
- end
114
-
115
- end
116
- end
117
- end
118
- end