fb_graph 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/README.rdoc +26 -2
  2. data/VERSION +1 -1
  3. data/fb_graph.gemspec +41 -6
  4. data/lib/fb_graph/album.rb +1 -1
  5. data/lib/fb_graph/collection.rb +32 -0
  6. data/lib/fb_graph/comparison.rb +9 -0
  7. data/lib/fb_graph/connections/activities.rb +1 -1
  8. data/lib/fb_graph/connections/albums.rb +1 -1
  9. data/lib/fb_graph/connections/attending.rb +1 -1
  10. data/lib/fb_graph/connections/books.rb +1 -1
  11. data/lib/fb_graph/connections/comments.rb +1 -1
  12. data/lib/fb_graph/connections/declined.rb +1 -1
  13. data/lib/fb_graph/connections/events.rb +1 -1
  14. data/lib/fb_graph/connections/feed.rb +1 -1
  15. data/lib/fb_graph/connections/friends.rb +1 -1
  16. data/lib/fb_graph/connections/groups.rb +1 -1
  17. data/lib/fb_graph/connections/home.rb +1 -1
  18. data/lib/fb_graph/connections/interests.rb +1 -1
  19. data/lib/fb_graph/connections/invited.rb +1 -1
  20. data/lib/fb_graph/connections/likes.rb +1 -1
  21. data/lib/fb_graph/connections/links.rb +1 -1
  22. data/lib/fb_graph/connections/maybe.rb +1 -1
  23. data/lib/fb_graph/connections/members.rb +1 -1
  24. data/lib/fb_graph/connections/movies.rb +1 -1
  25. data/lib/fb_graph/connections/music.rb +1 -1
  26. data/lib/fb_graph/connections/noreply.rb +1 -1
  27. data/lib/fb_graph/connections/notes.rb +1 -1
  28. data/lib/fb_graph/connections/photos.rb +1 -1
  29. data/lib/fb_graph/connections/posts.rb +1 -1
  30. data/lib/fb_graph/connections/statuses.rb +1 -1
  31. data/lib/fb_graph/connections/tagged.rb +1 -1
  32. data/lib/fb_graph/connections/television.rb +1 -1
  33. data/lib/fb_graph/connections/videos.rb +1 -1
  34. data/lib/fb_graph/event.rb +3 -1
  35. data/lib/fb_graph/group.rb +4 -3
  36. data/lib/fb_graph/link.rb +1 -1
  37. data/lib/fb_graph/node.rb +6 -10
  38. data/lib/fb_graph/photo.rb +2 -12
  39. data/lib/fb_graph/post.rb +1 -1
  40. data/lib/fb_graph/tag.rb +14 -0
  41. data/lib/fb_graph/user.rb +2 -2
  42. data/lib/fb_graph/venue.rb +17 -0
  43. data/lib/fb_graph.rb +8 -1
  44. data/spec/fake_json/users/albums/matake_private.json +34 -0
  45. data/spec/fake_json/users/albums/matake_public.json +6 -0
  46. data/spec/fake_json/users/events/matake_private.json +71 -0
  47. data/spec/fake_json/users/events/matake_public.json +6 -0
  48. data/spec/fake_json/users/groups/matake_private.json +48 -0
  49. data/spec/fake_json/users/groups/matake_public.json +6 -0
  50. data/spec/fake_json/users/home/me_private.json +208 -131
  51. data/spec/fake_json/users/home/me_private_next.json +382 -0
  52. data/spec/fake_json/users/home/me_private_previous.json +36 -0
  53. data/spec/fb_graph/album_spec.rb +41 -0
  54. data/spec/fb_graph/collection_spec.rb +37 -0
  55. data/spec/fb_graph/connections/activities_spec.rb +4 -4
  56. data/spec/fb_graph/connections/albums_spec.rb +35 -0
  57. data/spec/fb_graph/connections/events_spec.rb +31 -0
  58. data/spec/fb_graph/connections/feed_spec.rb +2 -2
  59. data/spec/fb_graph/connections/friends_spec.rb +7 -7
  60. data/spec/fb_graph/connections/groups_spec.rb +28 -0
  61. data/spec/fb_graph/connections/home_spec.rb +13 -13
  62. data/spec/fb_graph/connections/likes_spec.rb +3 -3
  63. data/spec/fb_graph/connections/posts_spec.rb +2 -2
  64. data/spec/fb_graph/connections/statuses_spec.rb +6 -6
  65. data/spec/fb_graph/connections/tagged_spec.rb +2 -2
  66. data/spec/fb_graph/event_spec.rb +50 -0
  67. data/spec/fb_graph/group_spec.rb +46 -0
  68. data/spec/fb_graph/link_spec.rb +33 -0
  69. data/spec/fb_graph/node_spec.rb +3 -3
  70. data/spec/fb_graph/note_spec.rb +35 -0
  71. data/spec/fb_graph/page_spec.rb +3 -3
  72. data/spec/fb_graph/photo_spec.rb +58 -0
  73. data/spec/fb_graph/post_spec.rb +6 -0
  74. data/spec/fb_graph/status_spec.rb +31 -0
  75. data/spec/fb_graph/user_spec.rb +6 -6
  76. data/spec/fb_graph/video_spec.rb +37 -0
  77. metadata +41 -6
  78. data/lib/fb_graph/connections/collection.rb +0 -31
  79. data/spec/fb_graph/connections/collection_spec.rb +0 -15
data/README.rdoc CHANGED
@@ -1,6 +1,30 @@
1
- = fb_graph
1
+ = FbGraph
2
2
 
3
- Description goes here.
3
+ A Ruby wrapper for Facebook Graph API.
4
+ This is a work in progress.
5
+
6
+ == Examples
7
+
8
+ # Basic Objects
9
+ user = FbGraph::User.fetch('matake')
10
+ user.name # => 'Nov Matake'
11
+ user.picture # => 'https://graph.facebook.com/matake/picture'
12
+
13
+ page = FbGraph::Page.fetch('smartfmteam')
14
+ page.name # => 'smart.fm'
15
+ page.picture # => 'https://graph.facebook.com/smart.fm/picture'
16
+
17
+ :
18
+ :
19
+
20
+ # Connections
21
+ likes = user.likes # => Array of FbGraph::Like
22
+ likes.next # => {:limit => 25, :until => '...'}
23
+ likes.previous # => {:limit => 25, :since => '...'}
24
+
25
+ # Pagination
26
+ user.likes(likes.next) # => Array of FbGraph::Like
27
+ user.likes(likes.previous) # => Array of FbGraph::Like
4
28
 
5
29
  == Note on Patches/Pull Requests
6
30
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
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.0.2"
8
+ s.version = "0.0.3"
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-04-26}
12
+ s.date = %q{2010-04-27}
13
13
  s.description = %q{Facebook Graph API library for Ruby}
14
14
  s.email = %q{nov@matake.jp}
15
15
  s.extra_rdoc_files = [
@@ -26,13 +26,14 @@ Gem::Specification.new do |s|
26
26
  "fb_graph.gemspec",
27
27
  "lib/fb_graph.rb",
28
28
  "lib/fb_graph/album.rb",
29
+ "lib/fb_graph/collection.rb",
29
30
  "lib/fb_graph/comment.rb",
31
+ "lib/fb_graph/comparison.rb",
30
32
  "lib/fb_graph/connections.rb",
31
33
  "lib/fb_graph/connections/activities.rb",
32
34
  "lib/fb_graph/connections/albums.rb",
33
35
  "lib/fb_graph/connections/attending.rb",
34
36
  "lib/fb_graph/connections/books.rb",
35
- "lib/fb_graph/connections/collection.rb",
36
37
  "lib/fb_graph/connections/comments.rb",
37
38
  "lib/fb_graph/connections/declined.rb",
38
39
  "lib/fb_graph/connections/events.rb",
@@ -66,7 +67,9 @@ Gem::Specification.new do |s|
66
67
  "lib/fb_graph/photo.rb",
67
68
  "lib/fb_graph/post.rb",
68
69
  "lib/fb_graph/status.rb",
70
+ "lib/fb_graph/tag.rb",
69
71
  "lib/fb_graph/user.rb",
72
+ "lib/fb_graph/venue.rb",
70
73
  "lib/fb_graph/video.rb",
71
74
  "spec/fake_json/pages/platform_private.json",
72
75
  "spec/fake_json/pages/platform_public.json",
@@ -74,17 +77,25 @@ Gem::Specification.new do |s|
74
77
  "spec/fake_json/pages/statuses/platform_public.json",
75
78
  "spec/fake_json/users/activities/arjun_private.json",
76
79
  "spec/fake_json/users/activities/arjun_public.json",
80
+ "spec/fake_json/users/albums/matake_private.json",
81
+ "spec/fake_json/users/albums/matake_public.json",
77
82
  "spec/fake_json/users/arjun_private.json",
78
83
  "spec/fake_json/users/arjun_public.json",
84
+ "spec/fake_json/users/events/matake_private.json",
85
+ "spec/fake_json/users/events/matake_public.json",
79
86
  "spec/fake_json/users/feed/arjun_private.json",
80
87
  "spec/fake_json/users/feed/arjun_public.json",
81
88
  "spec/fake_json/users/friends/arjun_private.json",
82
89
  "spec/fake_json/users/friends/arjun_public.json",
83
90
  "spec/fake_json/users/friends/me_private.json",
84
91
  "spec/fake_json/users/friends/me_public.json",
92
+ "spec/fake_json/users/groups/matake_private.json",
93
+ "spec/fake_json/users/groups/matake_public.json",
85
94
  "spec/fake_json/users/home/arjun_private.json",
86
95
  "spec/fake_json/users/home/arjun_public.json",
87
96
  "spec/fake_json/users/home/me_private.json",
97
+ "spec/fake_json/users/home/me_private_next.json",
98
+ "spec/fake_json/users/home/me_private_previous.json",
88
99
  "spec/fake_json/users/home/me_public.json",
89
100
  "spec/fake_json/users/likes/arjun_private.json",
90
101
  "spec/fake_json/users/likes/arjun_public.json",
@@ -94,19 +105,31 @@ Gem::Specification.new do |s|
94
105
  "spec/fake_json/users/statuses/arjun_public.json",
95
106
  "spec/fake_json/users/tagged/arjun_private.json",
96
107
  "spec/fake_json/users/tagged/arjun_public.json",
108
+ "spec/fb_graph/album_spec.rb",
109
+ "spec/fb_graph/collection_spec.rb",
97
110
  "spec/fb_graph/connections/activities_spec.rb",
98
- "spec/fb_graph/connections/collection_spec.rb",
111
+ "spec/fb_graph/connections/albums_spec.rb",
112
+ "spec/fb_graph/connections/events_spec.rb",
99
113
  "spec/fb_graph/connections/feed_spec.rb",
100
114
  "spec/fb_graph/connections/friends_spec.rb",
115
+ "spec/fb_graph/connections/groups_spec.rb",
101
116
  "spec/fb_graph/connections/home_spec.rb",
102
117
  "spec/fb_graph/connections/likes_spec.rb",
103
118
  "spec/fb_graph/connections/picture_spec.rb",
104
119
  "spec/fb_graph/connections/posts_spec.rb",
105
120
  "spec/fb_graph/connections/statuses_spec.rb",
106
121
  "spec/fb_graph/connections/tagged_spec.rb",
122
+ "spec/fb_graph/event_spec.rb",
123
+ "spec/fb_graph/group_spec.rb",
124
+ "spec/fb_graph/link_spec.rb",
107
125
  "spec/fb_graph/node_spec.rb",
126
+ "spec/fb_graph/note_spec.rb",
108
127
  "spec/fb_graph/page_spec.rb",
128
+ "spec/fb_graph/photo_spec.rb",
129
+ "spec/fb_graph/post_spec.rb",
130
+ "spec/fb_graph/status_spec.rb",
109
131
  "spec/fb_graph/user_spec.rb",
132
+ "spec/fb_graph/video_spec.rb",
110
133
  "spec/fb_graph_spec.rb",
111
134
  "spec/helpers/fake_json_helper.rb",
112
135
  "spec/spec.opts",
@@ -118,19 +141,31 @@ Gem::Specification.new do |s|
118
141
  s.rubygems_version = %q{1.3.6}
119
142
  s.summary = %q{Facebook Graph API library for Ruby}
120
143
  s.test_files = [
121
- "spec/fb_graph/connections/activities_spec.rb",
122
- "spec/fb_graph/connections/collection_spec.rb",
144
+ "spec/fb_graph/album_spec.rb",
145
+ "spec/fb_graph/collection_spec.rb",
146
+ "spec/fb_graph/connections/activities_spec.rb",
147
+ "spec/fb_graph/connections/albums_spec.rb",
148
+ "spec/fb_graph/connections/events_spec.rb",
123
149
  "spec/fb_graph/connections/feed_spec.rb",
124
150
  "spec/fb_graph/connections/friends_spec.rb",
151
+ "spec/fb_graph/connections/groups_spec.rb",
125
152
  "spec/fb_graph/connections/home_spec.rb",
126
153
  "spec/fb_graph/connections/likes_spec.rb",
127
154
  "spec/fb_graph/connections/picture_spec.rb",
128
155
  "spec/fb_graph/connections/posts_spec.rb",
129
156
  "spec/fb_graph/connections/statuses_spec.rb",
130
157
  "spec/fb_graph/connections/tagged_spec.rb",
158
+ "spec/fb_graph/event_spec.rb",
159
+ "spec/fb_graph/group_spec.rb",
160
+ "spec/fb_graph/link_spec.rb",
131
161
  "spec/fb_graph/node_spec.rb",
162
+ "spec/fb_graph/note_spec.rb",
132
163
  "spec/fb_graph/page_spec.rb",
164
+ "spec/fb_graph/photo_spec.rb",
165
+ "spec/fb_graph/post_spec.rb",
166
+ "spec/fb_graph/status_spec.rb",
133
167
  "spec/fb_graph/user_spec.rb",
168
+ "spec/fb_graph/video_spec.rb",
134
169
  "spec/fb_graph_spec.rb",
135
170
  "spec/helpers/fake_json_helper.rb",
136
171
  "spec/spec_helper.rb"
@@ -1,5 +1,5 @@
1
1
  module FbGraph
2
- class Photo < Node
2
+ class Album < Node
3
3
  include Connections::Photos
4
4
  include Connections::Comments
5
5
 
@@ -0,0 +1,32 @@
1
+ module FbGraph
2
+ class Collection < Array
3
+ attr_reader :previous, :next
4
+
5
+ def initialize(collection)
6
+ result = replace(collection[:data])
7
+ @previous, @next = {}, {}
8
+ if (paging = collection[:paging])
9
+ if paging[:previous]
10
+ @previous = fetch_params(paging[:previous])
11
+ end
12
+ if paging[:next]
13
+ @next = fetch_params(paging[:next])
14
+ end
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def fetch_params(url)
21
+ query = URI.parse(url).query
22
+ params = {}
23
+ query.split('&').each do |q|
24
+ key, value = q.split('=')
25
+ params[key] = URI.unescape(value)
26
+ end
27
+ params.delete_if do |k, v|
28
+ k == 'token'
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,9 @@
1
+ module FbGraph
2
+ module Comparison
3
+ def ==(other)
4
+ instance_variables.all? do |key|
5
+ instance_variable_get(key) == other.instance_variable_get(key)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Activities
4
4
  def activities(options = {})
5
- activities = Collection.new(get(options.merge(:connection => 'activities')))
5
+ activities = FbGraph::Collection.new(get(options.merge(:connection => 'activities')))
6
6
  activities.map! do |activity|
7
7
  Page.new(activity.delete(:id), activity)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Albums
4
4
  def albums(options = {})
5
- albums = Collection.new(get(options.merge(:connection => 'albums')))
5
+ albums = FbGraph::Collection.new(get(options.merge(:connection => 'albums')))
6
6
  albums.map! do |album|
7
7
  Album.new(album.delete(:id), album)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Attending
4
4
  def attending(options = {})
5
- members = Collection.new(get(options.merge(:connection => 'attending')))
5
+ members = FbGraph::Collection.new(get(options.merge(:connection => 'attending')))
6
6
  members.map! do |member|
7
7
  if member[:category]
8
8
  Page.new(member.delete(:id), member)
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Books
4
4
  def books(options = {})
5
- books = Collection.new(get(options.merge(:connection => 'books')))
5
+ books = FbGraph::Collection.new(get(options.merge(:connection => 'books')))
6
6
  books.map! do |book|
7
7
  Page.new(book.delete(:id), book)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Comments
4
4
  def comments(options = {})
5
- comments = Collection.new(get(options.merge(:connection => 'comment')))
5
+ comments = FbGraph::Collection.new(get(options.merge(:connection => 'comment')))
6
6
  comments.map! do |comment|
7
7
  Comment.new(comment.delete(:id), comment)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Declined
4
4
  def declined(options = {})
5
- members = Collection.new(get(options.merge(:connection => 'declined')))
5
+ members = FbGraph::Collection.new(get(options.merge(:connection => 'declined')))
6
6
  members.map! do |member|
7
7
  if member[:category]
8
8
  Page.new(member.delete(:id), member)
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Events
4
4
  def events(options = {})
5
- events = Collection.new(get(options.merge(:connection => 'events')))
5
+ events = FbGraph::Collection.new(get(options.merge(:connection => 'events')))
6
6
  events.map! do |event|
7
7
  Event.new(event.delete(:id), event)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Feed
4
4
  def feed(options = {})
5
- posts = Collection.new(get(options.merge(:connection => 'feed')))
5
+ posts = FbGraph::Collection.new(get(options.merge(:connection => 'feed')))
6
6
  posts.map! do |post|
7
7
  Post.new(post.delete(:id), post)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Friends
4
4
  def friends(options = {})
5
- users = Collection.new(get(options.merge(:connection => 'friends')))
5
+ users = FbGraph::Collection.new(get(options.merge(:connection => 'friends')))
6
6
  users.map! do |user|
7
7
  User.new(user.delete(:id), user)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Groups
4
4
  def groups(options = {})
5
- groups = Collection.new(get(options.merge(:connection => 'groups')))
5
+ groups = FbGraph::Collection.new(get(options.merge(:connection => 'groups')))
6
6
  groups.map! do |group|
7
7
  Group.new(group.delete(:id), group)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Home
4
4
  def home(options = {})
5
- posts = Collection.new(get(options.merge(:connection => 'home')))
5
+ posts = FbGraph::Collection.new(get(options.merge(:connection => 'home')))
6
6
  posts.map! do |post|
7
7
  Post.new(post.delete(:id), post)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Interests
4
4
  def interests(options = {})
5
- interests = Collection.new(get(options.merge(:connection => 'interests')))
5
+ interests = FbGraph::Collection.new(get(options.merge(:connection => 'interests')))
6
6
  interests.map! do |interest|
7
7
  Page.new(interest.delete(:id), interest)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Invited
4
4
  def invited(options = {})
5
- members = Collection.new(get(options.merge(:connection => 'invited')))
5
+ members = FbGraph::Collection.new(get(options.merge(:connection => 'invited')))
6
6
  members.map! do |member|
7
7
  if member[:category]
8
8
  Page.new(member.delete(:id), member)
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Likes
4
4
  def likes(options = {})
5
- likes = Collection.new(get(options.merge(:connection => 'likes')))
5
+ likes = FbGraph::Collection.new(get(options.merge(:connection => 'likes')))
6
6
  likes.map! do |like|
7
7
  Page.new(like.delete(:id), like)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Links
4
4
  def links(options = {})
5
- links = Collection.new(get(options.merge(:connection => 'links')))
5
+ links = FbGraph::Collection.new(get(options.merge(:connection => 'links')))
6
6
  links.map! do |link|
7
7
  Link.new(link.delete(:id), link)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Maybe
4
4
  def maybe(options = {})
5
- members = Collection.new(get(options.merge(:connection => 'maybe')))
5
+ members = FbGraph::Collection.new(get(options.merge(:connection => 'maybe')))
6
6
  members.map! do |member|
7
7
  if member[:category]
8
8
  Page.new(member.delete(:id), member)
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Members
4
4
  def members(options = {})
5
- members = Collection.new(get(options.merge(:connection => 'members')))
5
+ members = FbGraph::Collection.new(get(options.merge(:connection => 'members')))
6
6
  member.map! do |member|
7
7
  if member[:category]
8
8
  Page.new(member.delete(:id), member)
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Movies
4
4
  def movies(options = {})
5
- movies = Collection.new(get(options.merge(:connection => 'movies')))
5
+ movies = FbGraph::Collection.new(get(options.merge(:connection => 'movies')))
6
6
  movies.map! do |movie|
7
7
  Page.new(movie.delete(:id), movie)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Music
4
4
  def music(options = {})
5
- music = Collection.new(get(options.merge(:connection => 'music')))
5
+ music = FbGraph::Collection.new(get(options.merge(:connection => 'music')))
6
6
  music.map! do |_music_|
7
7
  Page.new(_music_.delete(:id), _music_)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Noreply
4
4
  def noreply(options = {})
5
- members = Collection.new(get(options.merge(:connection => 'noreply')))
5
+ members = FbGraph::Collection.new(get(options.merge(:connection => 'noreply')))
6
6
  members.map! do |member|
7
7
  if member[:category]
8
8
  Page.new(member.delete(:id), member)
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Notes
4
4
  def notes(options = {})
5
- notes = Collection.new(get(options.merge(:connection => 'notes')))
5
+ notes = FbGraph::Collection.new(get(options.merge(:connection => 'notes')))
6
6
  notes.map! do |note|
7
7
  Note.new(note.delete(:id), note)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Photos
4
4
  def photos(options = {})
5
- photos = Collection.new(get(options.merge(:connection => 'photos')))
5
+ photos = FbGraph::Collection.new(get(options.merge(:connection => 'photos')))
6
6
  photos.map! do |photo|
7
7
  Photo.new(photo.delete(:id), photo)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Posts
4
4
  def posts(options = {})
5
- posts = Collection.new(get(options.merge(:connection => 'posts')))
5
+ posts = FbGraph::Collection.new(get(options.merge(:connection => 'posts')))
6
6
  posts.map! do |post|
7
7
  Post.new(post.delete(:id), post)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Statuses
4
4
  def statuses(options = {})
5
- statuses = Collection.new(get(options.merge(:connection => 'statuses')))
5
+ statuses = FbGraph::Collection.new(get(options.merge(:connection => 'statuses')))
6
6
  statuses.map! do |status|
7
7
  Status.new(status.delete(:id), status)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Tagged
4
4
  def tagged(options = {})
5
- posts = Collection.new(get(options.merge(:connection => 'tagged')))
5
+ posts = FbGraph::Collection.new(get(options.merge(:connection => 'tagged')))
6
6
  posts.map! do |post|
7
7
  Post.new(post.delete(:id), post)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Television
4
4
  def television(options = {})
5
- television = Collection.new(get(options.merge(:connection => 'television')))
5
+ television = FbGraph::Collection.new(get(options.merge(:connection => 'television')))
6
6
  television.map! do |_television_|
7
7
  Page.new(_television_.delete(:id), _television_)
8
8
  end
@@ -2,7 +2,7 @@ module FbGraph
2
2
  module Connections
3
3
  module Videos
4
4
  def videos(options = {})
5
- videos = Collection.new(get(options.merge(:connection => 'videos')))
5
+ videos = FbGraph::Collection.new(get(options.merge(:connection => 'videos')))
6
6
  videos.map! do |video|
7
7
  Video.new(video.delete(:id), video)
8
8
  end
@@ -20,7 +20,9 @@ module FbGraph
20
20
  @start_time = options[:start_time]
21
21
  @end_time = options[:end_time]
22
22
  @location = options[:location]
23
- @venue = options[:venue]
23
+ if options[:venue]
24
+ @venue = FbGraph::Venue.new(options[:venue])
25
+ end
24
26
  @privacy = options[:privacy]
25
27
  @updated_time = options[:updated_time]
26
28
  end
@@ -4,7 +4,7 @@ module FbGraph
4
4
  include Connections::Members
5
5
  include Connections::Picture
6
6
 
7
- attr_accessor :owner, :name, :description, :link, :venue, :longitude, :privacy, :updated_time
7
+ attr_accessor :owner, :name, :description, :link, :venue, :privacy, :updated_time
8
8
 
9
9
  def initialize(identifier, options = {})
10
10
  super
@@ -14,8 +14,9 @@ module FbGraph
14
14
  @name = options[:name]
15
15
  @description = options[:description]
16
16
  @link = options[:link]
17
- @venue = options[:venue]
18
- @longitude = options[:longitude]
17
+ if options[:venue]
18
+ @venue = FbGraph::Venue.new(options[:venue])
19
+ end
19
20
  @privacy = options[:privacy]
20
21
  @updated_time = options[:updated_time]
21
22
  end
data/lib/fb_graph/link.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module FbGraph
2
- class Page < Node
2
+ class Link < Node
3
3
  include Connections::Comments
4
4
 
5
5
  attr_accessor :from, :link, :message, :updated_time
data/lib/fb_graph/node.rb CHANGED
@@ -1,17 +1,13 @@
1
1
  module FbGraph
2
2
  class Node
3
- attr_accessor :identifier, :endpoint, :access_token
3
+ include FbGraph::Comparison
4
4
 
5
- def ==(other)
6
- instance_variables.all? do |key|
7
- instance_variable_get(key) == other.instance_variable_get(key)
8
- end
9
- end
5
+ attr_accessor :identifier, :endpoint, :token
10
6
 
11
7
  def initialize(identifier, options = {})
12
- @identifier = identifier
13
- @endpoint = File.join(FbGraph::ROOT_URL, identifier)
14
- @access_token = options[:access_token]
8
+ @identifier = identifier
9
+ @endpoint = File.join(FbGraph::ROOT_URL, identifier)
10
+ @token = options[:token]
15
11
  end
16
12
 
17
13
  def self.fetch(identifier, options = {})
@@ -34,7 +30,7 @@ module FbGraph
34
30
  else
35
31
  self.endpoint
36
32
  end
37
- options[:access_token] ||= self.access_token
33
+ options[:token] ||= self.token
38
34
  _options_ = options.reject do |k, v|
39
35
  v.blank?
40
36
  end
@@ -4,16 +4,6 @@ module FbGraph
4
4
 
5
5
  attr_accessor :from, :tags, :name, :picture, :source, :height, :width, :link, :created_time, :updated_time
6
6
 
7
- class Tag
8
- attr_accessor :user, :x, :y, :created_time
9
- def initialize(identifier, options = {})
10
- @x = options.delete(:x)
11
- @y = options.delete(:y)
12
- @created_time = options.delete(:created_time)
13
- @user = User.new(identifier, options)
14
- end
15
- end
16
-
17
7
  def initialize(identifier, options = {})
18
8
  super
19
9
  if (from = options[:from])
@@ -25,8 +15,8 @@ module FbGraph
25
15
  end
26
16
  @tags = []
27
17
  if options[:tags]
28
- options[:tags][:data].each do |tag|
29
- FbGraph::Tag.new(tag.delete(:id), tag)
18
+ FbGraph::Collection.new(options[:tags]).each do |tag|
19
+ @tags << FbGraph::Tag.new(tag.delete(:id), tag)
30
20
  end
31
21
  end
32
22
  @name = options[:name]
data/lib/fb_graph/post.rb CHANGED
@@ -15,7 +15,7 @@ module FbGraph
15
15
  end
16
16
  @to = []
17
17
  if options[:to]
18
- options[:to][:data].each do |to|
18
+ FbGraph::Collection.new(options[:to]).each do |to|
19
19
  @to << if to[:category]
20
20
  FbGraph::Page.new(to.delete(:id), to)
21
21
  else
@@ -0,0 +1,14 @@
1
+ module FbGraph
2
+ class Tag
3
+ include FbGraph::Comparison
4
+
5
+ attr_accessor :user, :x, :y, :created_time
6
+
7
+ def initialize(identifier, options = {})
8
+ @x = options.delete(:x)
9
+ @y = options.delete(:y)
10
+ @created_time = options.delete(:created_time)
11
+ @user = User.new(identifier, options)
12
+ end
13
+ end
14
+ end
data/lib/fb_graph/user.rb CHANGED
@@ -43,8 +43,8 @@ module FbGraph
43
43
  @website = options[:website]
44
44
  end
45
45
 
46
- def self.me(access_token)
47
- new('me', :access_token => access_token)
46
+ def self.me(token)
47
+ new('me', :token => token)
48
48
  end
49
49
 
50
50
  end