fb_graph 2.1.13 → 2.2.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -2
- data/Gemfile.lock +31 -29
- data/Rakefile +13 -3
- data/VERSION +1 -1
- data/fb_graph.gemspec +5 -1
- data/lib/fb_graph/application.rb +1 -0
- data/lib/fb_graph/collection.rb +8 -2
- data/lib/fb_graph/connection.rb +1 -1
- data/lib/fb_graph/open_graph/action.rb +37 -0
- data/lib/fb_graph/open_graph/application_context.rb +10 -0
- data/lib/fb_graph/open_graph/object.rb +29 -0
- data/lib/fb_graph/open_graph/user_context.rb +21 -0
- data/lib/fb_graph/open_graph.rb +3 -0
- data/lib/fb_graph/user.rb +1 -0
- data/lib/fb_graph.rb +1 -0
- data/spec/fb_graph/connections/friend_requests_spec.rb +5 -1
- data/spec/fb_graph/open_graph/action_spec.rb +110 -0
- data/spec/fb_graph/open_graph/application_context_spec.rb +28 -0
- data/spec/fb_graph/open_graph/object_spec.rb +76 -0
- data/spec/fb_graph/open_graph/user_context_spec.rb +23 -0
- data/spec/mock_json/applications/fbgraphsample.json +14 -0
- data/spec/mock_json/open_graph/custom_actions.json +61 -0
- data/spec/mock_json/open_graph/play_actions.json +89 -0
- data/spec/mock_json/users/friend_requests/sample.json +16 -14
- data/spec/spec_helper.rb +4 -0
- metadata +70 -5
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,49 +1,52 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fb_graph (2.1.
|
4
|
+
fb_graph (2.1.13)
|
5
5
|
httpclient (>= 2.2.0.2)
|
6
6
|
rack-oauth2 (>= 0.9.4)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actionpack (3.1.
|
12
|
-
activemodel (= 3.1.
|
13
|
-
activesupport (= 3.1.
|
11
|
+
actionpack (3.1.1)
|
12
|
+
activemodel (= 3.1.1)
|
13
|
+
activesupport (= 3.1.1)
|
14
14
|
builder (~> 3.0.0)
|
15
15
|
erubis (~> 2.7.0)
|
16
16
|
i18n (~> 0.6)
|
17
17
|
rack (~> 1.3.2)
|
18
|
-
rack-cache (~> 1.
|
18
|
+
rack-cache (~> 1.1)
|
19
19
|
rack-mount (~> 0.8.2)
|
20
20
|
rack-test (~> 0.6.1)
|
21
|
-
sprockets (~> 2.0.
|
22
|
-
activemodel (3.1.
|
23
|
-
activesupport (= 3.1.
|
24
|
-
bcrypt-ruby (~> 3.0.0)
|
21
|
+
sprockets (~> 2.0.2)
|
22
|
+
activemodel (3.1.1)
|
23
|
+
activesupport (= 3.1.1)
|
25
24
|
builder (~> 3.0.0)
|
26
25
|
i18n (~> 0.6)
|
27
|
-
activesupport (3.1.
|
26
|
+
activesupport (3.1.1)
|
28
27
|
multi_json (~> 1.0)
|
29
28
|
addressable (2.2.6)
|
30
29
|
attr_required (0.0.3)
|
31
|
-
bcrypt-ruby (3.0.1)
|
32
|
-
bcrypt-ruby (3.0.1-java)
|
33
30
|
bouncy-castle-java (1.5.0146.1)
|
34
31
|
builder (3.0.0)
|
32
|
+
configatron (2.8.3)
|
33
|
+
yamler (>= 0.1.0)
|
34
|
+
cover_me (1.2.0)
|
35
|
+
configatron
|
36
|
+
hashie
|
35
37
|
crack (0.3.1)
|
36
38
|
diff-lcs (1.1.3)
|
37
39
|
erubis (2.7.0)
|
40
|
+
hashie (1.2.0)
|
38
41
|
hike (1.2.1)
|
39
|
-
httpclient (2.2.
|
42
|
+
httpclient (2.2.3)
|
40
43
|
i18n (0.6.0)
|
41
44
|
jruby-openssl (0.7.4)
|
42
45
|
bouncy-castle-java
|
43
46
|
json (1.6.1)
|
44
47
|
multi_json (1.0.3)
|
45
|
-
rack (1.3.
|
46
|
-
rack-cache (1.
|
48
|
+
rack (1.3.5)
|
49
|
+
rack-cache (1.1)
|
47
50
|
rack (>= 0.4)
|
48
51
|
rack-mount (0.8.3)
|
49
52
|
rack (>= 1.0.0)
|
@@ -56,25 +59,24 @@ GEM
|
|
56
59
|
rack (>= 1.1)
|
57
60
|
rack-test (0.6.1)
|
58
61
|
rack (>= 1.0)
|
59
|
-
rake (0.9.2)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
rspec-
|
64
|
-
|
65
|
-
|
66
|
-
rspec-core (2.6.4)
|
67
|
-
rspec-expectations (2.6.0)
|
62
|
+
rake (0.9.2.2)
|
63
|
+
rspec (2.7.0)
|
64
|
+
rspec-core (~> 2.7.0)
|
65
|
+
rspec-expectations (~> 2.7.0)
|
66
|
+
rspec-mocks (~> 2.7.0)
|
67
|
+
rspec-core (2.7.1)
|
68
|
+
rspec-expectations (2.7.0)
|
68
69
|
diff-lcs (~> 1.1.2)
|
69
|
-
rspec-mocks (2.
|
70
|
-
sprockets (2.0.
|
70
|
+
rspec-mocks (2.7.0)
|
71
|
+
sprockets (2.0.3)
|
71
72
|
hike (~> 1.2)
|
72
73
|
rack (~> 1.0)
|
73
74
|
tilt (~> 1.1, != 1.3.0)
|
74
75
|
tilt (1.3.3)
|
75
|
-
webmock (1.7.
|
76
|
-
addressable (
|
76
|
+
webmock (1.7.7)
|
77
|
+
addressable (~> 2.2, > 2.2.5)
|
77
78
|
crack (>= 0.1.7)
|
79
|
+
yamler (0.1.0)
|
78
80
|
|
79
81
|
PLATFORMS
|
80
82
|
java
|
@@ -82,9 +84,9 @@ PLATFORMS
|
|
82
84
|
|
83
85
|
DEPENDENCIES
|
84
86
|
actionpack (>= 3.0.6)
|
87
|
+
cover_me (>= 1.2.0)
|
85
88
|
fb_graph!
|
86
89
|
jruby-openssl (>= 0.7)
|
87
90
|
rake (>= 0.8)
|
88
|
-
rcov (>= 0.9)
|
89
91
|
rspec (>= 2)
|
90
92
|
webmock (>= 1.6.2)
|
data/Rakefile
CHANGED
@@ -4,9 +4,19 @@ Bundler::GemHelper.install_tasks
|
|
4
4
|
require 'rspec/core/rake_task'
|
5
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
if RUBY_VERSION >= '1.9'
|
8
|
+
require 'cover_me'
|
9
|
+
RSpec::Core::RakeTask.new(:cover) do
|
10
|
+
CoverMe.config do |c|
|
11
|
+
c.file_pattern = /(#{CoverMe.config.project.root}\/lib\/.+\.rb)/i
|
12
|
+
end
|
13
|
+
CoverMe.complete!
|
14
|
+
end
|
15
|
+
else
|
16
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
17
|
+
spec.rcov = true
|
18
|
+
spec.rcov_opts = ['-Ilib -Ispec --exclude spec,gems']
|
19
|
+
end
|
10
20
|
end
|
11
21
|
|
12
22
|
task :default => :spec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0.alpha
|
data/fb_graph.gemspec
CHANGED
@@ -15,7 +15,11 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.add_runtime_dependency "httpclient", ">= 2.2.0.2"
|
16
16
|
s.add_runtime_dependency "rack-oauth2", ">= 0.9.4"
|
17
17
|
s.add_development_dependency "rake", ">= 0.8"
|
18
|
-
|
18
|
+
if RUBY_VERSION >= '1.9'
|
19
|
+
s.add_development_dependency "cover_me", ">= 1.2.0"
|
20
|
+
else
|
21
|
+
s.add_development_dependency "rcov", ">= 0.9"
|
22
|
+
end
|
19
23
|
s.add_development_dependency "rspec", ">= 2"
|
20
24
|
s.add_development_dependency "webmock", ">= 1.6.2"
|
21
25
|
s.add_development_dependency "actionpack", ">= 3.0.6"
|
data/lib/fb_graph/application.rb
CHANGED
data/lib/fb_graph/collection.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module FbGraph
|
2
2
|
class Collection < Array
|
3
|
-
attr_reader :previous, :next, :total_count
|
3
|
+
attr_reader :previous, :next, :total_count, :unread_count, :updated_time
|
4
4
|
|
5
5
|
def initialize(collection = nil)
|
6
6
|
collection = case collection
|
@@ -19,7 +19,13 @@ module FbGraph
|
|
19
19
|
collection[:data].delete_if(&:nil?)
|
20
20
|
|
21
21
|
result = replace(collection[:data])
|
22
|
-
|
22
|
+
if summary = collection[:summary]
|
23
|
+
@total_count = summary[:total_count]
|
24
|
+
@unread_count = summary[:unread_count]
|
25
|
+
@updated_time = Time.parse(summary[:updated_time]) if summary[:updated_time]
|
26
|
+
else
|
27
|
+
@total_count = collection[:count]
|
28
|
+
end
|
23
29
|
@previous, @next = {}, {}
|
24
30
|
if (paging = collection[:paging])
|
25
31
|
if paging[:previous]
|
data/lib/fb_graph/connection.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module FbGraph
|
2
2
|
class Connection < Collection
|
3
3
|
attr_accessor :collection, :connection, :owner, :options
|
4
|
-
delegate :total_count, :to => :collection
|
4
|
+
delegate :total_count, :unread_count, :updated_time, :to => :collection
|
5
5
|
|
6
6
|
def initialize(owner, connection, options = {})
|
7
7
|
@owner = owner
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module FbGraph
|
2
|
+
module OpenGraph
|
3
|
+
class Action < Node
|
4
|
+
include Connections::Comments
|
5
|
+
include Connections::Likes
|
6
|
+
|
7
|
+
attr_accessor :type, :application, :from, :objects, :start_time, :end_time, :publish_time
|
8
|
+
attr_accessor :raw_attributes
|
9
|
+
|
10
|
+
def initialize(identifier, attributes = {})
|
11
|
+
super
|
12
|
+
@raw_attributes = attributes
|
13
|
+
@type = attributes[:type]
|
14
|
+
if application = attributes[:application]
|
15
|
+
@application = Application.new(application[:id], application)
|
16
|
+
end
|
17
|
+
if from = attributes[:from]
|
18
|
+
@from = User.new(from[:id], from)
|
19
|
+
end
|
20
|
+
@objects = {}
|
21
|
+
if attributes[:data]
|
22
|
+
attributes[:data].each do |key, _attributes_|
|
23
|
+
@objects[key] = Object.new _attributes_[:id], _attributes_
|
24
|
+
end
|
25
|
+
end
|
26
|
+
@objects = @objects.with_indifferent_access
|
27
|
+
[:start_time, :end_time, :publish_time].each do |key|
|
28
|
+
self.send "#{key}=", Time.parse(attributes[key]) if attributes[key]
|
29
|
+
end
|
30
|
+
|
31
|
+
# cached connection
|
32
|
+
@_likes_ = Collection.new(attributes[:likes])
|
33
|
+
@_comments_ = Collection.new(attributes[:comments])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module FbGraph
|
2
|
+
module OpenGraph
|
3
|
+
class Object < Node
|
4
|
+
attr_accessor :type, :application, :url, :title, :description, :images, :image, :site_name, :updated_time
|
5
|
+
attr_accessor :raw_attributes
|
6
|
+
|
7
|
+
def initialize(identifier, attributes = {})
|
8
|
+
super
|
9
|
+
@raw_attributes = attributes
|
10
|
+
[:type, :url, :title, :description, :site_name].each do |key|
|
11
|
+
self.send "#{key}=", attributes[key]
|
12
|
+
end
|
13
|
+
if application = attributes[:application]
|
14
|
+
@application = Application.new(application[:id], application)
|
15
|
+
end
|
16
|
+
@images = []
|
17
|
+
if attributes[:image]
|
18
|
+
attributes[:image].each do |image|
|
19
|
+
@images << image[:url]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
@image = @images.first
|
23
|
+
if attributes[:updated_time]
|
24
|
+
@updated_time = Time.parse attributes[:updated_time]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module FbGraph
|
2
|
+
module OpenGraph
|
3
|
+
module UserContext
|
4
|
+
def og_actions(action, options = {})
|
5
|
+
actions = self.connection(action, options)
|
6
|
+
actions.map! do |_action_|
|
7
|
+
Action.new _action_[:id], _action_.merge(
|
8
|
+
:access_token => options[:access_token] || self.access_token
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def og_action!(action, options = {})
|
14
|
+
action = post options.merge(:connection => action)
|
15
|
+
Action.new action[:id], action.merge(
|
16
|
+
:access_token => options[:access_token] || self.access_token
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/fb_graph/user.rb
CHANGED
@@ -36,6 +36,7 @@ module FbGraph
|
|
36
36
|
include Connections::UserAchievements
|
37
37
|
include Connections::UserLikes
|
38
38
|
include Connections::Videos
|
39
|
+
include OpenGraph::UserContext
|
39
40
|
extend Searchable
|
40
41
|
|
41
42
|
attr_accessor :name, :first_name, :middle_name, :last_name, :gender, :locale, :languages, :link, :username, :third_party_id, :timezone, :updated_time, :verified, :about, :bio, :birthday, :education, :email, :hometown, :interested_in, :location, :political, :favorite_teams, :quotes, :relationship_status, :religion, :significant_other, :video_upload_limits, :website, :work
|
data/lib/fb_graph.rb
CHANGED
@@ -3,7 +3,11 @@ require 'spec_helper'
|
|
3
3
|
describe FbGraph::Connections::FriendRequests do
|
4
4
|
it 'should return an Array of FriendRequest' do
|
5
5
|
mock_graph :get, 'me/friendrequests', 'users/friend_requests/sample', :access_token => 'access_token' do
|
6
|
-
|
6
|
+
friend_requests = FbGraph::User.me('access_token').friend_requests
|
7
|
+
friend_requests.total_count.should == 1
|
8
|
+
friend_requests.unread_count.should == 1
|
9
|
+
friend_requests.updated_time.should == Time.parse('2011-10-31T03:38:55+0000')
|
10
|
+
friend_request = friend_requests.first
|
7
11
|
friend_request.should be_a FbGraph::FriendRequest
|
8
12
|
friend_request.from.should be_a FbGraph::User
|
9
13
|
friend_request.to.should be_a FbGraph::User
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FbGraph::OpenGraph::Action do
|
4
|
+
subject do
|
5
|
+
FbGraph::OpenGraph::Action.new attributes[:id], attributes
|
6
|
+
end
|
7
|
+
let :attributes do
|
8
|
+
JSON.parse(json).with_indifferent_access
|
9
|
+
end
|
10
|
+
shared_examples_for :og_action_initialized do
|
11
|
+
its(:from) do
|
12
|
+
should == FbGraph::User.new(attributes[:from][:id], attributes[:from])
|
13
|
+
end
|
14
|
+
its(:application) do
|
15
|
+
should == FbGraph::Application.new(attributes[:application][:id], attributes[:application])
|
16
|
+
end
|
17
|
+
[:start_time, :end_time, :publish_time].each do |key|
|
18
|
+
its(key) { should == Time.parse(attributes[key]) }
|
19
|
+
end
|
20
|
+
its(:objects) { should be_a Hash }
|
21
|
+
its(:likes) { should be_instance_of FbGraph::Connection }
|
22
|
+
its(:comments) { should be_instance_of FbGraph::Connection }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with play action' do
|
26
|
+
let :json do
|
27
|
+
<<-JSON
|
28
|
+
{
|
29
|
+
"id": "10150402047187277",
|
30
|
+
"from": {
|
31
|
+
"id": "579612276",
|
32
|
+
"name": "Nov Matake"
|
33
|
+
},
|
34
|
+
"start_time": "2011-11-05T00:19:01+0000",
|
35
|
+
"end_time": "2011-11-05T00:19:01+0000",
|
36
|
+
"publish_time": "2011-11-05T00:19:01+0000",
|
37
|
+
"application": {
|
38
|
+
"id": "134145643294322",
|
39
|
+
"name": "gem sample"
|
40
|
+
},
|
41
|
+
"data": {
|
42
|
+
"game": {
|
43
|
+
"id": "10150267719331290",
|
44
|
+
"url": "http:\/\/samples.ogp.me\/163382137069945",
|
45
|
+
"type": "game",
|
46
|
+
"title": "Sample Game"
|
47
|
+
}
|
48
|
+
},
|
49
|
+
"likes": {
|
50
|
+
"count": 0
|
51
|
+
},
|
52
|
+
"comments": {
|
53
|
+
"count": 0
|
54
|
+
},
|
55
|
+
"type": "games.plays"
|
56
|
+
}
|
57
|
+
JSON
|
58
|
+
end
|
59
|
+
it_behaves_like :og_action_initialized
|
60
|
+
its(:type) { should == 'games.plays' }
|
61
|
+
it 'should have a game object' do
|
62
|
+
subject.objects['game'].should == subject.objects[:game]
|
63
|
+
subject.objects[:game].should be_instance_of FbGraph::OpenGraph::Object
|
64
|
+
subject.objects[:game].type.should == 'game'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'with custom action' do
|
69
|
+
let :json do
|
70
|
+
<<-JSON
|
71
|
+
{
|
72
|
+
"id": "10150389446227277",
|
73
|
+
"from": {
|
74
|
+
"id": "579612276",
|
75
|
+
"name": "Nov Matake"
|
76
|
+
},
|
77
|
+
"start_time": "2011-10-26T02:21:00+0000",
|
78
|
+
"end_time": "2011-10-26T02:21:00+0000",
|
79
|
+
"publish_time": "2011-10-26T02:21:00+0000",
|
80
|
+
"application": {
|
81
|
+
"id": "134145643294322",
|
82
|
+
"name": "gem sample"
|
83
|
+
},
|
84
|
+
"data": {
|
85
|
+
"custom_object": {
|
86
|
+
"id": "10150362170052970",
|
87
|
+
"url": "http:\/\/samples.ogp.me\/264755040233381",
|
88
|
+
"type": "fbgraphsample:custom_object",
|
89
|
+
"title": "Custom Object"
|
90
|
+
}
|
91
|
+
},
|
92
|
+
"likes": {
|
93
|
+
"count": 0
|
94
|
+
},
|
95
|
+
"comments": {
|
96
|
+
"count": 0
|
97
|
+
},
|
98
|
+
"type": "fbgraphsample:custom_action"
|
99
|
+
}
|
100
|
+
JSON
|
101
|
+
end
|
102
|
+
it_behaves_like :og_action_initialized
|
103
|
+
its(:type) { should == 'fbgraphsample:custom_action' }
|
104
|
+
it 'should have a custom object' do
|
105
|
+
subject.objects['custom_object'].should == subject.objects[:custom_object]
|
106
|
+
subject.objects[:custom_object].should be_instance_of FbGraph::OpenGraph::Object
|
107
|
+
subject.objects[:custom_object].type.should == 'fbgraphsample:custom_object'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FbGraph::OpenGraph::ApplicationContext do
|
4
|
+
let :application_with_namespace do
|
5
|
+
FbGraph::Application.new('app_id', :namespace => 'fbgraph')
|
6
|
+
end
|
7
|
+
let :application_without_namespace do
|
8
|
+
FbGraph::Application.new('app_id')
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#og_action' do
|
12
|
+
context 'with namespace' do
|
13
|
+
it 'should return "APP_NAMESPACE:ACTION_NAME" without fetching application info' do
|
14
|
+
application_with_namespace.og_action('action_name').should == 'fbgraph:action_name'
|
15
|
+
application_with_namespace.og_action(:action_name).should == 'fbgraph:action_name'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'without namespace' do
|
20
|
+
it 'should return "APP_NAMESPACE:ACTION_NAME" with fetching application info' do
|
21
|
+
mock_graph :get, 'app_id', 'applications/fbgraphsample' do
|
22
|
+
application_without_namespace.og_action('action_name').should == 'fbgraphsample:action_name'
|
23
|
+
application_without_namespace.og_action(:action_name).should == 'fbgraphsample:action_name'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FbGraph::OpenGraph::Object do
|
4
|
+
subject do
|
5
|
+
FbGraph::OpenGraph::Object.new attributes[:id], attributes
|
6
|
+
end
|
7
|
+
let :attributes do
|
8
|
+
JSON.parse(json).with_indifferent_access
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'with play action' do
|
12
|
+
let :json do
|
13
|
+
<<-JSON
|
14
|
+
{
|
15
|
+
"url": "http:\/\/samples.ogp.me\/163382137069945",
|
16
|
+
"type": "game",
|
17
|
+
"title": "Sample Game",
|
18
|
+
"image": [{
|
19
|
+
"url": "http:\/\/static.ak.fbcdn.net\/images\/devsite\/attachment_blank.png"
|
20
|
+
}],
|
21
|
+
"description": "",
|
22
|
+
"updated_time": "2011-10-10T08:28:48+0000",
|
23
|
+
"id": "10150267719331290",
|
24
|
+
"application": {
|
25
|
+
"id": "115190258555800",
|
26
|
+
"name": "Open Graph",
|
27
|
+
"url": "http:\/\/www.facebook.com\/apps\/application.php?id=115190258555800"
|
28
|
+
}
|
29
|
+
}
|
30
|
+
JSON
|
31
|
+
end
|
32
|
+
its(:url) { should == 'http://samples.ogp.me/163382137069945' }
|
33
|
+
its(:type) { should == 'game' }
|
34
|
+
its(:title) { should == 'Sample Game' }
|
35
|
+
its(:image) { should == 'http://static.ak.fbcdn.net/images/devsite/attachment_blank.png' }
|
36
|
+
its(:images) { should == ['http://static.ak.fbcdn.net/images/devsite/attachment_blank.png'] }
|
37
|
+
its(:description) { should == '' }
|
38
|
+
its(:updated_time) { should == Time.parse('2011-10-10T08:28:48+0000') }
|
39
|
+
its(:application) do
|
40
|
+
should == FbGraph::Application.new(attributes[:application][:id], attributes[:application])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'with custom action' do
|
45
|
+
let :json do
|
46
|
+
<<-JSON
|
47
|
+
{
|
48
|
+
"url": "http:\/\/samples.ogp.me\/264755040233381",
|
49
|
+
"type": "fbgraphsample:custom_object",
|
50
|
+
"title": "Custom Object",
|
51
|
+
"image": [{
|
52
|
+
"url": "https:\/\/s-static.ak.fbcdn.net\/images\/devsite\/attachment_blank.png"
|
53
|
+
}],
|
54
|
+
"description": "Custom Object for FbGraph testing",
|
55
|
+
"updated_time": "2011-10-26T02:12:08+0000",
|
56
|
+
"id": "10150362170052970",
|
57
|
+
"application": {
|
58
|
+
"id": "134145643294322",
|
59
|
+
"name": "gem sample",
|
60
|
+
"url": "http:\/\/www.facebook.com\/apps\/application.php?id=134145643294322"
|
61
|
+
}
|
62
|
+
}
|
63
|
+
JSON
|
64
|
+
end
|
65
|
+
its(:url) { should == 'http://samples.ogp.me/264755040233381' }
|
66
|
+
its(:type) { should == 'fbgraphsample:custom_object' }
|
67
|
+
its(:title) { should == 'Custom Object' }
|
68
|
+
its(:image) { should == 'https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png' }
|
69
|
+
its(:images) { should == ['https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png'] }
|
70
|
+
its(:description) { should == 'Custom Object for FbGraph testing' }
|
71
|
+
its(:updated_time) { should == Time.parse('2011-10-26T02:12:08+0000') }
|
72
|
+
its(:application) do
|
73
|
+
should == FbGraph::Application.new(attributes[:application][:id], attributes[:application])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FbGraph::OpenGraph::UserContext do
|
4
|
+
let(:me) { FbGraph::User.me('access_token') }
|
5
|
+
let(:app) { FbGraph::Application.new('app_id', :namespace => 'fbgraphsample') }
|
6
|
+
|
7
|
+
describe '#og_actions' do
|
8
|
+
it 'should return an array of FbGraph::OpenGraph::Action' do
|
9
|
+
mock_graph :get, 'me/fbgraphsample:custom_action', 'open_graph/custom_actions', :access_token => 'access_token' do
|
10
|
+
actions = me.og_actions(
|
11
|
+
app.og_action('custom_action')
|
12
|
+
)
|
13
|
+
actions.each do |action|
|
14
|
+
action.should be_instance_of FbGraph::OpenGraph::Action
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#og_action!' do
|
21
|
+
it :TODO
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"id": "134145643294322",
|
3
|
+
"name": "gem sample",
|
4
|
+
"category": "Games",
|
5
|
+
"subcategory": "Virtual World",
|
6
|
+
"link": "http:\/\/www.facebook.com\/apps\/application.php?id=134145643294322",
|
7
|
+
"canvas_name": "fbgraphsample",
|
8
|
+
"namespace": "fbgraphsample",
|
9
|
+
"icon_url": "http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yT\/r\/4QVMqOjUhcd.gif",
|
10
|
+
"logo_url": "http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yq\/r\/IobSBNz4FuT.gif",
|
11
|
+
"daily_active_users": "6",
|
12
|
+
"weekly_active_users": "40",
|
13
|
+
"monthly_active_users": "100"
|
14
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
{
|
2
|
+
"data": [{
|
3
|
+
"id": "10150389456592277",
|
4
|
+
"from": {
|
5
|
+
"id": "579612276",
|
6
|
+
"name": "Nov Matake"
|
7
|
+
},
|
8
|
+
"start_time": "2011-10-26T02:34:01+0000",
|
9
|
+
"end_time": "2011-10-26T02:34:01+0000",
|
10
|
+
"publish_time": "2011-10-26T02:34:01+0000",
|
11
|
+
"application": {
|
12
|
+
"id": "134145643294322",
|
13
|
+
"name": "gem sample"
|
14
|
+
},
|
15
|
+
"data": {
|
16
|
+
"custom_object": {
|
17
|
+
"id": "10150362170052970",
|
18
|
+
"url": "http:\/\/samples.ogp.me\/264755040233381",
|
19
|
+
"type": "fbgraphsample:custom_object",
|
20
|
+
"title": "Custom Object"
|
21
|
+
}
|
22
|
+
},
|
23
|
+
"likes": {
|
24
|
+
"count": 0
|
25
|
+
},
|
26
|
+
"comments": {
|
27
|
+
"count": 0
|
28
|
+
}
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"id": "10150389446227277",
|
32
|
+
"from": {
|
33
|
+
"id": "579612276",
|
34
|
+
"name": "Nov Matake"
|
35
|
+
},
|
36
|
+
"start_time": "2011-10-26T02:21:00+0000",
|
37
|
+
"end_time": "2011-10-26T02:21:00+0000",
|
38
|
+
"publish_time": "2011-10-26T02:21:00+0000",
|
39
|
+
"application": {
|
40
|
+
"id": "134145643294322",
|
41
|
+
"name": "gem sample"
|
42
|
+
},
|
43
|
+
"data": {
|
44
|
+
"custom_object": {
|
45
|
+
"id": "10150362170052970",
|
46
|
+
"url": "http:\/\/samples.ogp.me\/264755040233381",
|
47
|
+
"type": "fbgraphsample:custom_object",
|
48
|
+
"title": "Custom Object"
|
49
|
+
}
|
50
|
+
},
|
51
|
+
"likes": {
|
52
|
+
"count": 0
|
53
|
+
},
|
54
|
+
"comments": {
|
55
|
+
"count": 0
|
56
|
+
}
|
57
|
+
}],
|
58
|
+
"paging": {
|
59
|
+
"next": "https:\/\/graph.facebook.com\/me\/fbgraphsample:custom_action?access_token=AAAB6ATdqrnIBADbMH69FdhoaGf0DTL71rrN0yQuizYhf0xZAf4ukpmaL15qdjWwFYyZCsbNunJudd3ZCHTo57ZBebXxgyIgZD&offset=25&limit=25"
|
60
|
+
}
|
61
|
+
}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
{
|
2
|
+
"data": [{
|
3
|
+
"id": "10150402044277277",
|
4
|
+
"from": {
|
5
|
+
"id": "579612276",
|
6
|
+
"name": "Nov Matake"
|
7
|
+
},
|
8
|
+
"start_time": "2011-11-05T00:15:37+0000",
|
9
|
+
"end_time": "2011-11-05T00:15:37+0000",
|
10
|
+
"publish_time": "2011-11-05T00:15:37+0000",
|
11
|
+
"application": {
|
12
|
+
"id": "134145643294322",
|
13
|
+
"name": "gem sample"
|
14
|
+
},
|
15
|
+
"data": {
|
16
|
+
"game": {
|
17
|
+
"id": "10150267719331290",
|
18
|
+
"url": "http:\/\/samples.ogp.me\/163382137069945",
|
19
|
+
"type": "game",
|
20
|
+
"title": "Sample Game"
|
21
|
+
}
|
22
|
+
},
|
23
|
+
"likes": {
|
24
|
+
"count": 0
|
25
|
+
},
|
26
|
+
"comments": {
|
27
|
+
"count": 0
|
28
|
+
}
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"id": "10150402040052277",
|
32
|
+
"from": {
|
33
|
+
"id": "579612276",
|
34
|
+
"name": "Nov Matake"
|
35
|
+
},
|
36
|
+
"start_time": "2011-11-05T00:10:38+0000",
|
37
|
+
"end_time": "2011-11-05T00:10:38+0000",
|
38
|
+
"publish_time": "2011-11-05T00:10:38+0000",
|
39
|
+
"application": {
|
40
|
+
"id": "134145643294322",
|
41
|
+
"name": "gem sample"
|
42
|
+
},
|
43
|
+
"data": {
|
44
|
+
"game": {
|
45
|
+
"id": "10150267719331290",
|
46
|
+
"url": "http:\/\/samples.ogp.me\/163382137069945",
|
47
|
+
"type": "game",
|
48
|
+
"title": "Sample Game"
|
49
|
+
}
|
50
|
+
},
|
51
|
+
"likes": {
|
52
|
+
"count": 0
|
53
|
+
},
|
54
|
+
"comments": {
|
55
|
+
"count": 0
|
56
|
+
}
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"id": "10150353697142277",
|
60
|
+
"from": {
|
61
|
+
"id": "579612276",
|
62
|
+
"name": "Nov Matake"
|
63
|
+
},
|
64
|
+
"start_time": "2011-09-28T21:19:30+0000",
|
65
|
+
"end_time": "2011-09-28T22:13:54+0000",
|
66
|
+
"publish_time": "2011-09-28T21:19:30+0000",
|
67
|
+
"application": {
|
68
|
+
"id": "134145643294322",
|
69
|
+
"name": "gem sample"
|
70
|
+
},
|
71
|
+
"data": {
|
72
|
+
"game": {
|
73
|
+
"id": "10150256739160488",
|
74
|
+
"url": "http:\/\/apps.facebook.com\/fbgraphsample\/",
|
75
|
+
"type": "game",
|
76
|
+
"title": "gem sample"
|
77
|
+
}
|
78
|
+
},
|
79
|
+
"likes": {
|
80
|
+
"count": 0
|
81
|
+
},
|
82
|
+
"comments": {
|
83
|
+
"count": 0
|
84
|
+
}
|
85
|
+
}],
|
86
|
+
"paging": {
|
87
|
+
"next": "https:\/\/graph.facebook.com\/me\/games.plays?access_token=AAAB6ATdqrnIBADbMH69FdhoaGf0DTL71rrN0yQuizYhf0xZAf4ukpmaL15qdjWwFYyZCsbNunJudd3ZCHTo57ZBebXxgyIgZD&offset=25&limit=25"
|
88
|
+
}
|
89
|
+
}
|
@@ -1,17 +1,19 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
"data": [{
|
3
|
+
"from": {
|
4
|
+
"name": "IKnow Dev",
|
5
|
+
"id": "100001993741286"
|
6
|
+
},
|
7
|
+
"created_time": "2011-10-31T03:38:55+0000",
|
8
|
+
"unread": true,
|
9
|
+
"to": {
|
10
|
+
"name": "Nov Matake",
|
11
|
+
"id": "579612276"
|
12
|
+
}
|
13
|
+
}],
|
14
|
+
"summary": {
|
15
|
+
"unread_count": 1,
|
16
|
+
"total_count": 1,
|
17
|
+
"updated_time": "2011-10-31T03:38:55+0000"
|
15
18
|
}
|
16
|
-
]
|
17
19
|
}
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fb_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
hash: -1851332210
|
5
|
+
prerelease: 6
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
- alpha
|
11
|
+
version: 2.2.0.alpha
|
6
12
|
platform: ruby
|
7
13
|
authors:
|
8
14
|
- nov matake
|
@@ -10,7 +16,7 @@ autorequire:
|
|
10
16
|
bindir: bin
|
11
17
|
cert_chain: []
|
12
18
|
|
13
|
-
date: 2011-
|
19
|
+
date: 2011-11-05 00:00:00 Z
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: httpclient
|
@@ -20,6 +26,12 @@ dependencies:
|
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 123
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 2
|
33
|
+
- 0
|
34
|
+
- 2
|
23
35
|
version: 2.2.0.2
|
24
36
|
type: :runtime
|
25
37
|
version_requirements: *id001
|
@@ -31,6 +43,11 @@ dependencies:
|
|
31
43
|
requirements:
|
32
44
|
- - ">="
|
33
45
|
- !ruby/object:Gem::Version
|
46
|
+
hash: 51
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
- 9
|
50
|
+
- 4
|
34
51
|
version: 0.9.4
|
35
52
|
type: :runtime
|
36
53
|
version_requirements: *id002
|
@@ -42,6 +59,10 @@ dependencies:
|
|
42
59
|
requirements:
|
43
60
|
- - ">="
|
44
61
|
- !ruby/object:Gem::Version
|
62
|
+
hash: 27
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
- 8
|
45
66
|
version: "0.8"
|
46
67
|
type: :development
|
47
68
|
version_requirements: *id003
|
@@ -53,6 +74,10 @@ dependencies:
|
|
53
74
|
requirements:
|
54
75
|
- - ">="
|
55
76
|
- !ruby/object:Gem::Version
|
77
|
+
hash: 25
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
- 9
|
56
81
|
version: "0.9"
|
57
82
|
type: :development
|
58
83
|
version_requirements: *id004
|
@@ -64,6 +89,9 @@ dependencies:
|
|
64
89
|
requirements:
|
65
90
|
- - ">="
|
66
91
|
- !ruby/object:Gem::Version
|
92
|
+
hash: 7
|
93
|
+
segments:
|
94
|
+
- 2
|
67
95
|
version: "2"
|
68
96
|
type: :development
|
69
97
|
version_requirements: *id005
|
@@ -75,6 +103,11 @@ dependencies:
|
|
75
103
|
requirements:
|
76
104
|
- - ">="
|
77
105
|
- !ruby/object:Gem::Version
|
106
|
+
hash: 11
|
107
|
+
segments:
|
108
|
+
- 1
|
109
|
+
- 6
|
110
|
+
- 2
|
78
111
|
version: 1.6.2
|
79
112
|
type: :development
|
80
113
|
version_requirements: *id006
|
@@ -86,6 +119,11 @@ dependencies:
|
|
86
119
|
requirements:
|
87
120
|
- - ">="
|
88
121
|
- !ruby/object:Gem::Version
|
122
|
+
hash: 11
|
123
|
+
segments:
|
124
|
+
- 3
|
125
|
+
- 0
|
126
|
+
- 6
|
89
127
|
version: 3.0.6
|
90
128
|
type: :development
|
91
129
|
version_requirements: *id007
|
@@ -221,6 +259,11 @@ files:
|
|
221
259
|
- lib/fb_graph/message.rb
|
222
260
|
- lib/fb_graph/node.rb
|
223
261
|
- lib/fb_graph/note.rb
|
262
|
+
- lib/fb_graph/open_graph.rb
|
263
|
+
- lib/fb_graph/open_graph/action.rb
|
264
|
+
- lib/fb_graph/open_graph/application_context.rb
|
265
|
+
- lib/fb_graph/open_graph/object.rb
|
266
|
+
- lib/fb_graph/open_graph/user_context.rb
|
224
267
|
- lib/fb_graph/order.rb
|
225
268
|
- lib/fb_graph/page.rb
|
226
269
|
- lib/fb_graph/page/category_attributes.rb
|
@@ -349,6 +392,10 @@ files:
|
|
349
392
|
- spec/fb_graph/message_spec.rb
|
350
393
|
- spec/fb_graph/node_spec.rb
|
351
394
|
- spec/fb_graph/note_spec.rb
|
395
|
+
- spec/fb_graph/open_graph/action_spec.rb
|
396
|
+
- spec/fb_graph/open_graph/application_context_spec.rb
|
397
|
+
- spec/fb_graph/open_graph/object_spec.rb
|
398
|
+
- spec/fb_graph/open_graph/user_context_spec.rb
|
352
399
|
- spec/fb_graph/order_spec.rb
|
353
400
|
- spec/fb_graph/page/local_business_spec.rb
|
354
401
|
- spec/fb_graph/page/movie_spec.rb
|
@@ -395,6 +442,7 @@ files:
|
|
395
442
|
- spec/mock_json/albums/photos/post_with_valid_access_token.json
|
396
443
|
- spec/mock_json/applications/accounts/private.json
|
397
444
|
- spec/mock_json/applications/achievements/sample.json
|
445
|
+
- spec/mock_json/applications/fbgraphsample.json
|
398
446
|
- spec/mock_json/applications/feed/public.json
|
399
447
|
- spec/mock_json/applications/payments/sample.json
|
400
448
|
- spec/mock_json/applications/reviews/public.json
|
@@ -417,6 +465,8 @@ files:
|
|
417
465
|
- spec/mock_json/friend_lists/members/sample.json
|
418
466
|
- spec/mock_json/groups/docs/private.json
|
419
467
|
- spec/mock_json/groups/members/emacs_private.json
|
468
|
+
- spec/mock_json/open_graph/custom_actions.json
|
469
|
+
- spec/mock_json/open_graph/play_actions.json
|
420
470
|
- spec/mock_json/pages/admins/blank.json
|
421
471
|
- spec/mock_json/pages/admins/sample.json
|
422
472
|
- spec/mock_json/pages/blocked/create.json
|
@@ -556,13 +606,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
556
606
|
requirements:
|
557
607
|
- - ">="
|
558
608
|
- !ruby/object:Gem::Version
|
609
|
+
hash: 3
|
610
|
+
segments:
|
611
|
+
- 0
|
559
612
|
version: "0"
|
560
613
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
561
614
|
none: false
|
562
615
|
requirements:
|
563
|
-
- - "
|
616
|
+
- - ">"
|
564
617
|
- !ruby/object:Gem::Version
|
565
|
-
|
618
|
+
hash: 25
|
619
|
+
segments:
|
620
|
+
- 1
|
621
|
+
- 3
|
622
|
+
- 1
|
623
|
+
version: 1.3.1
|
566
624
|
requirements: []
|
567
625
|
|
568
626
|
rubyforge_project:
|
@@ -671,6 +729,10 @@ test_files:
|
|
671
729
|
- spec/fb_graph/message_spec.rb
|
672
730
|
- spec/fb_graph/node_spec.rb
|
673
731
|
- spec/fb_graph/note_spec.rb
|
732
|
+
- spec/fb_graph/open_graph/action_spec.rb
|
733
|
+
- spec/fb_graph/open_graph/application_context_spec.rb
|
734
|
+
- spec/fb_graph/open_graph/object_spec.rb
|
735
|
+
- spec/fb_graph/open_graph/user_context_spec.rb
|
674
736
|
- spec/fb_graph/order_spec.rb
|
675
737
|
- spec/fb_graph/page/local_business_spec.rb
|
676
738
|
- spec/fb_graph/page/movie_spec.rb
|
@@ -717,6 +779,7 @@ test_files:
|
|
717
779
|
- spec/mock_json/albums/photos/post_with_valid_access_token.json
|
718
780
|
- spec/mock_json/applications/accounts/private.json
|
719
781
|
- spec/mock_json/applications/achievements/sample.json
|
782
|
+
- spec/mock_json/applications/fbgraphsample.json
|
720
783
|
- spec/mock_json/applications/feed/public.json
|
721
784
|
- spec/mock_json/applications/payments/sample.json
|
722
785
|
- spec/mock_json/applications/reviews/public.json
|
@@ -739,6 +802,8 @@ test_files:
|
|
739
802
|
- spec/mock_json/friend_lists/members/sample.json
|
740
803
|
- spec/mock_json/groups/docs/private.json
|
741
804
|
- spec/mock_json/groups/members/emacs_private.json
|
805
|
+
- spec/mock_json/open_graph/custom_actions.json
|
806
|
+
- spec/mock_json/open_graph/play_actions.json
|
742
807
|
- spec/mock_json/pages/admins/blank.json
|
743
808
|
- spec/mock_json/pages/admins/sample.json
|
744
809
|
- spec/mock_json/pages/blocked/create.json
|