gosns 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0848e3d314c60a6ba840341eeabe062194c8e464
4
- data.tar.gz: 492f4738351be99761cecfb2613ea9257fe13a99
3
+ metadata.gz: 8f9d262edaac1006590aeef8e9d152f1f4431ab0
4
+ data.tar.gz: c1093218af1b681d537227fe08b1157e666f3704
5
5
  SHA512:
6
- metadata.gz: e6376627bf000b76d8f4bc8d7c0028680ef7cc242e8875f6a94288a381ddca7e954a8243fb24639944f99636ef6add5f47cb5ba6b16c7af6db0176f711da0aa6
7
- data.tar.gz: 402c4c2f5bfe08056fef70b15f7e11a2f9cbdbf903957ff715eb9411399c4612b5edcdd2c4f1e6a39dc914fa12fe1f1908661558b2cbaff19c4e0a0261e495de
6
+ metadata.gz: 3a0b3038a9167f1d368024f77af00e5365e30ecb1111727cc57a68a0f8268f35a52d6a5cc967f087448489897251346d7f3c66ce17c56f824a8b51c3a2fef0fb
7
+ data.tar.gz: f8c1dcbd3e7092fc60ade09724a9ac09c7259111388555d95511175662877d68f3c737f71e6d78c348ea31fc720fa9556a61b5cecfd4d2ed7c68a68777c34c73
data/gosns.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'gosns'
3
- s.version = '0.0.2'
3
+ s.version = '0.0.3'
4
4
  s.date = '2015-11-24'
5
5
  s.summary = "gem sns information!"
6
6
  s.description = "gem sns information from twitter, facebook, google+..."
data/lib/gosns.rb CHANGED
@@ -2,6 +2,7 @@ module Gosns
2
2
  require 'nokogiri'
3
3
  require 'open-uri'
4
4
  require 'json'
5
+ require 'oauth2'
5
6
  module Helper
6
7
  class << self
7
8
  def json(url)
@@ -41,4 +42,5 @@ module Gosns
41
42
  require 'provider/twitter'
42
43
  require 'provider/linkedin'
43
44
  require 'provider/googleplus'
45
+ require 'provider/pinterest'
44
46
  end
@@ -1,5 +1,28 @@
1
1
  module Gosns
2
2
  class Googleplus < Sns
3
+ class << self
4
+ attr_accessor :redirect_uri, :key, :secret
5
+ def oauth_authorize_url(options={})
6
+ oauth_client.auth_code.authorize_url(
7
+ redirect_uri: redirect_uri,
8
+ state: options[:state],
9
+ access_type: 'offline',
10
+ scope: 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.login'
11
+ )
12
+ end
13
+ def oauth_client
14
+ option = {
15
+ site: 'https://accounts.google.com',
16
+ authorize_url: "/o/oauth2/auth",
17
+ token_url: "https://www.googleapis.com/oauth2/v3/token"
18
+ }
19
+ OAuth2::Client.new(key, secret, option)
20
+ end
21
+
22
+ def get_token(code)
23
+ oauth_client.auth_code.get_token(code, redirect_uri: redirect_uri).token
24
+ end
25
+ end
3
26
  def followers
4
27
  Helper::parse_int Helper::at_css("https://plus.google.com/+#{account}", ".BOfSxb")
5
28
  end
@@ -1,13 +1,11 @@
1
1
  module Gosns
2
2
  class Linkedin < Sns
3
- require 'oauth2'
4
3
  class << self
5
4
  attr_accessor :redirect_uri, :key, :secret
6
- def oauth_authorize_url
7
- state = 'DCEeFWf45A53sdfKef424'
5
+ def oauth_authorize_url(options={})
8
6
  oauth_client.auth_code.authorize_url(
9
7
  redirect_uri: redirect_uri,
10
- state: state,
8
+ state: options[:state],
11
9
  )
12
10
  end
13
11
  def oauth_client
@@ -25,7 +23,6 @@ module Gosns
25
23
  end
26
24
 
27
25
  def followers
28
- JSON.parse(r.body)['followStatistics']['count']
29
26
  Helper::parse_int Helper::at_css("https://www.linkedin.com/company/#{account}", '.followers-count')
30
27
  end
31
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kikyous