fb_graph 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -20,11 +20,6 @@ Almost all connections for each object are also supported. (Private message co
20
20
 
21
21
  Plus, you can play an Rails sample app here. http://fbgraphsample.heroku.com/
22
22
 
23
- === Authentication
24
-
25
- Both Facebook JavaScript SDK and normal OAuth2 flow is supported.
26
- See http://github.com/nov/fb_graph_sample
27
-
28
23
  === GET
29
24
 
30
25
  ==== Basic Objects
@@ -190,6 +185,43 @@ See http://github.com/nov/fb_graph_sample
190
185
  post.unlike!(:access_token => ACCESS_TOKEN)
191
186
  post.destroy(:access_token => ACCESS_TOKEN)
192
187
 
188
+ === Authentication
189
+
190
+ Both Facebook JavaScript SDK and normal OAuth2 flow is supported.
191
+ Below I show simple sample code.
192
+ You can also see http://github.com/nov/fb_graph_sample for more details Rails3 sample application.
193
+
194
+ ==== JavaScript SDK
195
+
196
+ fb_auth = FbGraph::Auth.new(YOUR_APP_ID, YOUR_APPLICATION_SECRET)
197
+ fb_auth.client # => OAuth2::Client
198
+
199
+ # get Facebook's auth cookie in advance using their JS SDK
200
+ fb_auth.from_cookie(cookies)
201
+ fb_auth.access_token # => OAuth2::AccessToken
202
+ fb_auth.user # => FbGraph::User (only basic attributes)
203
+ fb_auth.user.fetch # => fetch more details
204
+
205
+ ==== Normal OAuth2 Flow
206
+
207
+ # redirect user to facebook
208
+ redirect_to fb_auth.client.web_server.authorize_url(
209
+ :redirect_uri => "http://your.client.com/facebook/callback",
210
+ :scope => "email,read_stream,offline_access"
211
+ )
212
+
213
+ # in callback
214
+ fb_auth.client.web_server.get_access_token(
215
+ params[:code],
216
+ :redirect_uri => callback_facebook_url
217
+ ) # => OAuth2::AccessToken
218
+ FbGraph::User.me(access_token).fetch # => fetch user
219
+
220
+ === Analytics
221
+
222
+ app = FbGraph::Application.new(YOUR_APP_ID, :secret => YOUR_APPLICATION_SECRET)
223
+ app.insights # => Array of FbGraph::Insight
224
+
193
225
  == Note on Patches/Pull Requests
194
226
 
195
227
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.1
data/fb_graph.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fb_graph}
8
- s.version = "0.7.0"
8
+ s.version = "0.7.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["nov matake"]
12
- s.date = %q{2010-08-13}
12
+ s.date = %q{2010-09-04}
13
13
  s.description = %q{A Ruby wrapper for Facebook Graph API}
14
14
  s.email = %q{nov@matake.jp}
15
15
  s.extra_rdoc_files = [
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
31
31
  "lib/fb_graph/application.rb",
32
32
  "lib/fb_graph/auth.rb",
33
33
  "lib/fb_graph/auth/cookie.rb",
34
+ "lib/fb_graph/checkin.rb",
34
35
  "lib/fb_graph/collection.rb",
35
36
  "lib/fb_graph/comment.rb",
36
37
  "lib/fb_graph/comparison.rb",
@@ -76,7 +77,9 @@ Gem::Specification.new do |s|
76
77
  "lib/fb_graph/photo.rb",
77
78
  "lib/fb_graph/post.rb",
78
79
  "lib/fb_graph/searchable.rb",
80
+ "lib/fb_graph/searchable/result.rb",
79
81
  "lib/fb_graph/status.rb",
82
+ "lib/fb_graph/subscription.rb",
80
83
  "lib/fb_graph/tag.rb",
81
84
  "lib/fb_graph/user.rb",
82
85
  "lib/fb_graph/venue.rb",
@@ -154,6 +157,8 @@ Gem::Specification.new do |s|
154
157
  "spec/fake_json/users/television/matake_private.json",
155
158
  "spec/fake_json/users/videos/kirk_private.json",
156
159
  "spec/fb_graph/album_spec.rb",
160
+ "spec/fb_graph/application_spec.rb",
161
+ "spec/fb_graph/auth_spec.rb",
157
162
  "spec/fb_graph/collection_spec.rb",
158
163
  "spec/fb_graph/comment_spec.rb",
159
164
  "spec/fb_graph/connection_spec.rb",
@@ -188,6 +193,7 @@ Gem::Specification.new do |s|
188
193
  "spec/fb_graph/education_spec.rb",
189
194
  "spec/fb_graph/event_spec.rb",
190
195
  "spec/fb_graph/group_spec.rb",
196
+ "spec/fb_graph/insight_spec.rb",
191
197
  "spec/fb_graph/link_spec.rb",
192
198
  "spec/fb_graph/node_spec.rb",
193
199
  "spec/fb_graph/note_spec.rb",
@@ -211,6 +217,8 @@ Gem::Specification.new do |s|
211
217
  s.summary = %q{A Ruby wrapper for Facebook Graph API}
212
218
  s.test_files = [
213
219
  "spec/fb_graph/album_spec.rb",
220
+ "spec/fb_graph/application_spec.rb",
221
+ "spec/fb_graph/auth_spec.rb",
214
222
  "spec/fb_graph/collection_spec.rb",
215
223
  "spec/fb_graph/comment_spec.rb",
216
224
  "spec/fb_graph/connection_spec.rb",
@@ -245,6 +253,7 @@ Gem::Specification.new do |s|
245
253
  "spec/fb_graph/education_spec.rb",
246
254
  "spec/fb_graph/event_spec.rb",
247
255
  "spec/fb_graph/group_spec.rb",
256
+ "spec/fb_graph/insight_spec.rb",
248
257
  "spec/fb_graph/link_spec.rb",
249
258
  "spec/fb_graph/node_spec.rb",
250
259
  "spec/fb_graph/note_spec.rb",
@@ -3,31 +3,37 @@ module FbGraph
3
3
  include Connections::Photos
4
4
  include Connections::Comments
5
5
 
6
- attr_accessor :from, :name, :description, :location, :link, :count, :created_time, :updated_time
6
+ attr_accessor :from, :name, :description, :location, :link, :privacy, :count, :created_time, :updated_time, :comments
7
7
 
8
- def initialize(identifier, options = {})
8
+ def initialize(identifier, attributes = {})
9
9
  super
10
- if (from = options[:from])
10
+ if (from = attributes[:from])
11
11
  @from = if from[:category]
12
12
  FbGraph::Page.new(from.delete(:id), from)
13
13
  else
14
14
  FbGraph::User.new(from.delete(:id), from)
15
15
  end
16
16
  end
17
- @name = options[:name]
17
+ @name = attributes[:name]
18
18
  # NOTE:
19
19
  # for some reason, facebook uses different parameter names.
20
20
  # "description" in GET & "message" in POST
21
- @description = options[:description] || options[:message]
22
- @location = options[:location]
23
- @link = options[:link]
24
- @count = options[:count]
25
- if options[:created_time]
26
- @created_time = Time.parse(options[:created_time]).utc
21
+ # TODO:
22
+ # check whether this issue is solved or not
23
+ @description = attributes[:description] || attributes[:message]
24
+ @location = attributes[:location]
25
+ @link = attributes[:link]
26
+ @privacy = attributes[:privacy]
27
+ @count = attributes[:count]
28
+ if attributes[:created_time]
29
+ @created_time = Time.parse(attributes[:created_time]).utc
27
30
  end
28
- if options[:updated_time]
29
- @updated_time = Time.parse(options[:updated_time]).utc
31
+ if attributes[:updated_time]
32
+ @updated_time = Time.parse(attributes[:updated_time]).utc
30
33
  end
34
+
35
+ # cached connection
36
+ @_comments_ = FbGraph::Collection.new(attributes[:comments])
31
37
  end
32
38
  end
33
39
  end
@@ -1,17 +1,28 @@
1
1
  module FbGraph
2
2
  class Application < Node
3
+ include Connections::Feed
4
+ include Connections::Posts
5
+ include Connections::Picture
6
+ include Connections::Tagged
7
+ include Connections::Links
8
+ include Connections::Photos
9
+ include Connections::Albums
10
+ include Connections::Statuses
11
+ include Connections::Videos
12
+ include Connections::Notes
13
+ include Connections::Events
14
+ # include Connections::Subscriptions # TODO
3
15
  include Connections::Insights
4
16
 
5
- attr_accessor :name, :description, :category, :subcategory, :link, :secret
17
+ attr_accessor :name, :description, :category, :link, :secret
6
18
 
7
- def initialize(client_id, options = {})
19
+ def initialize(client_id, attributes = {})
8
20
  super
9
- @name = options[:name]
10
- @description = options[:description]
11
- @category = options[:category]
12
- @subcategory = options[:subcategory]
13
- @link = options[:link]
14
- @secret = options[:secret]
21
+ @name = attributes[:name]
22
+ @description = attributes[:description]
23
+ @category = attributes[:category]
24
+ @link = attributes[:link]
25
+ @secret = attributes[:secret]
15
26
  end
16
27
 
17
28
  def get_access_token(secret = nil)
data/lib/fb_graph/auth.rb CHANGED
@@ -27,6 +27,4 @@ module FbGraph
27
27
  end
28
28
  end
29
29
 
30
- Dir[File.dirname(__FILE__) + '/auth/*.rb'].each do |file|
31
- require file
32
- end
30
+ require 'fb_graph/auth/cookie'
@@ -0,0 +1,15 @@
1
+ module FbGraph
2
+ class Event < Node
3
+ attr_accessor :from, :tags, :place, :message, :coordinates, :application, :created_time
4
+
5
+ def initialize(identifier, attributes = {})
6
+ super
7
+ if (from = attributes[:from])
8
+ @from = FbGraph::User.new(from.delete(:id), from)
9
+ end
10
+ # TODO
11
+ # Checkin isn't available in Japan yet, so I can't use this feature yet.
12
+ # I'm very glad if someone helps me here.
13
+ end
14
+ end
15
+ end
@@ -2,18 +2,18 @@ module FbGraph
2
2
  class Comment < Node
3
3
  attr_accessor :from, :message, :created_time
4
4
 
5
- def initialize(identifier, options = {})
5
+ def initialize(identifier, attributes = {})
6
6
  super
7
- if (from = options[:from])
7
+ if (from = attributes[:from])
8
8
  @from = if from[:category]
9
9
  FbGraph::Page.new(from.delete(:id), from)
10
10
  else
11
11
  FbGraph::User.new(from.delete(:id), from)
12
12
  end
13
13
  end
14
- @message = options[:message]
15
- if options[:created_time]
16
- @created_time = Time.parse(options[:created_time]).utc
14
+ @message = attributes[:message]
15
+ if attributes[:created_time]
16
+ @created_time = Time.parse(attributes[:created_time]).utc
17
17
  end
18
18
  end
19
19
  end
@@ -11,16 +11,16 @@ module FbGraph
11
11
 
12
12
  attr_accessor :owner, :name, :description, :start_time, :end_time, :location, :venue, :privacy, :updated_time
13
13
 
14
- def initialize(identifier, options = {})
14
+ def initialize(identifier, attributes = {})
15
15
  super
16
- if (owner = options[:owner])
16
+ if (owner = attributes[:owner])
17
17
  @owner = FbGraph::User.new(owner.delete(:id), owner)
18
18
  end
19
- @name = options[:name]
20
- @description = options[:description]
21
- @location = options[:location]
22
- @privacy = options[:privacy]
23
- if (start_time = options[:start_time])
19
+ @name = attributes[:name]
20
+ @description = attributes[:description]
21
+ @location = attributes[:location]
22
+ @privacy = attributes[:privacy]
23
+ if (start_time = attributes[:start_time])
24
24
  @start_time = case start_time
25
25
  when String
26
26
  Time.parse(start_time).utc
@@ -28,7 +28,7 @@ module FbGraph
28
28
  Time.at(start_time).utc
29
29
  end
30
30
  end
31
- if (end_time = options[:end_time])
31
+ if (end_time = attributes[:end_time])
32
32
  @end_time = case end_time
33
33
  when String
34
34
  Time.parse(end_time).utc
@@ -36,11 +36,11 @@ module FbGraph
36
36
  Time.at(end_time).utc
37
37
  end
38
38
  end
39
- if options[:venue]
40
- @venue = FbGraph::Venue.new(options[:venue])
39
+ if attributes[:venue]
40
+ @venue = FbGraph::Venue.new(attributes[:venue])
41
41
  end
42
- if options[:updated_time]
43
- @updated_time = Time.parse(options[:updated_time]).utc
42
+ if attributes[:updated_time]
43
+ @updated_time = Time.parse(attributes[:updated_time]).utc
44
44
  end
45
45
  end
46
46
  end
@@ -2,12 +2,13 @@ module FbGraph
2
2
  class Insight
3
3
  include FbGraph::Comparison
4
4
 
5
- attr_accessor :name, :period, :values
5
+ attr_accessor :name, :period, :values, :description
6
6
 
7
7
  def initialize(attributes = {})
8
8
  @name = attributes[:name]
9
9
  @period = attributes[:period]
10
10
  @values = attributes[:values].collect(&:with_indifferent_access)
11
+ @description = attributes[:description]
11
12
  end
12
13
  end
13
14
  end
data/lib/fb_graph/link.rb CHANGED
@@ -2,21 +2,25 @@ module FbGraph
2
2
  class Link < Node
3
3
  include Connections::Comments
4
4
 
5
- attr_accessor :from, :link, :message, :updated_time
5
+ attr_accessor :from, :link, :caption, :description, :icon, :picture, :message, :created_time
6
6
 
7
- def initialize(identifier, options = {})
7
+ def initialize(identifier, attributes = {})
8
8
  super
9
- if (from = options[:from])
9
+ if (from = attributes[:from])
10
10
  @from = if from[:category]
11
11
  FbGraph::Page.new(from.delete(:id), from)
12
12
  else
13
13
  FbGraph::User.new(from.delete(:id), from)
14
14
  end
15
15
  end
16
- @link = options[:link]
17
- @message = options[:message]
18
- if options[:updated_time]
19
- @updated_time = Time.parse(options[:updated_time]).utc
16
+ @link = attributes[:link]
17
+ @caption = attributes[:caption]
18
+ @description = attributes[:description]
19
+ @icon = attributes[:icon]
20
+ @picture = attributes[:picture]
21
+ @message = attributes[:message]
22
+ if attributes[:created_time]
23
+ @created_time = Time.parse(attributes[:created_time]).utc
20
24
  end
21
25
  end
22
26
  end
data/lib/fb_graph/note.rb CHANGED
@@ -1,26 +1,28 @@
1
1
  module FbGraph
2
2
  class Note < Node
3
3
  include Connections::Comments
4
+ include Connections::Likes
4
5
 
5
- attr_accessor :from, :subject, :message, :created_time, :updated_time
6
+ attr_accessor :from, :subject, :message, :created_time, :updated_time, :icon
6
7
 
7
- def initialize(identifier, options = {})
8
+ def initialize(identifier, attributes = {})
8
9
  super
9
- if (from = options[:from])
10
+ if (from = attributes[:from])
10
11
  @from = if from[:category]
11
12
  FbGraph::Page.new(from.delete(:id), from)
12
13
  else
13
14
  FbGraph::User.new(from.delete(:id), from)
14
15
  end
15
16
  end
16
- @subject = options[:subject]
17
- @message = options[:message]
18
- if options[:created_time]
19
- @created_time = Time.parse(options[:created_time]).utc
17
+ @subject = attributes[:subject]
18
+ @message = attributes[:message]
19
+ if attributes[:created_time]
20
+ @created_time = Time.parse(attributes[:created_time]).utc
20
21
  end
21
- if options[:updated_time]
22
- @updated_time = Time.parse(options[:updated_time]).utc
22
+ if attributes[:updated_time]
23
+ @updated_time = Time.parse(attributes[:updated_time]).utc
23
24
  end
25
+ @icon = attributes[:icon]
24
26
  end
25
27
  end
26
28
  end
data/lib/fb_graph/page.rb CHANGED
@@ -11,15 +11,24 @@ module FbGraph
11
11
  include Connections::Videos
12
12
  include Connections::Notes
13
13
  include Connections::Posts
14
+ include Connections::Members
14
15
  include Connections::Events
15
16
  extend Searchable
16
17
 
17
- attr_accessor :name, :category
18
+ attr_accessor :name, :link, :category, :founded, :company_overview, :mission, :products, :fan_count
18
19
 
19
- def initialize(identifier, options = {})
20
+ def initialize(identifier, attributes = {})
20
21
  super
21
- @name = options[:name]
22
- @category = options[:category]
22
+ @name = attributes[:name]
23
+ @link = attributes[:link]
24
+ @category = attributes[:category]
25
+ @founded = attributes[:founded]
26
+ @company_overview = attributes[:company_overview]
27
+ @mission = attributes[:mission]
28
+ if (products = attributes[:products])
29
+ @products = products.split "\n"
30
+ end
31
+ @fan_count = attributes[:fan_count]
23
32
  end
24
33
  end
25
34
  end
@@ -1,12 +1,13 @@
1
1
  module FbGraph
2
2
  class Photo < Node
3
3
  include Connections::Comments
4
+ include Connections::Likes
4
5
 
5
6
  attr_accessor :from, :tags, :name, :picture, :source, :height, :width, :link, :created_time, :updated_time
6
7
 
7
- def initialize(identifier, options = {})
8
+ def initialize(identifier, attributes = {})
8
9
  super
9
- if (from = options[:from])
10
+ if (from = attributes[:from])
10
11
  @from = if from[:category]
11
12
  FbGraph::Page.new(from.delete(:id), from)
12
13
  else
@@ -14,25 +15,25 @@ module FbGraph
14
15
  end
15
16
  end
16
17
  @tags = []
17
- if options[:tags]
18
- FbGraph::Collection.new(options[:tags]).each do |tag|
18
+ if attributes[:tags]
19
+ FbGraph::Collection.new(attributes[:tags]).each do |tag|
19
20
  @tags << FbGraph::Tag.new(tag.delete(:id), tag)
20
21
  end
21
22
  end
22
23
  # NOTE:
23
24
  # for some reason, facebook uses different parameter names.
24
25
  # "name" in GET & "message" in POST
25
- @name = options[:name] || options[:message]
26
- @picture = options[:picture]
27
- @source = options[:source]
28
- @height = options[:height]
29
- @width = options[:width]
30
- @link = options[:link]
31
- if options[:created_time]
32
- @created_time = Time.parse(options[:created_time]).utc
26
+ @name = attributes[:name] || attributes[:message]
27
+ @picture = attributes[:picture]
28
+ @source = attributes[:source]
29
+ @height = attributes[:height]
30
+ @width = attributes[:width]
31
+ @link = attributes[:link]
32
+ if attributes[:created_time]
33
+ @created_time = Time.parse(attributes[:created_time]).utc
33
34
  end
34
- if options[:updated_time]
35
- @updated_time = Time.parse(options[:updated_time]).utc
35
+ if attributes[:updated_time]
36
+ @updated_time = Time.parse(attributes[:updated_time]).utc
36
37
  end
37
38
  end
38
39
  end
data/lib/fb_graph/post.rb CHANGED
@@ -1,13 +1,14 @@
1
1
  module FbGraph
2
2
  class Post < Node
3
3
  include Connections::Comments
4
+ include Connections::Likes
4
5
  extend Searchable
5
6
 
6
7
  attr_accessor :from, :to, :message, :picture, :link, :name, :caption, :description, :source, :icon, :attribution, :actions, :likes, :created_time, :updated_time
7
8
 
8
- def initialize(identifier, options = {})
9
+ def initialize(identifier, attributes = {})
9
10
  super
10
- if (from = options[:from])
11
+ if (from = attributes[:from])
11
12
  @from = if from[:category]
12
13
  FbGraph::Page.new(from.delete(:id), from)
13
14
  else
@@ -15,8 +16,8 @@ module FbGraph
15
16
  end
16
17
  end
17
18
  @to = []
18
- if options[:to]
19
- FbGraph::Collection.new(options[:to]).each do |to|
19
+ if attributes[:to]
20
+ FbGraph::Collection.new(attributes[:to]).each do |to|
20
21
  @to << if to[:category]
21
22
  FbGraph::Page.new(to.delete(:id), to)
22
23
  else
@@ -24,26 +25,26 @@ module FbGraph
24
25
  end
25
26
  end
26
27
  end
27
- @message = options[:message]
28
- @picture = options[:picture]
29
- @link = options[:link]
30
- @name = options[:name]
31
- @caption = options[:caption]
32
- @description = options[:description]
33
- @source = options[:source]
34
- @icon = options[:icon]
35
- @attribution = options[:attribution]
36
- @actions = options[:actions]
37
- @likes = options[:likes]
38
- if options[:created_time]
39
- @created_time = Time.parse(options[:created_time]).utc
28
+ @message = attributes[:message]
29
+ @picture = attributes[:picture]
30
+ @link = attributes[:link]
31
+ @name = attributes[:name]
32
+ @caption = attributes[:caption]
33
+ @description = attributes[:description]
34
+ @source = attributes[:source]
35
+ @icon = attributes[:icon]
36
+ @attribution = attributes[:attribution]
37
+ @actions = attributes[:actions]
38
+ @likes = attributes[:likes]
39
+ if attributes[:created_time]
40
+ @created_time = Time.parse(attributes[:created_time]).utc
40
41
  end
41
- if options[:updated_time]
42
- @updated_time = Time.parse(options[:updated_time]).utc
42
+ if attributes[:updated_time]
43
+ @updated_time = Time.parse(attributes[:updated_time]).utc
43
44
  end
44
45
 
45
46
  # cached connection
46
- @_comments_ = FbGraph::Collection.new(options[:comments])
47
+ @_comments_ = FbGraph::Collection.new(attributes[:comments])
47
48
  end
48
49
  end
49
50
  end
@@ -0,0 +1,31 @@
1
+ module FbGraph
2
+ module Searchable
3
+ class Result < Collection
4
+ attr_accessor :query, :klass, :collection, :options
5
+
6
+ def initialize(query, klass, options = {})
7
+ @klass = klass
8
+ @query = query
9
+ @options = options
10
+ @collection = options.delete(:collection) || FbGraph::Collection.new
11
+ replace @collection
12
+ end
13
+
14
+ def next(_options_ = {})
15
+ if self.collection.next.present?
16
+ self.klass.search(self.query, self.options.merge(_options_).merge(self.collection.next))
17
+ else
18
+ self.class.new(self.query, self.klass)
19
+ end
20
+ end
21
+
22
+ def previous(_options_ = {})
23
+ if self.collection.previous.present?
24
+ self.klassf.search(self.query, self.options.merge(_options_).merge(self.collection.previous))
25
+ else
26
+ self.class.new(self.query, self.klass)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -19,33 +19,7 @@ module FbGraph
19
19
  end
20
20
  end
21
21
  end
22
-
23
- class Result < Collection
24
- attr_accessor :query, :klass, :collection, :options
25
-
26
- def initialize(query, klass, options = {})
27
- @klass = klass
28
- @query = query
29
- @options = options
30
- @collection = options.delete(:collection) || FbGraph::Collection.new
31
- replace @collection
32
- end
33
-
34
- def next(_options_ = {})
35
- if self.collection.next.present?
36
- self.klass.search(self.query, self.options.merge(_options_).merge(self.collection.next))
37
- else
38
- self.class.new(self.query, self.klass)
39
- end
40
- end
41
-
42
- def previous(_options_ = {})
43
- if self.collection.previous.present?
44
- self.klassf.search(self.query, self.options.merge(_options_).merge(self.collection.previous))
45
- else
46
- self.class.new(self.query, self.klass)
47
- end
48
- end
49
- end
50
22
  end
51
- end
23
+ end
24
+
25
+ require 'fb_graph/searchable/result'
@@ -1,6 +1,7 @@
1
1
  module FbGraph
2
2
  class Status < Node
3
3
  include Connections::Comments
4
+ include Connections::Likes
4
5
 
5
6
  attr_accessor :from, :message, :updated_time
6
7
 
@@ -0,0 +1,10 @@
1
+ module FbGraph
2
+ class Subscription < Node
3
+ attr_accessor :object, :fields, :callback_url, :active
4
+
5
+ def initialize(identifier, options = {})
6
+ super
7
+ # TODO
8
+ end
9
+ end
10
+ end
data/lib/fb_graph/user.rb CHANGED
@@ -21,6 +21,11 @@ module FbGraph
21
21
  include Connections::Links
22
22
  include Connections::Notes
23
23
  include Connections::Events
24
+ # TODO
25
+ # include Connections::Inbox
26
+ # include Connections::Outbox
27
+ # include Connections::Updates
28
+ # include Connections::Accounts
24
29
  extend Searchable
25
30
 
26
31
  # TODO:
@@ -28,7 +33,7 @@ module FbGraph
28
33
  # include Connections::Outbox
29
34
  # include Connections::Updates
30
35
 
31
- attr_accessor :first_name, :last_name, :name, :link, :about, :birthday, :work, :education, :email, :website, :hometown, :location, :gender, :interested_in, :meeting_for, :relationship_status, :religion, :political, :verified, :significant_other, :timezone, :updated_time
36
+ attr_accessor :first_name, :last_name, :name, :link, :about, :birthday, :work, :education, :email, :website, :hometown, :location, :bio, :quotes, :gender, :interested_in, :meeting_for, :relationship_status, :religion, :political, :verified, :significant_other, :timezone, :updated_time
32
37
 
33
38
  def initialize(identifier, options = {})
34
39
  super
@@ -62,6 +67,8 @@ module FbGraph
62
67
  if (location = options[:location])
63
68
  @location = FbGraph::Page.new(location.delete(:id), location)
64
69
  end
70
+ @bio = options[:bio]
71
+ @quotes = options[:quotes]
65
72
  @gender = options[:gender]
66
73
  @interested_in = Array(options[:interested_in])
67
74
  @meeting_for = Array(options[:meeting_for])
@@ -1,6 +1,7 @@
1
1
  module FbGraph
2
2
  class Video < Node
3
3
  include Connections::Comments
4
+ include Connections::Likes
4
5
 
5
6
  attr_accessor :from, :message, :description, :length, :created_time, :updated_time
6
7
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "19292868552",
3
3
  "name": "Facebook Platform",
4
- "picture": "http://profile.ak.fbcdn.net/object3/1566/8/s19292868552_1660.jpg",
4
+ "picture": "http://profile.ak.fbcdn.net/profile-ak-snc1/object3/1566/8/s19292868552_1660.jpg",
5
5
  "link": "http://www.facebook.com/platform",
6
6
  "category": "Technology",
7
7
  "username": "platform",
@@ -9,5 +9,5 @@
9
9
  "company_overview": "Facebook Platform enables anyone to build social applications on Facebook and the web.",
10
10
  "mission": "To make the web more open and social.",
11
11
  "products": "Facebook Application Programming Interface (API)\nFacebook Query Language (FQL)\nFacebook Markup Language (FBML)\nFacebook JavaScript (FBJS)\nFacebook Connect\n",
12
- "fan_count": 453163
12
+ "fan_count": 578214
13
13
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "19292868552",
3
3
  "name": "Facebook Platform",
4
- "picture": "http://profile.ak.fbcdn.net/object3/1566/8/s19292868552_1660.jpg",
4
+ "picture": "http://profile.ak.fbcdn.net/profile-ak-snc1/object3/1566/8/s19292868552_1660.jpg",
5
5
  "link": "http://www.facebook.com/platform",
6
6
  "category": "Technology",
7
7
  "username": "platform",
@@ -9,5 +9,5 @@
9
9
  "company_overview": "Facebook Platform enables anyone to build social applications on Facebook and the web.",
10
10
  "mission": "To make the web more open and social.",
11
11
  "products": "Facebook Application Programming Interface (API)\nFacebook Query Language (FQL)\nFacebook Markup Language (FBML)\nFacebook JavaScript (FBJS)\nFacebook Connect\n",
12
- "fan_count": 453163
12
+ "fan_count": 578214
13
13
  }
@@ -0,0 +1,23 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Application, '.new' do
4
+
5
+ it 'should setup all supported attributes' do
6
+ attributes = {
7
+ :id => '12345',
8
+ :name => 'FbGraph',
9
+ :description => 'Owsome Facebook Graph Wrapper',
10
+ :category => 'Programming',
11
+ :link => 'http://github.com/nov/fb_graph',
12
+ :secret => 'sec sec'
13
+ }
14
+ app = FbGraph::Application.new(attributes.delete(:id), attributes)
15
+ app.identifier.should == '12345'
16
+ app.name.should == 'FbGraph'
17
+ app.description.should == 'Owsome Facebook Graph Wrapper'
18
+ app.category.should == 'Programming'
19
+ app.link.should == 'http://github.com/nov/fb_graph'
20
+ app.secret.should == 'sec sec'
21
+ end
22
+
23
+ end
@@ -0,0 +1,35 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Auth, '.new' do
4
+
5
+ it 'should setup OAuth2::Client' do
6
+ auth = FbGraph::Auth.new('client_id', 'client_secret')
7
+ auth.client.should be_a(OAuth2::Client)
8
+ auth.client.id.should == 'client_id'
9
+ auth.client.secret.should == 'client_secret'
10
+ end
11
+
12
+ context 'when invalid cookie given' do
13
+ it 'should raise FbGraph::VerificationFailed' do
14
+ lambda do
15
+ FbGraph::Auth.new('client_id', 'client_secret', :cookie => 'invalid')
16
+ end.should raise_exception(FbGraph::Auth::VerificationFailed)
17
+ end
18
+ end
19
+
20
+ end
21
+
22
+ describe FbGraph::Auth, '.from_cookie' do
23
+ before do
24
+ @auth = FbGraph::Auth.new('client_id', 'client_secret')
25
+ end
26
+
27
+ context 'when invalid cookie given' do
28
+ it 'should raise FbGraph::VerificationFailed' do
29
+ lambda do
30
+ @auth.from_cookie('invalid')
31
+ end.should raise_exception(FbGraph::Auth::VerificationFailed)
32
+ end
33
+ end
34
+
35
+ end
@@ -28,6 +28,7 @@ context 'when included by FbGraph::User' do
28
28
  :name => 'モバイルアップロード',
29
29
  :link => 'http://www.facebook.com/album.php?aid=25463&id=579612276',
30
30
  :count => 3,
31
+ :privacy => 'everyone',
31
32
  :created_time => '2008-07-27T11:38:15+0000',
32
33
  :updated_time => '2009-02-07T16:09:53+0000'
33
34
  )
@@ -0,0 +1,17 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Insight, '.new' do
4
+
5
+ it 'should setup all supported attributes' do
6
+ attributes = {
7
+ :name => 'name_for_the_stats',
8
+ :period => 'day',
9
+ :values => [{'key1' => 'value2'}, {'key2' => 'value2'}]
10
+ }
11
+ insight = FbGraph::Insight.new(attributes)
12
+ insight.period.should == 'day'
13
+ insight.values.should == [{'key1' => 'value2'}, {'key2' => 'value2'}]
14
+ insight.values.first[:key1].should == 'value2'
15
+ end
16
+
17
+ end
@@ -11,14 +11,14 @@ describe FbGraph::Link, '.new' do
11
11
  },
12
12
  :link => 'http://www.facebook.com/link/12345',
13
13
  :message => 'check this out!',
14
- :updated_time => '2010-01-02T15:37:41+0000'
14
+ :created_time => '2010-01-02T15:37:41+0000'
15
15
  }
16
16
  link = FbGraph::Link.new(attributes.delete(:id), attributes)
17
17
  link.identifier.should == '12345'
18
18
  link.from.should == FbGraph::User.new('23456', :name => 'nov matake')
19
19
  link.link.should == 'http://www.facebook.com/link/12345'
20
20
  link.message.should == 'check this out!'
21
- link.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
21
+ link.created_time.should == Time.parse('2010-01-02T15:37:41+0000')
22
22
  end
23
23
 
24
24
  it 'should support page as from' do
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: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 0
10
- version: 0.7.0
9
+ - 1
10
+ version: 0.7.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - nov matake
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-13 00:00:00 +09:00
18
+ date: 2010-09-04 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -143,6 +143,7 @@ files:
143
143
  - lib/fb_graph/application.rb
144
144
  - lib/fb_graph/auth.rb
145
145
  - lib/fb_graph/auth/cookie.rb
146
+ - lib/fb_graph/checkin.rb
146
147
  - lib/fb_graph/collection.rb
147
148
  - lib/fb_graph/comment.rb
148
149
  - lib/fb_graph/comparison.rb
@@ -188,7 +189,9 @@ files:
188
189
  - lib/fb_graph/photo.rb
189
190
  - lib/fb_graph/post.rb
190
191
  - lib/fb_graph/searchable.rb
192
+ - lib/fb_graph/searchable/result.rb
191
193
  - lib/fb_graph/status.rb
194
+ - lib/fb_graph/subscription.rb
192
195
  - lib/fb_graph/tag.rb
193
196
  - lib/fb_graph/user.rb
194
197
  - lib/fb_graph/venue.rb
@@ -266,6 +269,8 @@ files:
266
269
  - spec/fake_json/users/television/matake_private.json
267
270
  - spec/fake_json/users/videos/kirk_private.json
268
271
  - spec/fb_graph/album_spec.rb
272
+ - spec/fb_graph/application_spec.rb
273
+ - spec/fb_graph/auth_spec.rb
269
274
  - spec/fb_graph/collection_spec.rb
270
275
  - spec/fb_graph/comment_spec.rb
271
276
  - spec/fb_graph/connection_spec.rb
@@ -300,6 +305,7 @@ files:
300
305
  - spec/fb_graph/education_spec.rb
301
306
  - spec/fb_graph/event_spec.rb
302
307
  - spec/fb_graph/group_spec.rb
308
+ - spec/fb_graph/insight_spec.rb
303
309
  - spec/fb_graph/link_spec.rb
304
310
  - spec/fb_graph/node_spec.rb
305
311
  - spec/fb_graph/note_spec.rb
@@ -351,6 +357,8 @@ specification_version: 3
351
357
  summary: A Ruby wrapper for Facebook Graph API
352
358
  test_files:
353
359
  - spec/fb_graph/album_spec.rb
360
+ - spec/fb_graph/application_spec.rb
361
+ - spec/fb_graph/auth_spec.rb
354
362
  - spec/fb_graph/collection_spec.rb
355
363
  - spec/fb_graph/comment_spec.rb
356
364
  - spec/fb_graph/connection_spec.rb
@@ -385,6 +393,7 @@ test_files:
385
393
  - spec/fb_graph/education_spec.rb
386
394
  - spec/fb_graph/event_spec.rb
387
395
  - spec/fb_graph/group_spec.rb
396
+ - spec/fb_graph/insight_spec.rb
388
397
  - spec/fb_graph/link_spec.rb
389
398
  - spec/fb_graph/node_spec.rb
390
399
  - spec/fb_graph/note_spec.rb