social_counter 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.1.0
@@ -84,6 +84,12 @@ class SocialCounter
84
84
  $1.to_i || 0
85
85
  end
86
86
 
87
+ def reddit_count
88
+ request_url = "http://tools.mercenie.com/social-share-count/api/?flag=32&format=json&url=#{@url}"
89
+ json = JSON.parser.new(open(request_url).read).parse
90
+ json["reddit"]
91
+ end
92
+
87
93
  def all
88
94
  data = {}
89
95
  self.methods.grep(/(.+)_count/) do
@@ -92,13 +98,14 @@ class SocialCounter
92
98
  data
93
99
  end
94
100
 
95
- alias :t :twitter_count
96
- alias :f :facebook_count
97
- alias :h :hatena_count
98
- alias :g :google_count
101
+ alias :t :twitter_count
102
+ alias :f :facebook_count
103
+ alias :h :hatena_count
104
+ alias :g :google_count
99
105
  alias :po :pocket_count
100
- alias :l :linkedin_count
101
- alias :d :delicious_count
106
+ alias :l :linkedin_count
107
+ alias :d :delicious_count
102
108
  alias :pi :pinterest_count
109
+ alias :r :reddit_count
103
110
 
104
111
  end
@@ -0,0 +1,67 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "social_counter"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["keitarou.oonishi"]
12
+ s.date = "2014-01-31"
13
+ s.description = "social network share counter"
14
+ s.email = "keitarou.oonishi@gmail.com"
15
+ s.executables = ["social_counter"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/social_counter",
29
+ "lib/social_counter.rb",
30
+ "social_counter.gemspec",
31
+ "test/helper.rb",
32
+ "test/test_social_counter.rb"
33
+ ]
34
+ s.homepage = "http://github.com/keitarou/social_counter"
35
+ s.licenses = ["MIT"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = "1.8.23"
38
+ s.summary = "social network share counter"
39
+
40
+ if s.respond_to? :specification_version then
41
+ s.specification_version = 3
42
+
43
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
+ s.add_runtime_dependency(%q<json>, [">= 0"])
45
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
46
+ s.add_runtime_dependency(%q<thor>, [">= 0"])
47
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
50
+ else
51
+ s.add_dependency(%q<json>, [">= 0"])
52
+ s.add_dependency(%q<nokogiri>, [">= 0"])
53
+ s.add_dependency(%q<thor>, [">= 0"])
54
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
55
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
56
+ s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
57
+ end
58
+ else
59
+ s.add_dependency(%q<json>, [">= 0"])
60
+ s.add_dependency(%q<nokogiri>, [">= 0"])
61
+ s.add_dependency(%q<thor>, [">= 0"])
62
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
63
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
64
+ s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
65
+ end
66
+ end
67
+
@@ -3,6 +3,9 @@ require './helper'
3
3
  class TestSocialCounter < Test::Unit::TestCase
4
4
  def setup
5
5
  @url1 = "http://google.com"
6
+ # reddit test
7
+ @url1 = "http://thenextweb.com/insider/2014/01/29/paypal-denies-providing-payment-information-hacker-hijacked-50000-twitter-username/"
8
+
6
9
  @social_counter = SocialCounter.new(@url1)
7
10
  end
8
11
 
@@ -54,6 +57,12 @@ class TestSocialCounter < Test::Unit::TestCase
54
57
  p "pinterest count: " << @social_counter.pi.to_s
55
58
  end
56
59
 
60
+ def test_reddit_count
61
+ p "reddit count: " << @social_counter.reddit_count.to_json
62
+ p "reddit count: " << @social_counter.r.to_json
63
+ assert_equal(@social_counter.r.class.name, "Hash")
64
+ end
65
+
57
66
  def test_all
58
67
  p @social_counter.all
59
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_counter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-30 00:00:00.000000000 Z
12
+ date: 2014-01-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -125,6 +125,7 @@ files:
125
125
  - VERSION
126
126
  - bin/social_counter
127
127
  - lib/social_counter.rb
128
+ - social_counter.gemspec
128
129
  - test/helper.rb
129
130
  - test/test_social_counter.rb
130
131
  homepage: http://github.com/keitarou/social_counter
@@ -142,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
143
  version: '0'
143
144
  segments:
144
145
  - 0
145
- hash: -3229483074396673623
146
+ hash: 3588407682820768091
146
147
  required_rubygems_version: !ruby/object:Gem::Requirement
147
148
  none: false
148
149
  requirements: