fb_graph2 0.7.1 → 0.7.2
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/attribute_assigner.rb +16 -12
- data/lib/fb_graph2/node.rb +3 -8
- data/lib/fb_graph2/struct/rating.rb +1 -1
- data/lib/fb_graph2/struct.rb +2 -4
- data/lib/fb_graph2.rb +5 -1
- data/spec/fb_graph2/app_spec.rb +4 -6
- data/spec/fb_graph2/node_spec.rb +1 -9
- data/spec/fb_graph2/node_subclass_spec.rb +2 -12
- data/spec/fb_graph2/request_filter/authenticator_spec.rb +1 -3
- data/spec/fb_graph2/user_spec.rb +5 -7
- data/spec/fb_graph2_spec.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47cc32a9ad029bbad0346803bf8ca999ae2b3d75
|
4
|
+
data.tar.gz: eaef411ebb5075c1ca0bc616ed597e2d6fdfa2de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b610f4cce39977ed93d62187ae635759ed5a7c2e7dd62f718792f41af5a91d8f7531a5494478c402679e2e02484daddc29da634b7295d16d9a746fe738c5fc43
|
7
|
+
data.tar.gz: e5c23365053ba2cbca1814042680a7d17db74793bad2da1fc8911eef04cc6e393f522ecbdca7e0eee8f8462f9a11338a32a40f05f6c484f99a35389fb01352da
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.2
|
@@ -8,26 +8,28 @@ module FbGraph2
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module ClassMethods
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
send :attr_accessor, *attributes.values.flatten
|
11
|
+
attr_reader :registered_attributes
|
12
|
+
|
13
|
+
def inherited(child)
|
14
|
+
super
|
15
|
+
child.register_attributes registered_attributes
|
18
16
|
end
|
19
17
|
|
20
18
|
def registered_attributes
|
21
|
-
@registered_attributes
|
19
|
+
@registered_attributes ||= {}
|
22
20
|
end
|
23
21
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
22
|
+
def register_attributes(attributes)
|
23
|
+
attributes.each do |type, keys|
|
24
|
+
registered_attributes[type] ||= []
|
25
|
+
registered_attributes[type] += keys
|
26
|
+
end
|
27
|
+
send :attr_accessor, *attributes.values.flatten
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
31
|
def assign(attributes)
|
32
|
+
self.raw_attributes = attributes
|
31
33
|
Array(self.class.registered_attributes).each do |type, keys|
|
32
34
|
keys.each do |key|
|
33
35
|
if attributes.include? key
|
@@ -91,9 +93,11 @@ module FbGraph2
|
|
91
93
|
Collection.new(raw).collect! do |_raw_|
|
92
94
|
Struct::Tag.new _raw_
|
93
95
|
end
|
94
|
-
|
96
|
+
when :custom
|
95
97
|
# NOTE: handle these attributes in each class
|
96
98
|
next
|
99
|
+
else
|
100
|
+
raise "unknown attribute type #{type}"
|
97
101
|
end
|
98
102
|
self.send :"#{key}=", value
|
99
103
|
end
|
data/lib/fb_graph2/node.rb
CHANGED
@@ -1,17 +1,12 @@
|
|
1
1
|
module FbGraph2
|
2
2
|
class Node
|
3
|
-
|
3
|
+
include AttributeAssigner
|
4
|
+
attr_accessor :id, :access_token
|
4
5
|
alias_method :identifier, :id
|
5
6
|
|
6
|
-
def self.inherited(klass)
|
7
|
-
klass.send :include, AttributeAssigner
|
8
|
-
FbGraph2.object_classes << klass
|
9
|
-
end
|
10
|
-
|
11
7
|
def initialize(id, attributes = {})
|
12
8
|
self.id = id
|
13
|
-
|
14
|
-
assign attributes if respond_to? :assign
|
9
|
+
assign attributes
|
15
10
|
authenticate attributes[:access_token] if attributes.include? :access_token
|
16
11
|
end
|
17
12
|
|
data/lib/fb_graph2/struct.rb
CHANGED
data/lib/fb_graph2.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'active_support'
|
2
2
|
require 'active_support/core_ext'
|
3
|
+
require 'active_support/concern'
|
3
4
|
require 'rack/oauth2'
|
4
5
|
|
5
6
|
module FbGraph2
|
@@ -10,9 +11,12 @@ module FbGraph2
|
|
10
11
|
self.gem_version = File.read(File.join(__dir__, '../VERSION')).strip
|
11
12
|
self.logger = Logger.new(STDOUT)
|
12
13
|
self.logger.progname = 'FbGraph2'
|
13
|
-
self.object_classes = Array.new
|
14
14
|
|
15
15
|
class << self
|
16
|
+
def object_classes
|
17
|
+
FbGraph2::Node.descendants
|
18
|
+
end
|
19
|
+
|
16
20
|
def debugging?
|
17
21
|
!!self.debugging
|
18
22
|
end
|
data/spec/fb_graph2/app_spec.rb
CHANGED
@@ -2,21 +2,19 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph2::App do
|
4
4
|
describe '.app' do
|
5
|
-
let(:klass) { FbGraph2::App }
|
6
|
-
|
7
5
|
it 'should not call API' do
|
8
6
|
expect do
|
9
|
-
app =
|
10
|
-
app.should be_instance_of
|
7
|
+
app = described_class.app 'token'
|
8
|
+
app.should be_instance_of described_class
|
11
9
|
end.not_to request_to 'app'
|
12
10
|
end
|
13
11
|
|
14
12
|
context 'when fetched' do
|
15
13
|
it 'should call API' do
|
16
14
|
app = mock_graph :get, 'app', 'app/app' do
|
17
|
-
|
15
|
+
described_class.app('token').fetch
|
18
16
|
end
|
19
|
-
app.should be_instance_of
|
17
|
+
app.should be_instance_of described_class
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
data/spec/fb_graph2/node_spec.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FbGraph2::Node do
|
4
|
-
let(:
|
5
|
-
let(:instance) { klass.new 'identifier' }
|
4
|
+
let(:instance) { described_class.new 'identifier' }
|
6
5
|
|
7
6
|
describe 'API Versioning' do
|
8
7
|
before do
|
@@ -56,15 +55,8 @@ describe FbGraph2::Node do
|
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
59
|
-
context 'class' do
|
60
|
-
subject { klass }
|
61
|
-
it { should_not respond_to :register_attributes }
|
62
|
-
it { should_not respond_to :registered_attributes }
|
63
|
-
end
|
64
|
-
|
65
58
|
context 'instance' do
|
66
59
|
subject { instance }
|
67
|
-
it { should_not respond_to :assign }
|
68
60
|
|
69
61
|
describe '#initialize' do
|
70
62
|
its(:id) { should == 'identifier' }
|
@@ -6,17 +6,7 @@ module FbGraph2
|
|
6
6
|
end
|
7
7
|
|
8
8
|
describe FbGraph2::NodeSubClass do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
context 'class' do
|
13
|
-
subject { klass }
|
14
|
-
it { should respond_to :register_attributes }
|
15
|
-
it { should respond_to :registered_attributes }
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'instance' do
|
19
|
-
subject { instance }
|
20
|
-
it { should respond_to :assign }
|
9
|
+
it 'should be included in FbGraph2.object_classes' do
|
10
|
+
FbGraph2.object_classes.should include described_class
|
21
11
|
end
|
22
12
|
end
|
@@ -1,11 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FbGraph2::RequestFilter::Authenticator do
|
4
|
-
let(:klass) { FbGraph2::RequestFilter::Authenticator }
|
5
|
-
|
6
4
|
let(:endpoint) { 'https://graph.facebook.com/matake' }
|
7
5
|
let(:request) { HTTP::Message.new_request(:get, URI.parse(endpoint)) }
|
8
|
-
let(:request_filter) {
|
6
|
+
let(:request_filter) { described_class.new token }
|
9
7
|
|
10
8
|
context 'when String given' do
|
11
9
|
let(:token) { 'token' }
|
data/spec/fb_graph2/user_spec.rb
CHANGED
@@ -2,27 +2,25 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe FbGraph2::User do
|
4
4
|
describe '.me' do
|
5
|
-
let(:klass) { FbGraph2::User }
|
6
|
-
|
7
5
|
it 'should not call API' do
|
8
6
|
expect do
|
9
|
-
me =
|
10
|
-
me.should be_instance_of
|
7
|
+
me = described_class.me 'token'
|
8
|
+
me.should be_instance_of described_class
|
11
9
|
end.not_to request_to 'me'
|
12
10
|
end
|
13
11
|
|
14
12
|
context 'when fetched' do
|
15
13
|
it 'should call API' do
|
16
14
|
me = mock_graph :get, 'me', 'user/me' do
|
17
|
-
|
15
|
+
described_class.me('token').fetch
|
18
16
|
end
|
19
|
-
me.should be_instance_of
|
17
|
+
me.should be_instance_of described_class
|
20
18
|
end
|
21
19
|
|
22
20
|
context 'when ext attrs included' do
|
23
21
|
it 'should success to parse' do
|
24
22
|
me = mock_graph :get, 'me', 'user/me_with_ext_attrs' do
|
25
|
-
|
23
|
+
described_class.me('token').fetch
|
26
24
|
end
|
27
25
|
[
|
28
26
|
:age_range, :context, :currency, :devices
|
data/spec/fb_graph2_spec.rb
CHANGED
@@ -8,7 +8,6 @@ describe FbGraph2 do
|
|
8
8
|
its(:logger) { should be_a Logger }
|
9
9
|
its(:api_version) { should == 'v2.3' }
|
10
10
|
its(:root_url) { should == 'https://graph.facebook.com' }
|
11
|
-
its(:object_classes) { should contain_exactly *FbGraph2::Node.subclasses + [FbGraph2::Place] }
|
12
11
|
it { should_not be_debugging }
|
13
12
|
end
|
14
13
|
|
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.2
|
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-07-
|
11
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|