share_counts 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ # TODO: update this page
2
+
3
+ Original blog post (January 31, 2011)
4
+ http://vitobotta.com/share-counts-gem-social-networks/
5
+
1
6
  = Share Counts
2
7
 
3
8
  This gem makes it super easy to check how many times a page/URL has been shared on social networks and aggregators.
@@ -51,7 +51,7 @@ module ShareCounts
51
51
  attempts = 1
52
52
 
53
53
  begin
54
- timeout(2) do
54
+ timeout(3) do
55
55
  url = args.shift
56
56
  params = args.inject({}) { |r, c| r.merge! c }
57
57
  response = RestClient.get url, { :params => params }
@@ -97,7 +97,7 @@ module ShareCounts
97
97
  # so to extract the share count.
98
98
  #
99
99
  #
100
- def extract_count *args
100
+ def extract_info *args
101
101
  json = args.shift
102
102
  result = args.first.to_a.flatten.last.split("/").inject( json.is_a?(Array) ? json.first : json ) {
103
103
  |r, c| r[c].is_a?(Array) ? r[c].first : r[c]
@@ -0,0 +1,19 @@
1
+ module ShareCounts
2
+ module Reddit
3
+ extend Common
4
+ extend Caching
5
+
6
+ def self.info_for url
7
+ try("reddit-details", url) {
8
+ data = extract_info from_json( "http://www.reddit.com/api/info.json", :url => url ), :selector => "data/children/data"
9
+
10
+ data.reject{ |key, value|
11
+ %w( media_embed levenshtein selftext_html selftext likes saved clicked media over_18
12
+ hidden thumbnail subreddit_id is_self created subreddit_id created_utc num_comments
13
+ domain subreddit id author downs name url title ups
14
+ ).include? key
15
+ }
16
+ }
17
+ end
18
+ end
19
+ end
data/lib/share_counts.rb CHANGED
@@ -1,13 +1,15 @@
1
- %w(rest_client json nokogiri redis timeout).each{|x| require x}
2
-
3
- require File.expand_path(File.dirname(__FILE__) + "/share_counts/common")
4
- require File.expand_path(File.dirname(__FILE__) + "/share_counts/caching")
1
+ %w( rest_client json nokogiri redis timeout ).each{ |lib| require lib }
2
+ %w( caching common reddit ).each{ |file| load File.expand_path( File.join( File.dirname( __FILE__ ), "share_counts", "#{file}.rb" ) ) } # TODO: replace load with require
5
3
 
6
4
  module ShareCounts
7
5
 
8
6
  extend Common
9
7
  extend Caching
10
8
 
9
+ def self.extract_count *args
10
+ extract_info *args
11
+ end
12
+
11
13
  def self.supported_networks
12
14
  %w(reddit digg twitter facebook fblike linkedin googlebuzz stumbleupon)
13
15
  end
data/share_counts.gemspec CHANGED
@@ -4,7 +4,7 @@ $:.push File.expand_path("../lib/share_counts", __FILE__)
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "share_counts"
7
- s.version = "0.0.4"
7
+ s.version = "0.0.5"
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Vito Botta"]
10
10
  s.email = ["vito@botta.name"]
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: share_counts
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 21
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 4
9
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
10
11
  platform: ruby
11
12
  authors:
12
13
  - Vito Botta
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-01-31 00:00:00 +00:00
18
+ date: 2011-02-06 00:00:00 +00:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,6 +26,7 @@ dependencies:
25
26
  requirements:
26
27
  - - ">="
27
28
  - !ruby/object:Gem::Version
29
+ hash: 3
28
30
  segments:
29
31
  - 0
30
32
  version: "0"
@@ -38,6 +40,7 @@ dependencies:
38
40
  requirements:
39
41
  - - ">="
40
42
  - !ruby/object:Gem::Version
43
+ hash: 3
41
44
  segments:
42
45
  - 0
43
46
  version: "0"
@@ -51,6 +54,7 @@ dependencies:
51
54
  requirements:
52
55
  - - ">="
53
56
  - !ruby/object:Gem::Version
57
+ hash: 3
54
58
  segments:
55
59
  - 0
56
60
  version: "0"
@@ -64,6 +68,7 @@ dependencies:
64
68
  requirements:
65
69
  - - ">="
66
70
  - !ruby/object:Gem::Version
71
+ hash: 3
67
72
  segments:
68
73
  - 0
69
74
  version: "0"
@@ -77,6 +82,7 @@ dependencies:
77
82
  requirements:
78
83
  - - ">="
79
84
  - !ruby/object:Gem::Version
85
+ hash: 3
80
86
  segments:
81
87
  - 0
82
88
  version: "0"
@@ -90,6 +96,7 @@ dependencies:
90
96
  requirements:
91
97
  - - ">="
92
98
  - !ruby/object:Gem::Version
99
+ hash: 3
93
100
  segments:
94
101
  - 0
95
102
  version: "0"
@@ -113,6 +120,7 @@ files:
113
120
  - lib/share_counts.rb
114
121
  - lib/share_counts/caching.rb
115
122
  - lib/share_counts/common.rb
123
+ - lib/share_counts/reddit.rb
116
124
  - share_counts.gemspec
117
125
  - spec/share_count_spec.rb
118
126
  - spec/test_helper.rb
@@ -130,6 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
138
  requirements:
131
139
  - - ">="
132
140
  - !ruby/object:Gem::Version
141
+ hash: 3
133
142
  segments:
134
143
  - 0
135
144
  version: "0"
@@ -138,13 +147,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
147
  requirements:
139
148
  - - ">="
140
149
  - !ruby/object:Gem::Version
150
+ hash: 3
141
151
  segments:
142
152
  - 0
143
153
  version: "0"
144
154
  requirements: []
145
155
 
146
156
  rubyforge_project: share_counts
147
- rubygems_version: 1.3.7
157
+ rubygems_version: 1.4.1
148
158
  signing_key:
149
159
  specification_version: 3
150
160
  summary: The easiest way to check how many times a URL has been shared on Reddit, Digg, Twitter, Facebook, LinkedIn, GoogleBuzz and StumbleUpon!