fb_graph2 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9323b5cf68713b7b9925a313bd0b11fd92741d86
4
- data.tar.gz: 90f36a1eadacd73e791c69c3075a07f4a484452f
3
+ metadata.gz: 2611fb2baed301de340cfdbfa644d4f0253ad59a
4
+ data.tar.gz: 19d3d36952bc4ddfaef0d53c9e7615274a0937c1
5
5
  SHA512:
6
- metadata.gz: 5d7972960b233c4067b472d02e444797dffc74db28897dc6cb731b99f7002b50473ab7432d597889d3182046fff7d68118daff643b45a95f1bf1e7e43f335614
7
- data.tar.gz: 9f78a3058fef522a4e1c018a8362660f0834f870def9ce9740fdf8c555c02af0cf31e5c1b686e33b1fad97b1dab157f5efcc1f2659c2d68a4aff2dfa55f00ab2
6
+ metadata.gz: 3e35b7fd13586d1fff033a477b8778f9f1081f8f6488bc26d0d0ab3eeb135c507a2099a599e9baea5e86bffb3af9d0f6d647750a353abc688555a7fed7eee57d
7
+ data.tar.gz: aa88f0f71ebe57734aa1612dae49e32031faa369810959bcd552fc1c16b48456d01751e57acd726403d2dec9544ae7780101a17a195e6a0b82a26e7662463c9f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -0,0 +1,16 @@
1
+ module FbGraph2
2
+ class Achievement < Node
3
+ register_attributes(
4
+ raw: [:type, :no_feed_story],
5
+ time: [:publish_time],
6
+ application: [:application],
7
+ user: [:from],
8
+ custom: [:data]
9
+ )
10
+
11
+ def initialize(id, attributes = {})
12
+ super
13
+ # TODO: handle custom attributes.
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ module FbGraph2
2
+ class Album < Node
3
+ register_attributes(
4
+ raw: [:can_upload, :count, :cover_photo, :description, :link, :location, :name, :privacy, :type],
5
+ time: [:created_time, :updated_time],
6
+ user: [:from],
7
+ page: [:place]
8
+ )
9
+ end
10
+ end
@@ -44,6 +44,8 @@ module FbGraph2
44
44
  Collection.new(raw).collect do |_raw_|
45
45
  as_profile _raw_
46
46
  end
47
+ when :application
48
+ Application.new raw[:id], raw
47
49
  when :user
48
50
  User.new raw[:id], raw
49
51
  else
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Achievements
4
+ def achievements(params = {})
5
+ achievements = self.edge :achievements, params
6
+ achievements.collect do |achievement|
7
+ Achievement.new(achievement[:id], achievement).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Activities
4
+ def activities(params = {})
5
+ pages = self.edge :activities, params
6
+ pages.collect do |page|
7
+ Page.new(page[:id], page).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Albums
4
+ def albums(params = {})
5
+ albums = self.edge :albums, params
6
+ albums.collect do |album|
7
+ Album.new(album[:id], album).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Books
4
+ def books(params = {})
5
+ pages = self.edge :books, params
6
+ pages.collect do |page|
7
+ Page.new(page[:id], page).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Events
4
+ def events(*args)
5
+ params = args.extract_options!
6
+ events = self.edge :events, params, edge_scope: args.first
7
+ events.collect do |event|
8
+ Event.new(event[:id], event).authenticate self.access_token
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Family
4
+ def family(params = {})
5
+ users = self.edge :family, params
6
+ users.collect do |user|
7
+ User.new(user[:id], user).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module FriendLists
4
+ def friend_lists(params = {})
5
+ friend_lists = self.edge :friendlists, params
6
+ friend_lists.collect do |friend_list|
7
+ FriendList.new(friend_list[:id], friend_list).authenticate self.access_token
8
+ end
9
+ end
10
+ alias_method :friendlists, :friend_lists
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Games
4
+ def games(params = {})
5
+ pages = self.edge :games, params
6
+ pages.collect do |page|
7
+ Page.new(page[:id], page).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Groups
4
+ def groups(params = {})
5
+ groups = self.edge :groups, params
6
+ groups.collect do |group|
7
+ Group.new(group[:id], group).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Home
4
+ def home(params = {})
5
+ posts = self.edge :home, params
6
+ posts.collect do |post|
7
+ Post.new(post[:id], post).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Interests
4
+ def interests(params = {})
5
+ pages = self.edge :interests, params
6
+ pages.collect do |page|
7
+ Page.new(page[:id], page).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Likes
4
+ def likes(params = {})
5
+ pages = self.edge :likes, params
6
+ pages.collect do |page|
7
+ Page.new(page[:id], page).authenticate self.access_token
8
+ end
9
+ end
10
+
11
+ def liked?(page_id, params = {})
12
+ pages = self.edge :likes, params, edge_scope: page_id
13
+ pages.present?
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Links
4
+ def links(params = {})
5
+ posts = self.edge :links, params
6
+ posts.collect do |post|
7
+ Post.new(post[:id], post).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Movies
4
+ def movies(params = {})
5
+ pages = self.edge :movies, params
6
+ pages.collect do |page|
7
+ Page.new(page[:id], page).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Music
4
+ def music(params = {})
5
+ pages = self.edge :music, params
6
+ pages.collect do |page|
7
+ Page.new(page[:id], page).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Posts
4
+ def posts(params = {})
5
+ posts = self.edge :posts, params
6
+ posts.collect do |post|
7
+ Post.new(post[:id], post).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Statuses
4
+ def statuses(params = {})
5
+ posts = self.edge :statuses, params
6
+ posts.collect do |post|
7
+ Post.new(post[:id], post).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Tagged
4
+ def tagged(params = {})
5
+ posts = self.edge :tagged, params
6
+ posts.collect do |post|
7
+ Post.new(post[:id], post).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module Television
4
+ def television(params = {})
5
+ pages = self.edge :television, params
6
+ pages.collect do |page|
7
+ Page.new(page[:id], page).authenticate self.access_token
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ module FbGraph2
2
+ class Event < Node
3
+ register_attributes(
4
+ raw: [:description, :is_date_only, :location, :name, :privacy, :ticket_uri, :timezone],
5
+ time: [:end_time, :start_time, :updated_time],
6
+ page: [:venue],
7
+ custom: [:cover, :owner, :parent_group]
8
+ )
9
+
10
+ def initialize(id, attributes = {})
11
+ super
12
+ # TODO: handle custom attributes.
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ module FbGraph2
2
+ class FriendList < Node
3
+ register_attributes(
4
+ raw: [:name, :list_type]
5
+ )
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ module FbGraph2
2
+ class Group < Node
3
+ register_attributes(
4
+ raw: [
5
+ :description, :email, :icon, :link, :name, :privacy,
6
+ # NOTE: in groups edge context
7
+ :administrator, :bookmark_order, :unread
8
+ ],
9
+ time: [:updated_time],
10
+ custom: [:cover, :owner, :parent]
11
+ )
12
+
13
+ def initialize(id, attributes = {})
14
+ super
15
+ # TODO: handle custom attributes.
16
+ end
17
+ end
18
+ end
@@ -80,6 +80,7 @@ module FbGraph2
80
80
  when 200...300
81
81
  _response_
82
82
  else
83
+ # TODO: better exception structure
83
84
  raise response.body
84
85
  end
85
86
  rescue MultiJson::DecodeError
@@ -6,9 +6,10 @@ module FbGraph2
6
6
  :current_location, :description, :directed_by, :founded, :general_info, :general_manager, :hometown,
7
7
  :is_permanently_closed, :is_published, :is_unclaimed, :likes, :link, :mission, :name, :phone, :press_contact,
8
8
  :products, :talking_about_count, :username, :website, :were_here_count,
9
- # only within /:user_id/accounts context
9
+ # NOTE: only within /:user_id/accounts context
10
10
  :perms
11
11
  ],
12
+ time: [:created_time],
12
13
  date: [:birthday],
13
14
  page: [:best_page],
14
15
  custom: [
@@ -1,14 +1,34 @@
1
1
  module FbGraph2
2
2
  class User < Node
3
3
  include Edge::Accounts
4
- include Edge::Friends
4
+ include Edge::Achievements
5
+ include Edge::Activities
6
+ include Edge::Albums
7
+ include Edge::Books
8
+ include Edge::Events
9
+ include Edge::Family
5
10
  include Edge::Feed
11
+ include Edge::FriendLists
12
+ include Edge::Friends
13
+ include Edge::Games
14
+ include Edge::Home
15
+ include Edge::Interests
16
+ include Edge::Likes
17
+ include Edge::Links
18
+ include Edge::Movies
19
+ include Edge::Music
20
+ include Edge::Posts
21
+ include Edge::Statuses
22
+ include Edge::Tagged
23
+ include Edge::Television
6
24
 
7
25
  register_attributes(
8
26
  raw: [
9
27
  :about, :bio, :email, :first_name, :gender, :installed, :is_verified, :link, :locale,
10
28
  :middle_name, :name, :name_format, :political, :quotes, :relationship_status, :religion,
11
- :timezone, :third_party_id, :verified, :website
29
+ :timezone, :third_party_id, :verified, :website,
30
+ # NOTE: in family edge context
31
+ :relationship
12
32
  ],
13
33
  time: [:updated_time], # NOTE: undocumented attribute
14
34
  date: [:birthday],
@@ -5,7 +5,7 @@ describe FbGraph2::Edge::Accounts do
5
5
  describe '#accounts' do
6
6
  let(:me) { FbGraph2::User.me('token') }
7
7
  it 'should return pages with page token' do
8
- accounts = mock_graph :get, 'me/accounts', 'user/accounts' do
8
+ accounts = mock_graph :get, 'me/accounts', 'user/accounts', access_token: 'token' do
9
9
  me.accounts
10
10
  end
11
11
  account = accounts.first
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe FbGraph2::Edge::Feed do
4
+ context 'included in User' do
5
+ let(:me) { FbGraph2::User.me('token') }
6
+
7
+ describe '#feed' do
8
+ it :TODO
9
+ end
10
+
11
+ describe 'feed!' do
12
+ it 'should return FbGraph2::Post with posted params' do
13
+ post = mock_graph :post, 'me/feed', 'success_with_id', access_token: 'token' do
14
+ me.feed! message: 'hello'
15
+ end
16
+ post.should be_instance_of FbGraph2::Post
17
+ post.id.should == 'created_object_id'
18
+ post.message.should == 'hello'
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ {
2
+ "id": "created_object_id"
3
+ }
@@ -39,8 +39,10 @@ module MockGraph
39
39
  def request_for(method, options = {})
40
40
  request = {}
41
41
  if options[:access_token]
42
- options[:params] ||= {}
43
- options[:params][:access_token] = options[:access_token].to_s
42
+ request[:headers] ||= {}
43
+ request[:headers] = {
44
+ authorization: "Bearer #{options[:access_token]}"
45
+ }
44
46
  end
45
47
  if options[:params]
46
48
  case method
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_graph2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-21 00:00:00.000000000 Z
11
+ date: 2014-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -137,13 +137,37 @@ files:
137
137
  - VERSION
138
138
  - fb_graph2.gemspec
139
139
  - lib/fb_graph2.rb
140
+ - lib/fb_graph2/achievement.rb
141
+ - lib/fb_graph2/album.rb
140
142
  - lib/fb_graph2/application.rb
141
143
  - lib/fb_graph2/attribute_assigner.rb
142
144
  - lib/fb_graph2/collection.rb
143
145
  - lib/fb_graph2/edge.rb
144
146
  - lib/fb_graph2/edge/accounts.rb
147
+ - lib/fb_graph2/edge/achievements.rb
148
+ - lib/fb_graph2/edge/activities.rb
149
+ - lib/fb_graph2/edge/albums.rb
150
+ - lib/fb_graph2/edge/books.rb
151
+ - lib/fb_graph2/edge/events.rb
152
+ - lib/fb_graph2/edge/family.rb
145
153
  - lib/fb_graph2/edge/feed.rb
154
+ - lib/fb_graph2/edge/friend_lists.rb
146
155
  - lib/fb_graph2/edge/friends.rb
156
+ - lib/fb_graph2/edge/games.rb
157
+ - lib/fb_graph2/edge/groups.rb
158
+ - lib/fb_graph2/edge/home.rb
159
+ - lib/fb_graph2/edge/interests.rb
160
+ - lib/fb_graph2/edge/likes.rb
161
+ - lib/fb_graph2/edge/links.rb
162
+ - lib/fb_graph2/edge/movies.rb
163
+ - lib/fb_graph2/edge/music.rb
164
+ - lib/fb_graph2/edge/posts.rb
165
+ - lib/fb_graph2/edge/statuses.rb
166
+ - lib/fb_graph2/edge/tagged.rb
167
+ - lib/fb_graph2/edge/television.rb
168
+ - lib/fb_graph2/event.rb
169
+ - lib/fb_graph2/friend_list.rb
170
+ - lib/fb_graph2/group.rb
147
171
  - lib/fb_graph2/node.rb
148
172
  - lib/fb_graph2/page.rb
149
173
  - lib/fb_graph2/post.rb
@@ -151,11 +175,13 @@ files:
151
175
  - lib/fb_graph2/request_filter/debugger.rb
152
176
  - lib/fb_graph2/user.rb
153
177
  - spec/fb_graph2/edge/accounts_spec.rb
178
+ - spec/fb_graph2/edge/feed_spec.rb
154
179
  - spec/fb_graph2/node_spec.rb
155
180
  - spec/fb_graph2/node_subclass_spec.rb
156
181
  - spec/fb_graph2/page_spec.rb
157
182
  - spec/fb_graph2/user_spec.rb
158
183
  - spec/fb_graph2_spec.rb
184
+ - spec/mock_json/success_with_id.json
159
185
  - spec/mock_json/user/accounts.json
160
186
  - spec/mock_json/user/me.json
161
187
  - spec/spec_helper.rb
@@ -180,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
206
  version: '0'
181
207
  requirements: []
182
208
  rubyforge_project:
183
- rubygems_version: 2.2.0
209
+ rubygems_version: 2.2.2
184
210
  signing_key:
185
211
  specification_version: 4
186
212
  summary: Facebook Graph API v2.0 Wrapper in Ruby