fb_graph 1.2.5 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/fb_graph.gemspec +1 -1
- data/lib/fb_graph/location.rb +1 -1
- data/lib/fb_graph/node.rb +9 -4
- data/lib/fb_graph/photo.rb +5 -1
- data/lib/fb_graph/post.rb +1 -1
- data/lib/fb_graph/privacy.rb +1 -1
- data/lib/fb_graph/query.rb +1 -1
- data/lib/fb_graph/serialization.rb +8 -4
- data/lib/fb_graph/tag.rb +11 -0
- data/lib/fb_graph/targeting.rb +1 -1
- data/lib/fb_graph/venue.rb +5 -5
- data/lib/fb_graph.rb +1 -5
- data/spec/fb_graph/connections/photos_spec.rb +9 -0
- data/spec/fb_graph/node_spec.rb +10 -2
- data/spec/fb_graph/seriarization_spec.rb +1 -1
- data/spec/fb_graph/tag_spec.rb +13 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/fb_graph.gemspec
CHANGED
data/lib/fb_graph/location.rb
CHANGED
data/lib/fb_graph/node.rb
CHANGED
@@ -33,7 +33,7 @@ module FbGraph
|
|
33
33
|
protected
|
34
34
|
|
35
35
|
def get(params = {})
|
36
|
-
_params_ =
|
36
|
+
_params_ = stringfy_params(params)
|
37
37
|
_endpoint_ = build_endpoint(_params_.merge!(:method => :get))
|
38
38
|
handle_response do
|
39
39
|
RestClient.get(_endpoint_)
|
@@ -41,7 +41,7 @@ module FbGraph
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def post(params = {})
|
44
|
-
_params_ =
|
44
|
+
_params_ = stringfy_params(params)
|
45
45
|
_endpoint_ = build_endpoint(_params_.merge!(:method => :post))
|
46
46
|
handle_response do
|
47
47
|
RestClient.post(_endpoint_, _params_)
|
@@ -49,7 +49,7 @@ module FbGraph
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def delete(params = {})
|
52
|
-
_params_ =
|
52
|
+
_params_ = stringfy_params(params)
|
53
53
|
_endpoint_ = build_endpoint(_params_.merge!(:method => :delete))
|
54
54
|
handle_response do
|
55
55
|
RestClient.delete(_endpoint_)
|
@@ -69,12 +69,17 @@ module FbGraph
|
|
69
69
|
_endpoint_
|
70
70
|
end
|
71
71
|
|
72
|
-
def
|
72
|
+
def stringfy_params(params)
|
73
73
|
_params_ = params.dup
|
74
74
|
_params_[:access_token] ||= self.access_token
|
75
75
|
if access_token.is_a?(OAuth2::AccessToken)
|
76
76
|
_params_[:access_token] = _params_[:access_token].token
|
77
77
|
end
|
78
|
+
_params_.each do |key, value|
|
79
|
+
if value.present? && ![Symbol, String, Numeric, IO].any? { |klass| value.is_a? klass }
|
80
|
+
_params_[key] = value.to_json
|
81
|
+
end
|
82
|
+
end
|
78
83
|
_params_
|
79
84
|
end
|
80
85
|
|
data/lib/fb_graph/photo.rb
CHANGED
data/lib/fb_graph/post.rb
CHANGED
data/lib/fb_graph/privacy.rb
CHANGED
data/lib/fb_graph/query.rb
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
module FbGraph
|
2
2
|
module Serialization
|
3
|
-
def to_hash
|
3
|
+
def to_hash(options = {})
|
4
4
|
raise "Define #{self.class}#to_hash!"
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
8
|
-
hash = self.to_hash
|
7
|
+
def as_json(options = {})
|
8
|
+
hash = self.to_hash options
|
9
9
|
hash.delete_if do |k, v|
|
10
10
|
v.blank?
|
11
11
|
end
|
12
|
-
hash
|
12
|
+
hash
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_json(options = {})
|
16
|
+
as_json.to_json options
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
data/lib/fb_graph/tag.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module FbGraph
|
2
2
|
class Tag
|
3
3
|
include Comparison
|
4
|
+
include Serialization
|
4
5
|
|
5
6
|
attr_accessor :user, :name, :x, :y, :created_time
|
6
7
|
|
@@ -15,5 +16,15 @@ module FbGraph
|
|
15
16
|
end
|
16
17
|
@name = attributes[:name]
|
17
18
|
end
|
19
|
+
|
20
|
+
def to_hash(options = {})
|
21
|
+
hash = {
|
22
|
+
:tag_text => self.name,
|
23
|
+
:x => self.x,
|
24
|
+
:y => self.y
|
25
|
+
}
|
26
|
+
hash[:tag_uid] = self.user.identifier if self.user
|
27
|
+
hash
|
28
|
+
end
|
18
29
|
end
|
19
30
|
end
|
data/lib/fb_graph/targeting.rb
CHANGED
data/lib/fb_graph/venue.rb
CHANGED
@@ -4,11 +4,11 @@ module FbGraph
|
|
4
4
|
|
5
5
|
def initialize(attriutes = {})
|
6
6
|
super
|
7
|
-
@street
|
8
|
-
@city
|
9
|
-
@state
|
10
|
-
@zip
|
11
|
-
@country
|
7
|
+
@street = attriutes[:street]
|
8
|
+
@city = attriutes[:city]
|
9
|
+
@state = attriutes[:state]
|
10
|
+
@zip = attriutes[:zip]
|
11
|
+
@country = attriutes[:country]
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/lib/fb_graph.rb
CHANGED
@@ -2,11 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'json'
|
3
3
|
require 'restclient'
|
4
4
|
require 'oauth2'
|
5
|
-
|
6
|
-
# NOTE:
|
7
|
-
# For some reason, ActiveSupport 3.0.0 doesn'tj load whole code.
|
8
|
-
# Load needed extention directly for now.
|
9
|
-
require 'active_support/core_ext'
|
5
|
+
require 'active_support/all'
|
10
6
|
|
11
7
|
module FbGraph
|
12
8
|
ROOT_URL = "https://graph.facebook.com"
|
@@ -29,4 +29,13 @@ describe FbGraph::Connections::Photos, '#photo!' do
|
|
29
29
|
photo.name.should == 'Hello, where is photo?'
|
30
30
|
photo.access_token.should == 'valid'
|
31
31
|
end
|
32
|
+
|
33
|
+
it 'should support Tag' do
|
34
|
+
photo = FbGraph::Album.new('12345', :access_token => 'valid').photo!(
|
35
|
+
:image => Tempfile.new('image_file'),
|
36
|
+
:message => 'Hello, where is photo?',
|
37
|
+
:tags => [FbGraph::Tag.new(:id => 12345, :name => 'me', :x => 0, :y => 10)]
|
38
|
+
)
|
39
|
+
photo.tags.should == [FbGraph::Tag.new(:id => 12345, :name => 'me', :x => 0, :y => 10)]
|
40
|
+
end
|
32
41
|
end
|
data/spec/fb_graph/node_spec.rb
CHANGED
@@ -12,11 +12,19 @@ describe FbGraph::Node, '.new' do
|
|
12
12
|
|
13
13
|
end
|
14
14
|
|
15
|
-
describe FbGraph::Node, '#
|
15
|
+
describe FbGraph::Node, '#stringfy_params' do
|
16
|
+
it 'should make all values to JSON' do
|
17
|
+
client = OAuth2::Client.new('client_id', 'client_secret')
|
18
|
+
node = FbGraph::Node.new('identifier')
|
19
|
+
params = node.send :stringfy_params, {:hash => {:a => :b}, :array => [:a, :b]}
|
20
|
+
params[:hash].should == '{"a":"b"}'
|
21
|
+
params[:array].should == '["a","b"]'
|
22
|
+
end
|
23
|
+
|
16
24
|
it 'should support OAuth2::AccessToken' do
|
17
25
|
client = OAuth2::Client.new('client_id', 'client_secret')
|
18
26
|
node = FbGraph::Node.new('identifier', :access_token => OAuth2::AccessToken.new(client, 'token', 'secret'))
|
19
|
-
params = node.send :
|
27
|
+
params = node.send :stringfy_params, {}
|
20
28
|
params[:access_token].should == 'token'
|
21
29
|
end
|
22
30
|
end
|
data/spec/fb_graph/tag_spec.rb
CHANGED
@@ -18,4 +18,17 @@ describe FbGraph::Tag, '.new' do
|
|
18
18
|
tag.created_time.should == Time.parse("2010-04-22T08:24:26+0000")
|
19
19
|
end
|
20
20
|
|
21
|
+
it 'should not setup user if id is blank' do
|
22
|
+
attributes = {
|
23
|
+
:id => "",
|
24
|
+
:name => "Arjun Banker",
|
25
|
+
:x => 32.5,
|
26
|
+
:y => 27.7778,
|
27
|
+
:created_time => "2010-04-22T08:24:26+0000"
|
28
|
+
}
|
29
|
+
tag = FbGraph::Tag.new(attributes)
|
30
|
+
tag.user.should be_nil
|
31
|
+
tag.name.should == 'Arjun Banker'
|
32
|
+
end
|
33
|
+
|
21
34
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fb_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 1.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- nov matake
|