fb_graph 0.4.2 → 0.5.0

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.
Files changed (39) hide show
  1. data/VERSION +1 -1
  2. data/fb_graph.gemspec +5 -4
  3. data/lib/fb_graph/collection.rb +2 -5
  4. data/lib/fb_graph/connection.rb +28 -0
  5. data/lib/fb_graph/connections/activities.rb +1 -1
  6. data/lib/fb_graph/connections/albums.rb +1 -1
  7. data/lib/fb_graph/connections/attending.rb +1 -1
  8. data/lib/fb_graph/connections/books.rb +1 -1
  9. data/lib/fb_graph/connections/comments.rb +1 -1
  10. data/lib/fb_graph/connections/declined.rb +1 -1
  11. data/lib/fb_graph/connections/events.rb +1 -1
  12. data/lib/fb_graph/connections/feed.rb +1 -1
  13. data/lib/fb_graph/connections/friends.rb +1 -1
  14. data/lib/fb_graph/connections/groups.rb +1 -1
  15. data/lib/fb_graph/connections/home.rb +1 -1
  16. data/lib/fb_graph/connections/interests.rb +1 -1
  17. data/lib/fb_graph/connections/invited.rb +1 -1
  18. data/lib/fb_graph/connections/likes.rb +1 -1
  19. data/lib/fb_graph/connections/links.rb +1 -1
  20. data/lib/fb_graph/connections/maybe.rb +1 -1
  21. data/lib/fb_graph/connections/members.rb +1 -1
  22. data/lib/fb_graph/connections/movies.rb +1 -1
  23. data/lib/fb_graph/connections/music.rb +1 -1
  24. data/lib/fb_graph/connections/noreply.rb +1 -1
  25. data/lib/fb_graph/connections/notes.rb +1 -1
  26. data/lib/fb_graph/connections/photos.rb +1 -1
  27. data/lib/fb_graph/connections/posts.rb +1 -1
  28. data/lib/fb_graph/connections/statuses.rb +1 -1
  29. data/lib/fb_graph/connections/tagged.rb +1 -1
  30. data/lib/fb_graph/connections/television.rb +1 -1
  31. data/lib/fb_graph/connections/videos.rb +1 -1
  32. data/lib/fb_graph/node.rb +9 -4
  33. data/lib/fb_graph.rb +15 -7
  34. data/spec/fb_graph/collection_spec.rb +1 -23
  35. data/spec/fb_graph/connection_spec.rb +38 -0
  36. data/spec/fb_graph/connections/activities_spec.rb +1 -0
  37. data/spec/fb_graph/connections/events_spec.rb +0 -1
  38. metadata +7 -6
  39. data/spec/fb_graph_spec.rb +0 -13
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.5.0
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.4.2"
8
+ s.version = "0.5.0"
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-05}
12
+ s.date = %q{2010-08-07}
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 = [
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
33
33
  "lib/fb_graph/collection.rb",
34
34
  "lib/fb_graph/comment.rb",
35
35
  "lib/fb_graph/comparison.rb",
36
+ "lib/fb_graph/connection.rb",
36
37
  "lib/fb_graph/connections.rb",
37
38
  "lib/fb_graph/connections/activities.rb",
38
39
  "lib/fb_graph/connections/albums.rb",
@@ -151,6 +152,7 @@ Gem::Specification.new do |s|
151
152
  "spec/fb_graph/album_spec.rb",
152
153
  "spec/fb_graph/collection_spec.rb",
153
154
  "spec/fb_graph/comment_spec.rb",
155
+ "spec/fb_graph/connection_spec.rb",
154
156
  "spec/fb_graph/connections/activities_spec.rb",
155
157
  "spec/fb_graph/connections/albums_spec.rb",
156
158
  "spec/fb_graph/connections/attending_spec.rb",
@@ -194,7 +196,6 @@ Gem::Specification.new do |s|
194
196
  "spec/fb_graph/venue_spec.rb",
195
197
  "spec/fb_graph/video_spec.rb",
196
198
  "spec/fb_graph/work_spec.rb",
197
- "spec/fb_graph_spec.rb",
198
199
  "spec/helpers/fake_json_helper.rb",
199
200
  "spec/spec.opts",
200
201
  "spec/spec_helper.rb"
@@ -208,6 +209,7 @@ Gem::Specification.new do |s|
208
209
  "spec/fb_graph/album_spec.rb",
209
210
  "spec/fb_graph/collection_spec.rb",
210
211
  "spec/fb_graph/comment_spec.rb",
212
+ "spec/fb_graph/connection_spec.rb",
211
213
  "spec/fb_graph/connections/activities_spec.rb",
212
214
  "spec/fb_graph/connections/albums_spec.rb",
213
215
  "spec/fb_graph/connections/attending_spec.rb",
@@ -251,7 +253,6 @@ Gem::Specification.new do |s|
251
253
  "spec/fb_graph/venue_spec.rb",
252
254
  "spec/fb_graph/video_spec.rb",
253
255
  "spec/fb_graph/work_spec.rb",
254
- "spec/fb_graph_spec.rb",
255
256
  "spec/helpers/fake_json_helper.rb",
256
257
  "spec/spec_helper.rb"
257
258
  ]
@@ -2,11 +2,8 @@ module FbGraph
2
2
  class Collection < Array
3
3
  attr_reader :previous, :next
4
4
 
5
- def initialize(collection)
6
- # allow nil input
7
- collection ||= {}
8
- collection[:data] ||= []
9
-
5
+ def initialize(collection = nil)
6
+ collection ||= {:data => []}
10
7
  result = replace(collection[:data])
11
8
  @previous, @next = {}, {}
12
9
  if (paging = collection[:paging])
@@ -0,0 +1,28 @@
1
+ module FbGraph
2
+ class Connection < Collection
3
+ attr_accessor :collection, :connection, :owner
4
+
5
+ def initialize(owner, connection, collection = FbGraph::Collection.new)
6
+ @owner = owner
7
+ @connection = connection
8
+ @collection = collection
9
+ replace collection
10
+ end
11
+
12
+ def next(options = {})
13
+ if self.collection.next.present?
14
+ self.owner.send(self.connection, options.merge(self.collection.next))
15
+ else
16
+ self.class.new(self.owner, self.connection)
17
+ end
18
+ end
19
+
20
+ def previous(options = {})
21
+ if self.collection.previous.present?
22
+ self.owner.send(self.connection, options.merge(self.collection.previous))
23
+ else
24
+ self.class.new(self.owner, self.connection)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Activities
4
4
  def activities(options = {})
5
- activities = FbGraph::Collection.new(get(options.merge(:connection => 'activities')))
5
+ activities = self.connection(:activities, options)
6
6
  activities.map! do |activity|
7
7
  FbGraph::Page.new(activity.delete(:id), activity.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Albums
4
4
  def albums(options = {})
5
- albums = FbGraph::Collection.new(get(options.merge(:connection => 'albums')))
5
+ albums = self.connection(:albums, options)
6
6
  albums.map! do |album|
7
7
  Album.new(album.delete(:id), album.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Attending
4
4
  def attending(options = {})
5
- members = FbGraph::Collection.new(get(options.merge(:connection => 'attending')))
5
+ members = self.connection(:attending, options)
6
6
  members.map! do |member|
7
7
  User.new(member.delete(:id), member.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Books
4
4
  def books(options = {})
5
- books = FbGraph::Collection.new(get(options.merge(:connection => 'books')))
5
+ books = self.connection(:books, options)
6
6
  books.map! do |book|
7
7
  Page.new(book.delete(:id), book.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -8,7 +8,7 @@ module FbGraph
8
8
  # this improves performance when rendering the stream with comments
9
9
  @_comments_
10
10
  else
11
- FbGraph::Collection.new(get(options.merge(:connection => 'comments')))
11
+ self.connection(:comments, options)
12
12
  end
13
13
  comments.map! do |comment|
14
14
  Comment.new(comment.delete(:id), comment.merge(
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Declined
4
4
  def declined(options = {})
5
- members = FbGraph::Collection.new(get(options.merge(:connection => 'declined')))
5
+ members = self.connection(:declined, options)
6
6
  members.map! do |member|
7
7
  User.new(member.delete(:id), member.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Events
4
4
  def events(options = {})
5
- events = FbGraph::Collection.new(get(options.merge(:connection => 'events')))
5
+ events = self.connection(:events, options)
6
6
  events.map! do |event|
7
7
  Event.new(event.delete(:id), event.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Feed
4
4
  def feed(options = {})
5
- posts = FbGraph::Collection.new(get(options.merge(:connection => 'feed')))
5
+ posts = self.connection(:feed, options)
6
6
  posts.map! do |post|
7
7
  Post.new(post.delete(:id), post.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Friends
4
4
  def friends(options = {})
5
- users = FbGraph::Collection.new(get(options.merge(:connection => 'friends')))
5
+ users = self.connection(:friends, options)
6
6
  users.map! do |user|
7
7
  User.new(user.delete(:id), user.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Groups
4
4
  def groups(options = {})
5
- groups = FbGraph::Collection.new(get(options.merge(:connection => 'groups')))
5
+ groups = self.connection(:groups, options)
6
6
  groups.map! do |group|
7
7
  Group.new(group.delete(:id), group.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Home
4
4
  def home(options = {})
5
- posts = FbGraph::Collection.new(get(options.merge(:connection => 'home')))
5
+ posts = self.connection(:home, options)
6
6
  posts.map! do |post|
7
7
  Post.new(post.delete(:id), post.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Interests
4
4
  def interests(options = {})
5
- interests = FbGraph::Collection.new(get(options.merge(:connection => 'interests')))
5
+ interests = self.connection(:interests, options)
6
6
  interests.map! do |interest|
7
7
  Page.new(interest.delete(:id), interest.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Invited
4
4
  def invited(options = {})
5
- members = FbGraph::Collection.new(get(options.merge(:connection => 'invited')))
5
+ members = self.connection(:invited, options)
6
6
  members.map! do |member|
7
7
  User.new(member.delete(:id), member.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Likes
4
4
  def likes(options = {})
5
- likes = FbGraph::Collection.new(get(options.merge(:connection => 'likes')))
5
+ likes = self.connection(:likes, options)
6
6
  likes.map! do |like|
7
7
  Page.new(like.delete(:id), like.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Links
4
4
  def links(options = {})
5
- links = FbGraph::Collection.new(get(options.merge(:connection => 'links')))
5
+ links = self.connection(:links, options)
6
6
  links.map! do |link|
7
7
  Link.new(link.delete(:id), link.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Maybe
4
4
  def maybe(options = {})
5
- members = FbGraph::Collection.new(get(options.merge(:connection => 'maybe')))
5
+ members = self.connection(:maybe, options)
6
6
  members.map! do |member|
7
7
  User.new(member.delete(:id), member.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Members
4
4
  def members(options = {})
5
- members = FbGraph::Collection.new(get(options.merge(:connection => 'members')))
5
+ members = self.connection(:members, options)
6
6
  members.map! do |member|
7
7
  User.new(member.delete(:id), member.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Movies
4
4
  def movies(options = {})
5
- movies = FbGraph::Collection.new(get(options.merge(:connection => 'movies')))
5
+ movies = self.connection(:movies, options)
6
6
  movies.map! do |movie|
7
7
  Page.new(movie.delete(:id), movie.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Music
4
4
  def music(options = {})
5
- music = FbGraph::Collection.new(get(options.merge(:connection => 'music')))
5
+ music = self.connection(:music, options)
6
6
  music.map! do |_music_|
7
7
  Page.new(_music_.delete(:id), _music_.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Noreply
4
4
  def noreply(options = {})
5
- members = FbGraph::Collection.new(get(options.merge(:connection => 'noreply')))
5
+ members = self.connection(:noreply, options)
6
6
  members.map! do |member|
7
7
  User.new(member.delete(:id), member.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Notes
4
4
  def notes(options = {})
5
- notes = FbGraph::Collection.new(get(options.merge(:connection => 'notes')))
5
+ notes = self.connection(:notes, options)
6
6
  notes.map! do |note|
7
7
  Note.new(note.delete(:id), note.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Photos
4
4
  def photos(options = {})
5
- photos = FbGraph::Collection.new(get(options.merge(:connection => 'photos')))
5
+ photos = self.connection(:photos, options)
6
6
  photos.map! do |photo|
7
7
  Photo.new(photo.delete(:id), photo.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Posts
4
4
  def posts(options = {})
5
- posts = FbGraph::Collection.new(get(options.merge(:connection => 'posts')))
5
+ posts = self.connection(:posts, options)
6
6
  posts.map! do |post|
7
7
  Post.new(post.delete(:id), post.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Statuses
4
4
  def statuses(options = {})
5
- statuses = FbGraph::Collection.new(get(options.merge(:connection => 'statuses')))
5
+ statuses = self.connection(:statuses, options)
6
6
  statuses.map! do |status|
7
7
  Status.new(status.delete(:id), status.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Tagged
4
4
  def tagged(options = {})
5
- posts = FbGraph::Collection.new(get(options.merge(:connection => 'tagged')))
5
+ posts = self.connection(:tagged, options)
6
6
  posts.map! do |post|
7
7
  Post.new(post.delete(:id), post.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Television
4
4
  def television(options = {})
5
- television = FbGraph::Collection.new(get(options.merge(:connection => 'television')))
5
+ television = self.connection(:television, options)
6
6
  television.map! do |_television_|
7
7
  Page.new(_television_.delete(:id), _television_.merge(
8
8
  :access_token => options[:access_token] || self.access_token
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Videos
4
4
  def videos(options = {})
5
- videos = FbGraph::Collection.new(get(options.merge(:connection => 'videos')))
5
+ videos = self.connection(:videos, options)
6
6
  videos.map! do |video|
7
7
  Video.new(video.delete(:id), video.merge(
8
8
  :access_token => options[:access_token] || self.access_token
data/lib/fb_graph/node.rb CHANGED
@@ -20,6 +20,11 @@ module FbGraph
20
20
  new(identifier).fetch(options)
21
21
  end
22
22
 
23
+ def connection(connection, options = {})
24
+ collection = FbGraph::Collection.new(get(options.merge(:connection => connection)))
25
+ Connection.new(self, connection, collection)
26
+ end
27
+
23
28
  def destroy(options = {})
24
29
  options[:access_token] ||= self.access_token if self.access_token
25
30
  delete(options)
@@ -58,7 +63,7 @@ module FbGraph
58
63
 
59
64
  def build_endpoint(params = {})
60
65
  _endpoint_ = if params[:connection]
61
- File.join(self.endpoint, params.delete(:connection))
66
+ File.join(self.endpoint, params.delete(:connection).to_s)
62
67
  else
63
68
  self.endpoint
64
69
  end
@@ -93,15 +98,15 @@ module FbGraph
93
98
  # This is an undocumented behaviour, so facebook might chaange it without any announcement.
94
99
  # I've posted this issue on their forum, so hopefully I'll get a document about Graph API error responses.
95
100
  # ref) http://forum.developers.facebook.com/viewtopic.php?pid=228256#p228256
96
- raise FbGraph::NotFound.new(404, 'Graph API returned false, so probably it means your requested object is not found.')
101
+ raise FbGraph::NotFound.new('Graph API returned false, so probably it means your requested object is not found.')
97
102
  else
98
103
  _response_ = JSON.parse(response.body).with_indifferent_access
99
104
  if _response_[:error]
100
105
  case _response_[:error][:type]
101
106
  when 'OAuthAccessTokenException', 'QueryParseException'
102
- raise FbGraph::Unauthorized.new(401, _response_[:error][:message])
107
+ raise FbGraph::Unauthorized.new(_response_[:error][:message])
103
108
  else
104
- raise FbGraph::Exception.new(400, "#{_response_[:error][:type]} :: #{_response_[:error][:message]}")
109
+ raise FbGraph::BadRequest.new("#{_response_[:error][:type]} :: #{_response_[:error][:message]}")
105
110
  end
106
111
  else
107
112
  _response_
data/lib/fb_graph.rb CHANGED
@@ -24,15 +24,22 @@ module FbGraph
24
24
  end
25
25
  end
26
26
  end
27
- class Unauthorized < FbGraph::Exception; end
28
- class NotFound < FbGraph::Exception; end
29
27
 
30
- class << self
31
- def node(identifier, options = {})
32
- Node.new(identifier, options)
28
+ class BadRequest < FbGraph::Exception
29
+ def initialize(message, body = '')
30
+ super 400, message, body
33
31
  end
34
- def user(identifier, options = {})
35
- User.new(identifier, options)
32
+ end
33
+
34
+ class Unauthorized < FbGraph::Exception
35
+ def initialize(message, body = '')
36
+ super 401, message, body
37
+ end
38
+ end
39
+
40
+ class NotFound < FbGraph::Exception
41
+ def initialize(message, body = '')
42
+ super 404, message, body
36
43
  end
37
44
  end
38
45
 
@@ -41,6 +48,7 @@ end
41
48
  require 'fb_graph/auth'
42
49
  require 'fb_graph/comparison'
43
50
  require 'fb_graph/collection'
51
+ require 'fb_graph/connection'
44
52
  require 'fb_graph/connections'
45
53
 
46
54
  require 'fb_graph/node'
@@ -6,31 +6,9 @@ describe FbGraph::Collection, '.new' do
6
6
  end
7
7
 
8
8
  it 'should return an array with pagination info' do
9
- statuses = FbGraph::Page.new('platform', :access_token => 'access_token').statuses
9
+ statuses = FbGraph::Page.new('platform', :access_token => 'access_token').statuses.collection
10
10
  statuses.should be_kind_of(Array)
11
11
  statuses.previous.should be_kind_of(Hash)
12
12
  statuses.next.should be_kind_of(Hash)
13
13
  end
14
- end
15
-
16
- describe FbGraph::Collection do
17
- before(:all) do
18
- fake_json(:get, 'me/home?access_token=access_token', 'users/home/me_private')
19
- fake_json(:get, 'me/home?limit=25&since=2010-04-27T13%3A06%3A14%2B0000&access_token=access_token', 'users/home/me_private_previous')
20
- fake_json(:get, 'me/home?limit=25&access_token=access_token&until=2010-04-27T11%3A07%3A48%2B0000', 'users/home/me_private_next')
21
- end
22
-
23
- it 'should be useful for pagenation' do
24
- me = FbGraph::User.new('me', :access_token => 'access_token')
25
- posts = me.home
26
- posts.first.created_time.should == Time.parse('2010-04-27T13:06:14+0000')
27
- posts.last.created_time.should == Time.parse('2010-04-27T11:07:48+0000')
28
- previous_posts = me.home(posts.previous)
29
- previous_posts.first.created_time.should == Time.parse('2010-04-27T13:23:08+0000')
30
- previous_posts.last.created_time.should == Time.parse('2010-04-27T13:10:56+0000')
31
- next_posts = me.home(posts.next)
32
- next_posts.first.created_time.should == Time.parse('2010-04-27T11:06:29+0000')
33
- next_posts.last.created_time.should == Time.parse('2010-04-27T09:44:28+0000')
34
- end
35
-
36
14
  end
@@ -0,0 +1,38 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Connection, '.new' do
4
+ before(:all) do
5
+ fake_json(:get, 'platform/statuses?access_token=access_token', 'pages/statuses/platform_private')
6
+ end
7
+
8
+ it 'should return an array with connection info' do
9
+ page = FbGraph::Page.new('platform', :access_token => 'access_token')
10
+ statuses = page.statuses
11
+ statuses.should be_kind_of(Array)
12
+ statuses.collection.should be_kind_of(FbGraph::Collection)
13
+ statuses.owner.should == page
14
+ statuses.connection.should == :statuses
15
+ end
16
+ end
17
+
18
+ describe FbGraph::Connection do
19
+ before(:all) do
20
+ fake_json(:get, 'me/home?access_token=access_token', 'users/home/me_private')
21
+ fake_json(:get, 'me/home?limit=25&since=2010-04-27T13%3A06%3A14%2B0000&access_token=access_token', 'users/home/me_private_previous')
22
+ fake_json(:get, 'me/home?limit=25&access_token=access_token&until=2010-04-27T11%3A07%3A48%2B0000', 'users/home/me_private_next')
23
+ end
24
+
25
+ it 'should be useful for pagenation' do
26
+ me = FbGraph::User.new('me', :access_token => 'access_token')
27
+ posts = me.home
28
+ posts.first.created_time.should == Time.parse('2010-04-27T13:06:14+0000')
29
+ posts.last.created_time.should == Time.parse('2010-04-27T11:07:48+0000')
30
+ previous_posts = posts.previous
31
+ previous_posts.first.created_time.should == Time.parse('2010-04-27T13:23:08+0000')
32
+ previous_posts.last.created_time.should == Time.parse('2010-04-27T13:10:56+0000')
33
+ next_posts = posts.next
34
+ next_posts.first.created_time.should == Time.parse('2010-04-27T11:06:29+0000')
35
+ next_posts.last.created_time.should == Time.parse('2010-04-27T09:44:28+0000')
36
+ end
37
+
38
+ end
@@ -18,6 +18,7 @@ context 'when included by FbGraph::User' do
18
18
  context 'when access_token is given' do
19
19
  it 'should return activities as FbGraph::Page' do
20
20
  activities = FbGraph::User.new('arjun', :access_token => 'access_token').activities
21
+ activities.class.should == FbGraph::Connection
21
22
  activities.first.should == FbGraph::Page.new(
22
23
  '378209722137',
23
24
  :access_token => 'access_token',
@@ -39,7 +39,6 @@ context 'when included by FbGraph::User' do
39
39
  end
40
40
 
41
41
  it 'should return generated note' do
42
- puts Time.utc(2010,5,11,9,0).to_i
43
42
  event = FbGraph::User.new('matake', :access_token => 'valid').event!(
44
43
  :name => 'FbGraph test event',
45
44
  :start_time => Time.utc(2010, 5, 11, 10, 0, 0).to_i,
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 4
8
- - 2
9
- version: 0.4.2
7
+ - 5
8
+ - 0
9
+ version: 0.5.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - nov matake
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-05 00:00:00 +09:00
17
+ date: 2010-08-07 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -130,6 +130,7 @@ files:
130
130
  - lib/fb_graph/collection.rb
131
131
  - lib/fb_graph/comment.rb
132
132
  - lib/fb_graph/comparison.rb
133
+ - lib/fb_graph/connection.rb
133
134
  - lib/fb_graph/connections.rb
134
135
  - lib/fb_graph/connections/activities.rb
135
136
  - lib/fb_graph/connections/albums.rb
@@ -248,6 +249,7 @@ files:
248
249
  - spec/fb_graph/album_spec.rb
249
250
  - spec/fb_graph/collection_spec.rb
250
251
  - spec/fb_graph/comment_spec.rb
252
+ - spec/fb_graph/connection_spec.rb
251
253
  - spec/fb_graph/connections/activities_spec.rb
252
254
  - spec/fb_graph/connections/albums_spec.rb
253
255
  - spec/fb_graph/connections/attending_spec.rb
@@ -291,7 +293,6 @@ files:
291
293
  - spec/fb_graph/venue_spec.rb
292
294
  - spec/fb_graph/video_spec.rb
293
295
  - spec/fb_graph/work_spec.rb
294
- - spec/fb_graph_spec.rb
295
296
  - spec/helpers/fake_json_helper.rb
296
297
  - spec/spec.opts
297
298
  - spec/spec_helper.rb
@@ -329,6 +330,7 @@ test_files:
329
330
  - spec/fb_graph/album_spec.rb
330
331
  - spec/fb_graph/collection_spec.rb
331
332
  - spec/fb_graph/comment_spec.rb
333
+ - spec/fb_graph/connection_spec.rb
332
334
  - spec/fb_graph/connections/activities_spec.rb
333
335
  - spec/fb_graph/connections/albums_spec.rb
334
336
  - spec/fb_graph/connections/attending_spec.rb
@@ -372,6 +374,5 @@ test_files:
372
374
  - spec/fb_graph/venue_spec.rb
373
375
  - spec/fb_graph/video_spec.rb
374
376
  - spec/fb_graph/work_spec.rb
375
- - spec/fb_graph_spec.rb
376
377
  - spec/helpers/fake_json_helper.rb
377
378
  - spec/spec_helper.rb
@@ -1,13 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'spec_helper')
2
-
3
- describe FbGraph, '#node' do
4
- it "should return FbGraph::Node instance" do
5
- FbGraph.node('matake').should == FbGraph::Node.new('matake')
6
- end
7
- end
8
-
9
- describe FbGraph, '#user' do
10
- it "should return FbGraph::User instance" do
11
- FbGraph.user('matake').should == FbGraph::User.new('matake')
12
- end
13
- end