gosns 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b20f0ae8651b808b9ea7ceaa9f3d92603a3b29c0
4
+ data.tar.gz: ec932590705e9a5f39aaa3c8a87bbd2f8faa2044
5
+ SHA512:
6
+ metadata.gz: f41da3358d2d0fdf69581e67af6cbfb2bba3d3871e0c6245b53f24c0b276cf42d6f5c374852ec03a2d715b92aab3fad7c304735196c8eee3c034c4c9b08210b2
7
+ data.tar.gz: 9247a98881cf28827ee6fa961bfc860b19d996434d851b9ff805ffb41b4ccb81a2c74d5cea0fe81fa65d562872eb36da0bca097afe47a2dce34fa622b57c0113
data/gosns.gemspec ADDED
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'gosns'
3
+ s.version = '0.0.1'
4
+ s.date = '2015-11-24'
5
+ s.summary = "gem sns information!"
6
+ s.description = "gem sns information from twitter, facebook, google+..."
7
+ s.authors = ["kikyous"]
8
+ s.email = 'kikyous@163.com'
9
+ s.files = `git ls-files`.split("\n")
10
+ s.homepage = 'http://rubygems.org/gems/gosns'
11
+ s.license = 'MIT'
12
+
13
+ s.add_runtime_dependency "nokogiri"
14
+ end
data/lib/gosns.rb ADDED
@@ -0,0 +1,44 @@
1
+ module Gosns
2
+ require 'nokogiri'
3
+ require 'open-uri'
4
+ require 'json'
5
+ module Helper
6
+ class << self
7
+ def json(url)
8
+ JSON.parse(open(url).read)
9
+ end
10
+
11
+ def at_css(url, css)
12
+ doc(url).css(css).first.text
13
+ end
14
+
15
+ def at_xpath(url, css)
16
+ doc(url).css(css).text
17
+ end
18
+
19
+ def parse_int(str)
20
+ str.gsub(',', '').to_i
21
+ end
22
+
23
+ def doc(url)
24
+ Nokogiri::HTML(open(url))
25
+ end
26
+
27
+ def description(url)
28
+ doc(url).css("meta[name='description']").first
29
+ end
30
+ end
31
+ end
32
+
33
+ class Sns
34
+ attr_accessor :account
35
+ def initialize(account)
36
+ self.account = account
37
+ end
38
+ end
39
+
40
+ require 'provider/facebook'
41
+ require 'provider/twitter'
42
+ require 'provider/linkedin'
43
+ require 'provider/googleplus'
44
+ end
@@ -0,0 +1,11 @@
1
+ module Gosns
2
+ class Facebook < Sns
3
+ def likes
4
+ data = Helper::json("http://api.facebook.com/restserver.php?format=json&method=links.getStats&urls=https://www.facebook.com/#{account}")
5
+
6
+ data.first['like_count']
7
+ end
8
+
9
+ alias followers likes
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module Gosns
2
+ class Googleplus < Sns
3
+ def followers
4
+ Helper::parse_int Helper::at_css("https://plus.google.com/+#{account}", ".BOfSxb")
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Gosns
2
+ class Linkedin < Sns
3
+ def followers
4
+ Helper::parse_int Helper::at_css("https://www.linkedin.com/company/#{account}", '.followers-count')
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Gosns
2
+ class Twitter < Sns
3
+ def followers
4
+ Helper::json("https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names=#{account}").first['followers_count']
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gosns
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - kikyous
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: gem sns information from twitter, facebook, google+...
28
+ email: kikyous@163.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - gosns.gemspec
34
+ - lib/gosns.rb
35
+ - lib/provider/facebook.rb
36
+ - lib/provider/googleplus.rb
37
+ - lib/provider/linkedin.rb
38
+ - lib/provider/twitter.rb
39
+ homepage: http://rubygems.org/gems/gosns
40
+ licenses:
41
+ - MIT
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 2.4.5
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: gem sns information!
63
+ test_files: []
64
+ has_rdoc: