fb_graph2 0.7.4 → 0.7.5
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 +4 -4
- data/VERSION +1 -1
- data/lib/fb_graph2.rb +1 -0
- data/lib/fb_graph2/auth/signed_request.rb +1 -0
- data/lib/fb_graph2/edge/permissions.rb +4 -0
- data/lib/fb_graph2/edge/picture.rb +12 -1
- data/lib/fb_graph2/struct/permission.rb +8 -0
- data/lib/fb_graph2/util.rb +2 -0
- data/lib/patch/rack/oauth2/util.rb +14 -0
- data/spec/fb_graph2/edge/picture_spec.rb +30 -0
- data/spec/fb_graph2/util_spec.rb +8 -0
- data/spec/mock_json/user/with_picture.json +9 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dff2abb98ac745ab5794798b2464f545f264310
|
4
|
+
data.tar.gz: c1e1bf71b981067e42a5b199c982404126456c74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ea181a68ed183e4845afe6919bb095551242bb1553e8511c75a73cf7e397a71c10efe341f77ee3e81c2e935dde246eba17184ea84360a6e731e0afbaadbe128
|
7
|
+
data.tar.gz: 13a8b6b2050e946d42af1c58a523e3f6cf49abb83a89b302e2493eecc2d0e02ea6bbaf5ba2a3cc3b904775efa0a3f751c4181cc602a6292b5c842c989a5c9084
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.5
|
data/lib/fb_graph2.rb
CHANGED
@@ -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
|
@@ -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 =
|
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
|
data/lib/fb_graph2/util.rb
CHANGED
@@ -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
|
data/spec/fb_graph2/util_spec.rb
CHANGED
@@ -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
|
+
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-
|
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
|