fbgraph 1.9.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +3 -3
- data/README.textile +12 -0
- data/VERSION +1 -1
- data/fbgraph.gemspec +14 -11
- data/lib/fbgraph.rb +3 -0
- data/lib/fbgraph/base.rb +20 -16
- data/lib/fbgraph/client.rb +10 -1
- data/lib/fbgraph/fql.rb +9 -0
- data/lib/fbgraph/logger.rb +16 -0
- data/lib/fbgraph/selection.rb +2 -8
- data/lib/fbgraph/timeline.rb +28 -0
- data/specs/lib/fbauth/authorization_spec.rb +1 -1
- metadata +38 -35
data/.bundle/config
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
---
|
2
|
-
BUNDLE_DISABLE_SHARED_GEMS:
|
3
|
-
BUNDLE_PATH: vendor/
|
1
|
+
---
|
2
|
+
BUNDLE_DISABLE_SHARED_GEMS: '1'
|
3
|
+
BUNDLE_PATH: vendor/bundler/
|
data/README.textile
CHANGED
@@ -227,6 +227,18 @@ Examples:
|
|
227
227
|
notextile. <code> results = client.realtime.user.delete!</code>
|
228
228
|
|
229
229
|
|
230
|
+
h3. FQL
|
231
|
+
|
232
|
+
h4. client.fql.query("SELECT name FROM user WHERE uid = me()")
|
233
|
+
|
234
|
+
|
235
|
+
h3. Timeline
|
236
|
+
|
237
|
+
h4. client.timeline.action('namespace', 'run').param(:location => [location object URL])
|
238
|
+
|
239
|
+
h4. client.timeline.reads.param(:article => [article object URL] )
|
240
|
+
|
241
|
+
|
230
242
|
h3. Analytics
|
231
243
|
|
232
244
|
h4. TODO
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.10.0
|
data/fbgraph.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "1.
|
7
|
+
s.name = "fbgraph"
|
8
|
+
s.version = "1.10.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
11
|
+
s.authors = ["Nicolas Santa"]
|
12
|
+
s.date = "2012-04-27"
|
13
|
+
s.description = "A Gem for Facebook Open Graph API"
|
14
|
+
s.email = "nicolas55ar@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README",
|
17
17
|
"README.textile"
|
@@ -32,10 +32,13 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/fbgraph/cacert.pem",
|
33
33
|
"lib/fbgraph/canvas.rb",
|
34
34
|
"lib/fbgraph/client.rb",
|
35
|
+
"lib/fbgraph/fql.rb",
|
36
|
+
"lib/fbgraph/logger.rb",
|
35
37
|
"lib/fbgraph/realtime.rb",
|
36
38
|
"lib/fbgraph/result.rb",
|
37
39
|
"lib/fbgraph/search.rb",
|
38
40
|
"lib/fbgraph/selection.rb",
|
41
|
+
"lib/fbgraph/timeline.rb",
|
39
42
|
"specs/lib/fbauth/authorization_spec.rb",
|
40
43
|
"specs/lib/fbauth/base_spec.rb",
|
41
44
|
"specs/lib/fbauth/canvas_spec.rb",
|
@@ -45,11 +48,11 @@ Gem::Specification.new do |s|
|
|
45
48
|
"specs/lib/fbauth/selection_spec.rb",
|
46
49
|
"specs/spec_helper.rb"
|
47
50
|
]
|
48
|
-
s.homepage =
|
49
|
-
s.licenses = [
|
50
|
-
s.require_paths = [
|
51
|
-
s.rubygems_version =
|
52
|
-
s.summary =
|
51
|
+
s.homepage = "http://github.com/nsanta/fbgraph"
|
52
|
+
s.licenses = ["MIT"]
|
53
|
+
s.require_paths = ["lib"]
|
54
|
+
s.rubygems_version = "1.8.21"
|
55
|
+
s.summary = "A Gem for Facebook Open Graph API"
|
53
56
|
|
54
57
|
if s.respond_to? :specification_version then
|
55
58
|
s.specification_version = 3
|
data/lib/fbgraph.rb
CHANGED
data/lib/fbgraph/base.rb
CHANGED
@@ -47,15 +47,13 @@ module FBGraph
|
|
47
47
|
@params.merge!(:access_token => @client.access_token) unless @client.access_token.nil?
|
48
48
|
if @objects.is_a? Array
|
49
49
|
@params.merge!({:ids => @objects.join(',')})
|
50
|
-
path = build_open_graph_path(nil,nil, params)
|
50
|
+
path = build_open_graph_path(nil,nil, @params)
|
51
51
|
elsif @objects.is_a? String
|
52
52
|
path = build_open_graph_path(@objects , @connection_type, @params)
|
53
53
|
else
|
54
54
|
raise "No Facebook objects were recognized as selected; unable to build fb graph path."
|
55
55
|
end
|
56
|
-
|
57
|
-
# puts "FBGRAPH [GET]: #{path}"
|
58
|
-
# puts "ACCESS TOKEN: #{@client.access_token}"
|
56
|
+
show_log('GET' , path, @params) if @debug
|
59
57
|
result = @client.consumer[path].get
|
60
58
|
@last_result = ::FBGraph::Result.new(result, @params)
|
61
59
|
end
|
@@ -65,22 +63,20 @@ module FBGraph
|
|
65
63
|
@params.merge!(data)
|
66
64
|
self.instance_eval(&block) if block_given?
|
67
65
|
@params.merge!(:fields => sanitized_fields.join(',')) unless sanitized_fields.blank?
|
68
|
-
|
69
|
-
path = build_open_graph_path(@objects , @connection_type)
|
70
|
-
|
71
|
-
|
72
|
-
result = @client.consumer[path].post(params)
|
66
|
+
@params.merge!(:access_token => @client.access_token) if (@client.access_token)
|
67
|
+
@path = build_open_graph_path(@objects , @connection_type)
|
68
|
+
show_log('POST' , @path, @params) if @debug
|
69
|
+
result = @client.consumer[@path].post(@params)
|
73
70
|
@last_result = ::FBGraph::Result.new(result, @params)
|
74
71
|
end
|
75
72
|
|
76
73
|
def delete!(parsed = true, &block)
|
77
74
|
self.instance_eval(&block) if block_given?
|
78
|
-
path = build_open_graph_path(@objects , nil)
|
79
|
-
|
80
|
-
params.merge!(:method => :delete)
|
81
|
-
|
82
|
-
|
83
|
-
result = @client.consumer[path].post(params)
|
75
|
+
@path = build_open_graph_path(@objects , nil)
|
76
|
+
@params.merge!(:access_token => @client.access_token) if (@client.access_token)
|
77
|
+
@params.merge!(:method => :delete)
|
78
|
+
show_log('DELETE' , @path, @params) if @debug
|
79
|
+
result = @client.consumer[@path].post(@params)
|
84
80
|
@last_result = ::FBGraph::Result.new(result, @params)
|
85
81
|
end
|
86
82
|
|
@@ -93,7 +89,10 @@ module FBGraph
|
|
93
89
|
PAGING
|
94
90
|
end
|
95
91
|
|
96
|
-
|
92
|
+
def debug=(att)
|
93
|
+
@debug= att
|
94
|
+
end
|
95
|
+
|
97
96
|
private
|
98
97
|
|
99
98
|
def sanitized_fields
|
@@ -106,5 +105,10 @@ module FBGraph
|
|
106
105
|
URI.encode(request)
|
107
106
|
end
|
108
107
|
|
108
|
+
def show_log(ver, path, params)
|
109
|
+
client.logger.info "FBGRAPH [#{verb}]: #{path}"
|
110
|
+
client.logger.info "PARAMS: #{params.to_a.map{|p| p.join('=')}.join('&')}"
|
111
|
+
end
|
112
|
+
|
109
113
|
end
|
110
114
|
end
|
data/lib/fbgraph/client.rb
CHANGED
@@ -2,7 +2,7 @@ module FBGraph
|
|
2
2
|
|
3
3
|
class Client
|
4
4
|
|
5
|
-
attr_accessor :client_id , :secret_id , :facebook_uri , :access_token , :consumer , :auth
|
5
|
+
attr_accessor :client_id , :secret_id , :facebook_uri , :access_token , :consumer , :auth , :logger
|
6
6
|
|
7
7
|
def initialize(options = {})
|
8
8
|
@client_id = options[:client_id] || FBGraph.config[:client_id]
|
@@ -12,6 +12,7 @@ module FBGraph
|
|
12
12
|
@consumer = RestClient::Resource.new(@facebook_uri, rest_client_ssl_options)
|
13
13
|
@access_token = options.fetch :token, nil
|
14
14
|
@auth = OAuth2::AccessToken.new(oauth_client, @access_token)
|
15
|
+
@logger = options[:logger] || FBGraph::Logger
|
15
16
|
return true
|
16
17
|
end
|
17
18
|
|
@@ -37,6 +38,14 @@ module FBGraph
|
|
37
38
|
FBGraph::Realtime.new(self)
|
38
39
|
end
|
39
40
|
|
41
|
+
def fql
|
42
|
+
FBGraph::FQL.new(self)
|
43
|
+
end
|
44
|
+
|
45
|
+
def timeline
|
46
|
+
FBGraph::Timeline.new(self)
|
47
|
+
end
|
48
|
+
|
40
49
|
def oauth_client
|
41
50
|
OAuth2::Client.new(client_id, secret_id,
|
42
51
|
:site => { :url => facebook_uri },
|
data/lib/fbgraph/fql.rb
ADDED
data/lib/fbgraph/selection.rb
CHANGED
@@ -26,8 +26,8 @@ module FBGraph
|
|
26
26
|
|
27
27
|
CONNECTION_TYPES.each do |object|
|
28
28
|
class_eval <<-METHOD
|
29
|
-
def #{object}
|
30
|
-
connection('#{object}')
|
29
|
+
def #{object}(connection_id = nil)
|
30
|
+
connection(['#{object}', connection_id])
|
31
31
|
self
|
32
32
|
end
|
33
33
|
METHOD
|
@@ -38,12 +38,6 @@ module FBGraph
|
|
38
38
|
find('me')
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
def action(namespace,action)
|
43
|
-
connection([namespace,action].join(':'))
|
44
|
-
self
|
45
|
-
end
|
46
|
-
|
47
41
|
def metadata
|
48
42
|
@params.merge!({:metadata => '1'})
|
49
43
|
self
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module FBGraph
|
2
|
+
class Timeline < Base
|
3
|
+
|
4
|
+
BUILT_IN_ACTIONS = {
|
5
|
+
:listens => :music,
|
6
|
+
:reads => :news,
|
7
|
+
:watches => :movie,
|
8
|
+
}
|
9
|
+
|
10
|
+
|
11
|
+
def action(namespace,action)
|
12
|
+
connection([namespace,action].join(':'))
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
BUILT_IN_ACTIONS.each do |action,obj|
|
17
|
+
class_eval <<-METHOD
|
18
|
+
def #{action}
|
19
|
+
find('me').connection("#{[obj,action].join('.')}")
|
20
|
+
self
|
21
|
+
end
|
22
|
+
METHOD
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -21,7 +21,7 @@ describe FBGraph do
|
|
21
21
|
describe '.authorize_url' do
|
22
22
|
it 'should return the authorization url' do
|
23
23
|
@authorization.authorize_url(:redirect_uri => 'redirect/to/path' ,
|
24
|
-
:scope => 'email,user_photos,friends_photos').should
|
24
|
+
:scope => 'email,user_photos,friends_photos').should =~ /redirect_uri=redirect%2Fto%2Fpath/
|
25
25
|
end
|
26
26
|
end
|
27
27
|
describe "process_callback" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fbgraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 10
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.10.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nicolas Santa
|
@@ -15,9 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-04-27 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
+
name: activesupport
|
22
|
+
prerelease: false
|
21
23
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
24
|
none: false
|
23
25
|
requirements:
|
@@ -29,9 +31,9 @@ dependencies:
|
|
29
31
|
version: "0"
|
30
32
|
type: :runtime
|
31
33
|
requirement: *id001
|
32
|
-
prerelease: false
|
33
|
-
name: activesupport
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
+
name: hashie
|
36
|
+
prerelease: false
|
35
37
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
36
38
|
none: false
|
37
39
|
requirements:
|
@@ -45,9 +47,9 @@ dependencies:
|
|
45
47
|
version: 1.0.0
|
46
48
|
type: :runtime
|
47
49
|
requirement: *id002
|
48
|
-
prerelease: false
|
49
|
-
name: hashie
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
|
+
name: oauth2
|
52
|
+
prerelease: false
|
51
53
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
52
54
|
none: false
|
53
55
|
requirements:
|
@@ -61,9 +63,9 @@ dependencies:
|
|
61
63
|
version: 0.5.0
|
62
64
|
type: :runtime
|
63
65
|
requirement: *id003
|
64
|
-
prerelease: false
|
65
|
-
name: oauth2
|
66
66
|
- !ruby/object:Gem::Dependency
|
67
|
+
name: faraday
|
68
|
+
prerelease: false
|
67
69
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
68
70
|
none: false
|
69
71
|
requirements:
|
@@ -77,9 +79,9 @@ dependencies:
|
|
77
79
|
version: 0.7.5
|
78
80
|
type: :runtime
|
79
81
|
requirement: *id004
|
80
|
-
prerelease: false
|
81
|
-
name: faraday
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
|
+
name: json
|
84
|
+
prerelease: false
|
83
85
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
84
86
|
none: false
|
85
87
|
requirements:
|
@@ -93,9 +95,9 @@ dependencies:
|
|
93
95
|
version: 1.0.0
|
94
96
|
type: :runtime
|
95
97
|
requirement: *id005
|
96
|
-
prerelease: false
|
97
|
-
name: json
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
|
+
name: rest-client
|
100
|
+
prerelease: false
|
99
101
|
version_requirements: &id006 !ruby/object:Gem::Requirement
|
100
102
|
none: false
|
101
103
|
requirements:
|
@@ -107,9 +109,9 @@ dependencies:
|
|
107
109
|
version: "0"
|
108
110
|
type: :runtime
|
109
111
|
requirement: *id006
|
110
|
-
prerelease: false
|
111
|
-
name: rest-client
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
|
+
name: i18n
|
114
|
+
prerelease: false
|
113
115
|
version_requirements: &id007 !ruby/object:Gem::Requirement
|
114
116
|
none: false
|
115
117
|
requirements:
|
@@ -121,9 +123,9 @@ dependencies:
|
|
121
123
|
version: "0"
|
122
124
|
type: :runtime
|
123
125
|
requirement: *id007
|
124
|
-
prerelease: false
|
125
|
-
name: i18n
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
+
name: jeweler
|
128
|
+
prerelease: false
|
127
129
|
version_requirements: &id008 !ruby/object:Gem::Requirement
|
128
130
|
none: false
|
129
131
|
requirements:
|
@@ -137,9 +139,9 @@ dependencies:
|
|
137
139
|
version: 1.6.0
|
138
140
|
type: :development
|
139
141
|
requirement: *id008
|
140
|
-
prerelease: false
|
141
|
-
name: jeweler
|
142
142
|
- !ruby/object:Gem::Dependency
|
143
|
+
name: rake
|
144
|
+
prerelease: false
|
143
145
|
version_requirements: &id009 !ruby/object:Gem::Requirement
|
144
146
|
none: false
|
145
147
|
requirements:
|
@@ -153,9 +155,9 @@ dependencies:
|
|
153
155
|
version: 0.9.2
|
154
156
|
type: :development
|
155
157
|
requirement: *id009
|
156
|
-
prerelease: false
|
157
|
-
name: rake
|
158
158
|
- !ruby/object:Gem::Dependency
|
159
|
+
name: bundler
|
160
|
+
prerelease: false
|
159
161
|
version_requirements: &id010 !ruby/object:Gem::Requirement
|
160
162
|
none: false
|
161
163
|
requirements:
|
@@ -169,9 +171,9 @@ dependencies:
|
|
169
171
|
version: 1.0.0
|
170
172
|
type: :development
|
171
173
|
requirement: *id010
|
172
|
-
prerelease: false
|
173
|
-
name: bundler
|
174
174
|
- !ruby/object:Gem::Dependency
|
175
|
+
name: fakeweb
|
176
|
+
prerelease: false
|
175
177
|
version_requirements: &id011 !ruby/object:Gem::Requirement
|
176
178
|
none: false
|
177
179
|
requirements:
|
@@ -185,9 +187,9 @@ dependencies:
|
|
185
187
|
version: 1.3.0
|
186
188
|
type: :development
|
187
189
|
requirement: *id011
|
188
|
-
prerelease: false
|
189
|
-
name: fakeweb
|
190
190
|
- !ruby/object:Gem::Dependency
|
191
|
+
name: rspec
|
192
|
+
prerelease: false
|
191
193
|
version_requirements: &id012 !ruby/object:Gem::Requirement
|
192
194
|
none: false
|
193
195
|
requirements:
|
@@ -201,9 +203,9 @@ dependencies:
|
|
201
203
|
version: 2.6.0
|
202
204
|
type: :development
|
203
205
|
requirement: *id012
|
204
|
-
prerelease: false
|
205
|
-
name: rspec
|
206
206
|
- !ruby/object:Gem::Dependency
|
207
|
+
name: rcov
|
208
|
+
prerelease: false
|
207
209
|
version_requirements: &id013 !ruby/object:Gem::Requirement
|
208
210
|
none: false
|
209
211
|
requirements:
|
@@ -215,9 +217,9 @@ dependencies:
|
|
215
217
|
version: "0"
|
216
218
|
type: :development
|
217
219
|
requirement: *id013
|
218
|
-
prerelease: false
|
219
|
-
name: rcov
|
220
220
|
- !ruby/object:Gem::Dependency
|
221
|
+
name: rdoc
|
222
|
+
prerelease: false
|
221
223
|
version_requirements: &id014 !ruby/object:Gem::Requirement
|
222
224
|
none: false
|
223
225
|
requirements:
|
@@ -231,9 +233,9 @@ dependencies:
|
|
231
233
|
version: 3.9.0
|
232
234
|
type: :development
|
233
235
|
requirement: *id014
|
234
|
-
prerelease: false
|
235
|
-
name: rdoc
|
236
236
|
- !ruby/object:Gem::Dependency
|
237
|
+
name: redgreen
|
238
|
+
prerelease: false
|
237
239
|
version_requirements: &id015 !ruby/object:Gem::Requirement
|
238
240
|
none: false
|
239
241
|
requirements:
|
@@ -247,8 +249,6 @@ dependencies:
|
|
247
249
|
version: 1.2.2
|
248
250
|
type: :development
|
249
251
|
requirement: *id015
|
250
|
-
prerelease: false
|
251
|
-
name: redgreen
|
252
252
|
description: A Gem for Facebook Open Graph API
|
253
253
|
email: nicolas55ar@gmail.com
|
254
254
|
executables: []
|
@@ -274,10 +274,13 @@ files:
|
|
274
274
|
- lib/fbgraph/cacert.pem
|
275
275
|
- lib/fbgraph/canvas.rb
|
276
276
|
- lib/fbgraph/client.rb
|
277
|
+
- lib/fbgraph/fql.rb
|
278
|
+
- lib/fbgraph/logger.rb
|
277
279
|
- lib/fbgraph/realtime.rb
|
278
280
|
- lib/fbgraph/result.rb
|
279
281
|
- lib/fbgraph/search.rb
|
280
282
|
- lib/fbgraph/selection.rb
|
283
|
+
- lib/fbgraph/timeline.rb
|
281
284
|
- specs/lib/fbauth/authorization_spec.rb
|
282
285
|
- specs/lib/fbauth/base_spec.rb
|
283
286
|
- specs/lib/fbauth/canvas_spec.rb
|
@@ -315,7 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
315
318
|
requirements: []
|
316
319
|
|
317
320
|
rubyforge_project:
|
318
|
-
rubygems_version: 1.8.
|
321
|
+
rubygems_version: 1.8.21
|
319
322
|
signing_key:
|
320
323
|
specification_version: 3
|
321
324
|
summary: A Gem for Facebook Open Graph API
|