weibo_2 0.1.4 → 0.1.5

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: 804567e4d657756fd85e6f1ee69d157af8a70c5d
4
- data.tar.gz: 62c245c552dbaa0802162bf77442bcda0512bac7
3
+ metadata.gz: 82d0f89962c79e9e4c84446eca7fa8a721e73c50
4
+ data.tar.gz: 4514afd94a970bbddfd84058c3fe4a60b2dd946a
5
5
  SHA512:
6
- metadata.gz: a2ab72bcc012887524bbdbf7f75ea27950b2f81891dd6860f45149e5aec11a35b1ae2474410a3c9e460ebb97a83b84aa2073fc8424bad12314c3a5fe065d6e5e
7
- data.tar.gz: c0ffcc212443c76091d9c2e08865a145fb8418e5acbfcfdbbc3e6f144a88559da0d1898b098a20ef522c5f2662220ccfed03dc5681c7dc406714a79f27da80f6
6
+ metadata.gz: 6c3f8691b5320fda33446296ea059f60102ce8319c00211aa0089725ce5540f7f34e014ae7b1a8e7a69a37c284cbe891223c0a531d1607ec59e4b731ba24b5ae
7
+ data.tar.gz: 2e5dc929e50444b98b7a0b18233645d3aaf71335d1a17757f61c425155910173ef3163cd6406c437897f0067b7596270352017ae3feaa30edad6a796cfcb9003
@@ -17,7 +17,7 @@ module WeiboOAuth2
17
17
  end
18
18
 
19
19
  def hashie(response)
20
- json_body = MultiJson.load(response.body)
20
+ json_body = MultiJson.decode(response.body)
21
21
  if json_body.is_a? Array
22
22
  Array.new(json_body.count){|i| Hashie::Mash.new(json_body[i])}
23
23
  else
@@ -76,4 +76,4 @@ module WeiboOAuth2
76
76
  end
77
77
  end
78
78
  end
79
- end
79
+ end
@@ -2,7 +2,9 @@ require 'oauth2'
2
2
 
3
3
  module WeiboOAuth2
4
4
  class Client < OAuth2::Client
5
-
5
+
6
+ attr_accessor :access_token
7
+
6
8
  def initialize(client_id='', client_secret='', opts={}, &block)
7
9
  client_id = WeiboOAuth2::Config.api_key if client_id.empty?
8
10
  client_secret = WeiboOAuth2::Config.api_secret if client_secret.empty?
@@ -11,7 +13,21 @@ module WeiboOAuth2
11
13
  @options[:authorize_url] = '/oauth2/authorize'
12
14
  @options[:token_url] = '/oauth2/access_token'
13
15
  end
14
-
16
+
17
+ def self.from_code(code, opts={}, &block)
18
+ client = self.new(opts, &block)
19
+ client.auth_code.get_token(code)
20
+
21
+ client
22
+ end
23
+
24
+ def self.from_hash(hash, opts={}, &block)
25
+ client = self.new(opts, &block)
26
+ client.get_token_from_hash(hash)
27
+
28
+ client
29
+ end
30
+
15
31
  def authorize_url(params={})
16
32
  params[:client_id] = @id unless params[:client_id]
17
33
  params[:response_type] = 'code' unless params[:response_type]
@@ -93,6 +109,14 @@ module WeiboOAuth2
93
109
  def auth_code
94
110
  @auth_code ||= WeiboOAuth2::Strategy::AuthCode.new(self)
95
111
  end
112
+
113
+ def place
114
+ @place ||= WeiboOAuth2::Api::V2::Place.new(@access_token) if @access_token
115
+ end
116
+
117
+ def location
118
+ @location ||= WeiboOAuth2::Api::V2::Location.new(@access_token) if @access_token
119
+ end
96
120
 
97
121
  end
98
122
  end
@@ -3,7 +3,7 @@ module WeiboOAuth2
3
3
  class Version
4
4
  MAJOR = 0 unless defined? MAJOR
5
5
  MINOR = 1 unless defined? MINOR
6
- PATCH = 4 unless defined? PATCH
6
+ PATCH = 5 unless defined? PATCH
7
7
  PRE = nil unless defined? PRE
8
8
 
9
9
  class << self
data/lib/weibo_2.rb CHANGED
@@ -17,6 +17,8 @@ require "weibo_2/api/v2/search"
17
17
  require "weibo_2/api/v2/short_url"
18
18
  require "weibo_2/api/v2/suggestions"
19
19
  require "weibo_2/api/v2/remind"
20
+ require "weibo_2/api/v2/place"
21
+ require "weibo_2/api/v2/location"
20
22
  require "weibo_2/strategy/auth_code"
21
23
 
22
24
 
data/weibo_2.gemspec CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('../lib/weibo_2/version', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["simsicon"]
6
6
  gem.email = ["simsicon@gmail.com"]
7
- gem.description = %q{WeioOAuth2 is a Ruby gem that provides a wrapper for interacting with sina weibo's v2 API,
7
+ gem.description = %q{WeioOAuth2 is a Ruby gem that provides a wrapper for interacting with sina weibo's v2 API,
8
8
  which is currently the latest version. The output data format is Hashie::Mash}
9
9
  gem.summary = "A oauth2 gem for weibo"
10
10
  gem.homepage = "http://github.com/simsicon/weibo_2"
@@ -15,11 +15,11 @@ Gem::Specification.new do |gem|
15
15
  gem.name = "weibo_2"
16
16
  gem.require_paths = ["lib"]
17
17
  gem.version = WeiboOAuth2::Version
18
-
18
+
19
19
  gem.add_development_dependency "rspec", "~> 2.6"
20
-
20
+
21
21
  gem.add_runtime_dependency 'oauth2', "~> 0.9.1"
22
22
  gem.add_runtime_dependency 'hashie', "~> 2.0.4"
23
- gem.add_runtime_dependency 'multi_json' , "~> 1.7.2"
23
+ gem.add_runtime_dependency 'multi_json' , "~> 1"
24
24
  gem.add_runtime_dependency 'rest-client', "~> 1.6.7"
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weibo_2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - simsicon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-08 00:00:00.000000000 Z
11
+ date: 2013-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 1.7.2
61
+ version: '1'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 1.7.2
68
+ version: '1'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rest-client
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,9 +80,9 @@ dependencies:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.6.7
83
- description: "WeioOAuth2 is a Ruby gem that provides a wrapper for interacting with
84
- sina weibo's v2 API, \n which is currently the latest version.
85
- The output data format is Hashie::Mash"
83
+ description: |-
84
+ WeioOAuth2 is a Ruby gem that provides a wrapper for interacting with sina weibo's v2 API,
85
+ which is currently the latest version. The output data format is Hashie::Mash
86
86
  email:
87
87
  - simsicon@gmail.com
88
88
  executables: []