fb_graph2 0.7.4 → 0.7.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: 431d6cb04562b1022f10b4040fea986b10e4404b
4
- data.tar.gz: d18110c880b7db29ccfe344d75a489bfa341c10b
3
+ metadata.gz: 5dff2abb98ac745ab5794798b2464f545f264310
4
+ data.tar.gz: c1e1bf71b981067e42a5b199c982404126456c74
5
5
  SHA512:
6
- metadata.gz: cf83c95e279e359db21b00f997dc97bc9f179b17d6cd221053e12898edfaa709dfd13ae90d7887a2ee59005a58e02f118bec5741c8cb148965818e6e15da892e
7
- data.tar.gz: 383aca0fff54f11d75ba24f10f289d2bc92ff379b509a7bf47793e8e9c06be0b8ea91ec9a445dbe66676009d867370c66feb7c5678d1bcfee7186e3622a9723f
6
+ metadata.gz: 3ea181a68ed183e4845afe6919bb095551242bb1553e8511c75a73cf7e397a71c10efe341f77ee3e81c2e935dde246eba17184ea84360a6e731e0afbaadbe128
7
+ data.tar.gz: 13a8b6b2050e946d42af1c58a523e3f6cf49abb83a89b302e2493eecc2d0e02ea6bbaf5ba2a3cc3b904775efa0a3f751c4181cc602a6292b5c842c989a5c9084
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.4
1
+ 0.7.5
@@ -2,6 +2,7 @@ require 'active_support'
2
2
  require 'active_support/core_ext'
3
3
  require 'active_support/concern'
4
4
  require 'rack/oauth2'
5
+ require 'patch/rack/oauth2/util'
5
6
 
6
7
  module FbGraph2
7
8
  mattr_accessor :root_url, :api_version, :gem_version, :logger, :debugging, :_http_config_, :object_classes
@@ -27,6 +27,7 @@ module FbGraph2
27
27
 
28
28
  def instantiate(client)
29
29
  if payload[:code].present?
30
+ client.redirect_uri ||= ''
30
31
  client.authorization_code = payload[:code]
31
32
  self.access_token = client.access_token!
32
33
  else
@@ -7,6 +7,10 @@ module FbGraph2
7
7
  Struct::Permission.new permission
8
8
  end
9
9
  end
10
+
11
+ def revoke!(permission = nil, params = {})
12
+ destroy params, edge: :permissions, edge_scope: permission
13
+ end
10
14
  end
11
15
  end
12
16
  end
@@ -1,10 +1,21 @@
1
1
  module FbGraph2
2
2
  class Edge
3
3
  module Picture
4
+ def assign(attributes)
5
+ super
6
+ if attributes.include? :picture
7
+ @_cached_picture = attributes[:picture]
8
+ end
9
+ end
10
+
4
11
  def picture(*args)
5
12
  params = args.extract_options!
6
13
  params[:type] = args.first if args.first
7
- picture = self.get params.merge(redirect: false), edge: :picture
14
+ picture = if @_cached_picture.present? && params.blank?
15
+ @_cached_picture
16
+ else
17
+ self.get params.merge(redirect: false), edge: :picture
18
+ end
8
19
  Struct::Picture.new picture[:data]
9
20
  end
10
21
  end
@@ -4,6 +4,14 @@ module FbGraph2
4
4
  register_attributes(
5
5
  raw: [:permission, :status]
6
6
  )
7
+
8
+ def as_identifier
9
+ permission
10
+ end
11
+
12
+ def revokable?
13
+ !['public_profile'].include? permission
14
+ end
7
15
  end
8
16
  end
9
17
  end
@@ -5,6 +5,8 @@ module FbGraph2
5
5
  def as_identifier(object)
6
6
  if object.respond_to? :id
7
7
  object.id
8
+ elsif object.respond_to? :as_identifier
9
+ object.as_identifier
8
10
  else
9
11
  object
10
12
  end
@@ -0,0 +1,14 @@
1
+ # NOTE: Authorization code given via FB JS SDK needs blank string as redirect_uri
2
+ module Rack::OAuth2::Util
3
+ class << self
4
+ def compact_hash_with_blank_redirect_uri(hash)
5
+ original_redirect_uri = hash[:redirect_uri]
6
+ result = compact_hash_without_blank_redirect_uri hash
7
+ if original_redirect_uri
8
+ result[:redirect_uri] ||= original_redirect_uri
9
+ end
10
+ result
11
+ end
12
+ alias_method_chain :compact_hash, :blank_redirect_uri
13
+ end
14
+ end
@@ -4,6 +4,7 @@ describe FbGraph2::Edge::Picture do
4
4
  context 'included in User' do
5
5
  describe '#picture' do
6
6
  let(:me) { FbGraph2::User.me('token') }
7
+
7
8
  it do
8
9
  mock_graph :get, 'me/picture', 'user/picture', access_token: 'token', params: {
9
10
  redirect: false
@@ -11,6 +12,35 @@ describe FbGraph2::Edge::Picture do
11
12
  me.picture
12
13
  end.should be_instance_of FbGraph2::Struct::Picture
13
14
  end
15
+
16
+ context 'when cached' do
17
+ let(:me_with_picture) do
18
+ mock_graph :get, 'me', 'user/with_picture', access_token: 'token', params: {
19
+ fields: 'picture'
20
+ } do
21
+ me.fetch fields: 'picture'
22
+ end
23
+ end
24
+
25
+ context 'with option params' do
26
+ it 'should not use cache' do
27
+ mock_graph :get, '579612276/picture', 'user/picture', access_token: 'token', params: {
28
+ redirect: false,
29
+ type: 'square'
30
+ } do
31
+ me_with_picture.picture :square
32
+ end
33
+ end
34
+ end
35
+
36
+ context 'without option params' do
37
+ it 'should use cache' do
38
+ expect do
39
+ me_with_picture.picture
40
+ end.not_to request_to '579612276/picture'
41
+ end
42
+ end
43
+ end
14
44
  end
15
45
  end
16
46
  end
@@ -15,5 +15,13 @@ describe FbGraph2::Util do
15
15
  FbGraph2::Util.as_identifier('object_id').should == 'object_id'
16
16
  end
17
17
  end
18
+
19
+ context 'when FbGraph2::Struct::Permission given' do
20
+ it do
21
+ FbGraph2::Util.as_identifier(
22
+ FbGraph2::Struct::Permission.new(permission: 'permission_name', granted: true)
23
+ ).should == 'permission_name'
24
+ end
25
+ end
18
26
  end
19
27
  end
@@ -0,0 +1,9 @@
1
+ {
2
+ "picture": {
3
+ "data": {
4
+ "is_silhouette": false,
5
+ "url": "https://scontent.xx.fbcdn.net/hprofile-xaf1/v/l/t1.0-1/c47.47.587.587/s50x50/480315_10151515065267277_840234863_n.jpg?oh=6935fc39f4807b6f30c741d721ce766e&oe=56639F81"
6
+ }
7
+ },
8
+ "id": "579612276"
9
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_graph2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-21 00:00:00.000000000 Z
11
+ date: 2015-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -319,6 +319,7 @@ files:
319
319
  - lib/fb_graph2/user.rb
320
320
  - lib/fb_graph2/util.rb
321
321
  - lib/fb_graph2/video.rb
322
+ - lib/patch/rack/oauth2/util.rb
322
323
  - spec/fb_graph2/app_link_host_spec.rb
323
324
  - spec/fb_graph2/app_spec.rb
324
325
  - spec/fb_graph2/auth_spec.rb
@@ -469,6 +470,7 @@ files:
469
470
  - spec/mock_json/user/taggable_friends.json
470
471
  - spec/mock_json/user/television.json
471
472
  - spec/mock_json/user/videos.json
473
+ - spec/mock_json/user/with_picture.json
472
474
  - spec/spec_helper.rb
473
475
  - spec/spec_helper/mock_graph.rb
474
476
  homepage: https://github.com/nov/fb_graph2
@@ -491,7 +493,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
491
493
  version: '0'
492
494
  requirements: []
493
495
  rubyforge_project:
494
- rubygems_version: 2.4.5
496
+ rubygems_version: 2.4.5.1
495
497
  signing_key:
496
498
  specification_version: 4
497
499
  summary: Facebook Graph API v2.x Wrapper in Ruby