fb_graph 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/fb_graph.gemspec +5 -2
- data/lib/fb_graph/auth.rb +5 -3
- data/lib/fb_graph/page/categories/local_business.rb +2 -2
- data/lib/fb_graph/user.rb +1 -1
- data/spec/fake_json/pages/categories/local_business.json +72 -0
- data/spec/fb_graph/auth_spec.rb +34 -3
- data/spec/fb_graph/page/categories/local_business_spec.rb +34 -0
- data/spec/fb_graph/page_spec.rb +1 -7
- data/spec/fb_graph/user_spec.rb +0 -2
- metadata +7 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.1
|
data/fb_graph.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{fb_graph}
|
8
|
-
s.version = "1.6.
|
8
|
+
s.version = "1.6.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["nov matake"]
|
12
|
-
s.date = %q{2011-03-
|
12
|
+
s.date = %q{2011-03-20}
|
13
13
|
s.description = %q{A full-stack Facebook Graph API wrapper in Ruby.}
|
14
14
|
s.email = %q{nov@matake.jp}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -130,6 +130,7 @@ Gem::Specification.new do |s|
|
|
130
130
|
"spec/fake_json/events/maybe/smartday_private.json",
|
131
131
|
"spec/fake_json/events/noreply/smartday_private.json",
|
132
132
|
"spec/fake_json/groups/members/emacs_private.json",
|
133
|
+
"spec/fake_json/pages/categories/local_business.json",
|
133
134
|
"spec/fake_json/pages/checkins/gowalla_private.json",
|
134
135
|
"spec/fake_json/pages/checkins/gowalla_public.json",
|
135
136
|
"spec/fake_json/pages/insights/FbGraph_private.json",
|
@@ -281,6 +282,7 @@ Gem::Specification.new do |s|
|
|
281
282
|
"spec/fb_graph/message_spec.rb",
|
282
283
|
"spec/fb_graph/node_spec.rb",
|
283
284
|
"spec/fb_graph/note_spec.rb",
|
285
|
+
"spec/fb_graph/page/categories/local_business_spec.rb",
|
284
286
|
"spec/fb_graph/page_spec.rb",
|
285
287
|
"spec/fb_graph/photo_spec.rb",
|
286
288
|
"spec/fb_graph/place_spec.rb",
|
@@ -372,6 +374,7 @@ Gem::Specification.new do |s|
|
|
372
374
|
"spec/fb_graph/message_spec.rb",
|
373
375
|
"spec/fb_graph/node_spec.rb",
|
374
376
|
"spec/fb_graph/note_spec.rb",
|
377
|
+
"spec/fb_graph/page/categories/local_business_spec.rb",
|
375
378
|
"spec/fb_graph/page_spec.rb",
|
376
379
|
"spec/fb_graph/photo_spec.rb",
|
377
380
|
"spec/fb_graph/place_spec.rb",
|
data/lib/fb_graph/auth.rb
CHANGED
@@ -34,12 +34,14 @@ module FbGraph
|
|
34
34
|
self.access_token.present?
|
35
35
|
end
|
36
36
|
|
37
|
-
def authorize_uri(canvas_uri)
|
37
|
+
def authorize_uri(canvas_uri, options = {})
|
38
38
|
endpoint = URI.parse SignedRequest::OAUTH_DIALOG_ENDPOINT
|
39
|
-
|
39
|
+
params = options.merge(
|
40
40
|
:client_id => self.client.id,
|
41
41
|
:redirect_uri => canvas_uri
|
42
|
-
|
42
|
+
)
|
43
|
+
params[:scope] = Array(params[:scope]).join(',') if params[:scope].present?
|
44
|
+
endpoint.query = params.to_query
|
43
45
|
endpoint.to_s
|
44
46
|
end
|
45
47
|
|
@@ -2,7 +2,7 @@ module FbGraph
|
|
2
2
|
class Page
|
3
3
|
module Categories
|
4
4
|
module LocalBusiness
|
5
|
-
attr_accessor :attire, :general_manager, :hours, :parking, :payment_options, :phone, :price_range, :public_transit, :restaurant_services, :restaurant_specialties
|
5
|
+
attr_accessor :attire, :culinary_team, :general_manager, :hours, :parking, :payment_options, :phone, :price_range, :public_transit, :restaurant_services, :restaurant_specialties
|
6
6
|
|
7
7
|
def self.included(klass)
|
8
8
|
klass.alias_method_chain :initialize, :category_specific_attributes
|
@@ -10,7 +10,7 @@ module FbGraph
|
|
10
10
|
|
11
11
|
def initialize_with_category_specific_attributes(identifier, attributes = {})
|
12
12
|
initialize_without_category_specific_attributes identifier, attributes
|
13
|
-
[:attire, :general_manager, :phone, :price_range, :public_transit].each do |key|
|
13
|
+
[:attire, :culinary_team, :general_manager, :phone, :price_range, :public_transit].each do |key|
|
14
14
|
self.send :"#{key}=", attributes[key]
|
15
15
|
end
|
16
16
|
[:parking, :payment_options, :restaurant_services, :restaurant_specialties].each do |key|
|
data/lib/fb_graph/user.rb
CHANGED
@@ -29,7 +29,7 @@ module FbGraph
|
|
29
29
|
include Connections::Videos
|
30
30
|
extend Searchable
|
31
31
|
|
32
|
-
attr_accessor :first_name, :last_name, :name, :link, :about, :birthday, :work, :education, :email, :website, :
|
32
|
+
attr_accessor :first_name, :last_name, :name, :link, :about, :birthday, :work, :education, :email, :website, :hometown, :location, :bio, :quotes, :gender, :interested_in, :meeting_for, :relationship_status, :religion, :political, :verified, :significant_other, :timezone, :updated_time, :sports, :favorite_teams, :favorite_athletes, :inspirational_people, :locale, :languages, :third_party_id, :address, :mobile_phone
|
33
33
|
|
34
34
|
def initialize(identifier, attributes = {})
|
35
35
|
super
|
@@ -0,0 +1,72 @@
|
|
1
|
+
{
|
2
|
+
"attire":
|
3
|
+
"Casual",
|
4
|
+
"category":
|
5
|
+
"Bar",
|
6
|
+
"culinary_team":
|
7
|
+
"Team FbGraph!",
|
8
|
+
"general_manager":
|
9
|
+
"Nov Matake",
|
10
|
+
"hours":
|
11
|
+
{
|
12
|
+
"mon_1_open":
|
13
|
+
378000,
|
14
|
+
"mon_2_close":
|
15
|
+
406800
|
16
|
+
},
|
17
|
+
"id":
|
18
|
+
"196723247025808",
|
19
|
+
"link":
|
20
|
+
"http://www.facebook.com/pages/Local-Business-Sample/196723247025808",
|
21
|
+
"location":
|
22
|
+
{
|
23
|
+
"city":
|
24
|
+
"Kyoto",
|
25
|
+
"country":
|
26
|
+
"Japan",
|
27
|
+
"street":
|
28
|
+
"\u65b0\u7530\u8fba",
|
29
|
+
"zip":
|
30
|
+
"513001"
|
31
|
+
},
|
32
|
+
"name":
|
33
|
+
"Local Business Sample",
|
34
|
+
"parking":
|
35
|
+
{
|
36
|
+
"street":
|
37
|
+
1,
|
38
|
+
"valet":
|
39
|
+
1
|
40
|
+
},
|
41
|
+
"payment_options":
|
42
|
+
{
|
43
|
+
"amex":
|
44
|
+
1,
|
45
|
+
"mastercard":
|
46
|
+
1,
|
47
|
+
"visa":
|
48
|
+
1
|
49
|
+
},
|
50
|
+
"phone":
|
51
|
+
"1234567890",
|
52
|
+
"picture":
|
53
|
+
"http://b.static.ak.fbcdn.net/rsrc.php/v1/y0/r/XsEg9L6Ie5_.jpg",
|
54
|
+
"price_range":
|
55
|
+
"$ (0-10)",
|
56
|
+
"public_transit":
|
57
|
+
"30 min from Kyoto St.",
|
58
|
+
"restaurant_services":
|
59
|
+
{
|
60
|
+
"groups":
|
61
|
+
1,
|
62
|
+
"reserve":
|
63
|
+
1
|
64
|
+
},
|
65
|
+
"restaurant_specialties":
|
66
|
+
{
|
67
|
+
"dinner":
|
68
|
+
1,
|
69
|
+
"drinks":
|
70
|
+
1
|
71
|
+
}
|
72
|
+
}
|
data/spec/fb_graph/auth_spec.rb
CHANGED
@@ -25,7 +25,7 @@ describe FbGraph::Auth, '.new' do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
describe FbGraph::Auth, '
|
28
|
+
describe FbGraph::Auth, '#from_cookie' do
|
29
29
|
before do
|
30
30
|
@auth = FbGraph::Auth.new('client_id', 'client_secret')
|
31
31
|
@expires_at = Time.parse('2020-12-31 12:00:00')
|
@@ -54,7 +54,7 @@ describe FbGraph::Auth, '.from_cookie' do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
describe FbGraph::Auth, '
|
57
|
+
describe FbGraph::Auth, '#from_signed_request' do
|
58
58
|
before do
|
59
59
|
@signed_request = "LqsgnfcsRdfjOgyW6ZuSLpGBVsxUBegEqai4EcrWS0A=.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjAsImlzc3VlZF9hdCI6MTI5ODc4MzczOSwib2F1dGhfdG9rZW4iOiIxMzQxNDU2NDMyOTQzMjJ8MmI4YTZmOTc1NTJjNmRjZWQyMDU4MTBiLTU3OTYxMjI3NnxGS1o0akdKZ0JwN2k3bFlrOVhhUk1QZ3lhNnMiLCJ1c2VyIjp7ImNvdW50cnkiOiJqcCIsImxvY2FsZSI6ImVuX1VTIiwiYWdlIjp7Im1pbiI6MjF9fSwidXNlcl9pZCI6IjU3OTYxMjI3NiJ9"
|
60
60
|
@auth = FbGraph::Auth.new('client_id', 'client_secret')
|
@@ -86,4 +86,35 @@ describe FbGraph::Auth, '.from_signed_request' do
|
|
86
86
|
end.should raise_exception(FbGraph::Auth::VerificationFailed)
|
87
87
|
end
|
88
88
|
end
|
89
|
-
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe FbGraph::Auth do
|
92
|
+
let(:auth) { FbGraph::Auth.new('client_id', 'client_secret') }
|
93
|
+
|
94
|
+
describe '#authorized?' do
|
95
|
+
subject { auth.authorized? }
|
96
|
+
|
97
|
+
context 'when access_token is given' do
|
98
|
+
before do
|
99
|
+
auth.access_token = 'access_token'
|
100
|
+
end
|
101
|
+
it { should be_true }
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'otherwise' do
|
105
|
+
it { should be_false }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe '#authorize_uri' do
|
110
|
+
let(:canvas_uri) { 'http://client.example.com/canvas' }
|
111
|
+
subject { auth.authorize_uri(canvas_uri) }
|
112
|
+
it { should == "https://www.facebook.com/dialog/oauth?client_id=client_id&redirect_uri=#{CGI.escape canvas_uri}" }
|
113
|
+
|
114
|
+
context 'when params are given' do
|
115
|
+
subject { auth.authorize_uri(canvas_uri, :scope => [:scope1, :scope2], :state => 'state1') }
|
116
|
+
it { should == "https://www.facebook.com/dialog/oauth?client_id=client_id&redirect_uri=#{CGI.escape canvas_uri}&scope=#{CGI.escape "scope1,scope2"}&state=state1" }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../../../spec_helper')
|
2
|
+
|
3
|
+
describe FbGraph::Page::Categories::LocalBusiness do
|
4
|
+
before do
|
5
|
+
fake_json(:get, 'local_business', 'pages/categories/local_business')
|
6
|
+
end
|
7
|
+
let(:page) { FbGraph::Page.new('local_business').fetch }
|
8
|
+
subject { page }
|
9
|
+
|
10
|
+
[:attire, :culinary_team, :general_manager, :phone, :price_range, :public_transit].each do |key|
|
11
|
+
its(key) { should be_instance_of String }
|
12
|
+
end
|
13
|
+
|
14
|
+
[:parking, :payment_options, :restaurant_services, :restaurant_specialties].each do |key|
|
15
|
+
its(key) { should be_instance_of Array }
|
16
|
+
describe key do
|
17
|
+
it 'should be an Array of Symbol' do
|
18
|
+
page.send(key).all? do |value|
|
19
|
+
value.should be_instance_of Symbol
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
its(:hours) { should be_instance_of Hash }
|
26
|
+
its(:hours) do
|
27
|
+
should == {
|
28
|
+
:mon => [
|
29
|
+
{:open => Time.parse('Wed Mar 23 09:00:00 UTC 2011')},
|
30
|
+
{:close => Time.parse('Wed Mar 23 17:00:00 UTC 2011')}
|
31
|
+
]
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
data/spec/fb_graph/page_spec.rb
CHANGED
@@ -23,13 +23,7 @@ describe FbGraph::Page, '.new' do
|
|
23
23
|
page.category.should == 'Technology'
|
24
24
|
page.username.should == 'platform'
|
25
25
|
page.mission.should == 'To make the web more open and social.'
|
26
|
-
page.products.should ==
|
27
|
-
'Facebook Application Programming Interface (API)',
|
28
|
-
'Facebook Query Language (FQL)',
|
29
|
-
'Facebook Markup Language (FBML)',
|
30
|
-
'Facebook JavaScript (FBJS)',
|
31
|
-
'Facebook Connect'
|
32
|
-
]
|
26
|
+
page.products.should == "Facebook Application Programming Interface (API)\nFacebook Query Language (FQL)\nFacebook Markup Language (FBML)\nFacebook JavaScript (FBJS)\nFacebook Connect\n"
|
33
27
|
page.like_count.should == 578246
|
34
28
|
page.company_overview.should == 'Facebook Platform enables anyone to build social applications on Facebook and the web.'
|
35
29
|
page.link.should == 'http://www.facebook.com/platform'
|
data/spec/fb_graph/user_spec.rb
CHANGED
@@ -56,7 +56,6 @@ describe FbGraph::User, '.fetch' do
|
|
56
56
|
user.meeting_for.should == ['Friendship', 'Networking']
|
57
57
|
user.relationship_status.should == 'Married'
|
58
58
|
user.website.should == 'http://matake.jp'
|
59
|
-
user.websites.should == ['http://matake.jp']
|
60
59
|
user.religion.should be_nil
|
61
60
|
user.political.should be_nil
|
62
61
|
user.timezone.should == 9
|
@@ -136,7 +135,6 @@ describe FbGraph::User, '.fetch' do
|
|
136
135
|
]
|
137
136
|
user.email.should == nil
|
138
137
|
user.website.should == nil
|
139
|
-
user.websites.should == []
|
140
138
|
user.hometown.should == FbGraph::Page.new(109533479072558, :name => 'Minnetonka, Minnesota')
|
141
139
|
user.interested_in.should == ['female']
|
142
140
|
user.meeting_for.should == ['Friendship']
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fb_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 1.6.
|
9
|
+
- 1
|
10
|
+
version: 1.6.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- nov matake
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-20 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -248,6 +248,7 @@ files:
|
|
248
248
|
- spec/fake_json/events/maybe/smartday_private.json
|
249
249
|
- spec/fake_json/events/noreply/smartday_private.json
|
250
250
|
- spec/fake_json/groups/members/emacs_private.json
|
251
|
+
- spec/fake_json/pages/categories/local_business.json
|
251
252
|
- spec/fake_json/pages/checkins/gowalla_private.json
|
252
253
|
- spec/fake_json/pages/checkins/gowalla_public.json
|
253
254
|
- spec/fake_json/pages/insights/FbGraph_private.json
|
@@ -399,6 +400,7 @@ files:
|
|
399
400
|
- spec/fb_graph/message_spec.rb
|
400
401
|
- spec/fb_graph/node_spec.rb
|
401
402
|
- spec/fb_graph/note_spec.rb
|
403
|
+
- spec/fb_graph/page/categories/local_business_spec.rb
|
402
404
|
- spec/fb_graph/page_spec.rb
|
403
405
|
- spec/fb_graph/photo_spec.rb
|
404
406
|
- spec/fb_graph/place_spec.rb
|
@@ -519,6 +521,7 @@ test_files:
|
|
519
521
|
- spec/fb_graph/message_spec.rb
|
520
522
|
- spec/fb_graph/node_spec.rb
|
521
523
|
- spec/fb_graph/note_spec.rb
|
524
|
+
- spec/fb_graph/page/categories/local_business_spec.rb
|
522
525
|
- spec/fb_graph/page_spec.rb
|
523
526
|
- spec/fb_graph/photo_spec.rb
|
524
527
|
- spec/fb_graph/place_spec.rb
|