fb_graph 2.4.1 → 2.4.2
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.
- data/Gemfile.lock +11 -9
- data/VERSION +1 -1
- data/fb_graph.gemspec +1 -0
- data/lib/fb_graph/exception.rb +6 -1
- data/lib/fb_graph/page/category_attributes.rb +8 -2
- data/spec/fb_graph/exception_spec.rb +12 -0
- data/spec/fb_graph/page/local_business_spec.rb +24 -1
- data/spec/mock_json/pages/categories/local_business_fixnum.json +56 -0
- metadata +29 -16
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fb_graph (2.4.
|
4
|
+
fb_graph (2.4.1)
|
5
5
|
httpclient (>= 2.2.0.2)
|
6
6
|
rack-oauth2 (>= 0.14.0)
|
7
|
+
tzinfo
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: http://rubygems.org/
|
@@ -24,8 +25,8 @@ GEM
|
|
24
25
|
activesupport (3.2.1)
|
25
26
|
i18n (~> 0.6)
|
26
27
|
multi_json (~> 1.0)
|
27
|
-
addressable (2.2.
|
28
|
-
attr_required (0.0.
|
28
|
+
addressable (2.2.7)
|
29
|
+
attr_required (0.0.5)
|
29
30
|
builder (3.0.0)
|
30
31
|
configatron (2.9.0)
|
31
32
|
yamler (>= 0.1.0)
|
@@ -39,15 +40,15 @@ GEM
|
|
39
40
|
hike (1.2.1)
|
40
41
|
httpclient (2.2.4)
|
41
42
|
i18n (0.6.0)
|
42
|
-
journey (1.0.
|
43
|
+
journey (1.0.3)
|
43
44
|
json (1.6.5)
|
44
|
-
multi_json (1.0
|
45
|
+
multi_json (1.1.0)
|
45
46
|
rack (1.4.1)
|
46
47
|
rack-cache (1.1)
|
47
48
|
rack (>= 0.4)
|
48
|
-
rack-oauth2 (0.14.
|
49
|
+
rack-oauth2 (0.14.2)
|
49
50
|
activesupport (>= 2.3)
|
50
|
-
attr_required (>= 0.0.
|
51
|
+
attr_required (>= 0.0.5)
|
51
52
|
httpclient (>= 2.2.0.2)
|
52
53
|
i18n
|
53
54
|
json (>= 1.4.3)
|
@@ -68,8 +69,9 @@ GEM
|
|
68
69
|
rack (~> 1.0)
|
69
70
|
tilt (~> 1.1, != 1.3.0)
|
70
71
|
tilt (1.3.3)
|
71
|
-
|
72
|
-
|
72
|
+
tzinfo (0.3.31)
|
73
|
+
webmock (1.8.0)
|
74
|
+
addressable (>= 2.2.7)
|
73
75
|
crack (>= 0.1.7)
|
74
76
|
yamler (0.1.0)
|
75
77
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.4.
|
1
|
+
2.4.2
|
data/fb_graph.gemspec
CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
15
|
s.add_runtime_dependency "httpclient", ">= 2.2.0.2"
|
16
16
|
s.add_runtime_dependency "rack-oauth2", ">= 0.14.0"
|
17
|
+
s.add_runtime_dependency "tzinfo"
|
17
18
|
s.add_development_dependency "rake", ">= 0.8"
|
18
19
|
if RUBY_VERSION >= '1.9'
|
19
20
|
s.add_development_dependency "cover_me", ">= 1.2.0"
|
data/lib/fb_graph/exception.rb
CHANGED
@@ -24,7 +24,12 @@ module FbGraph
|
|
24
24
|
|
25
25
|
# Check the WWW-Authenticate header, since it seems to be more standardized than the response
|
26
26
|
# body error information.
|
27
|
-
|
27
|
+
# The complex lookup is needed to follow the HTTP spec - headers should be looked up
|
28
|
+
# without regard to case.
|
29
|
+
www_authenticate = headers.select do |name, value|
|
30
|
+
name.upcase == "WWW-Authenticate".upcase
|
31
|
+
end.to_a.flatten.second
|
32
|
+
if www_authenticate
|
28
33
|
# Session expiration/invalidation is very common. Check for that first.
|
29
34
|
if www_authenticate =~ /invalid_token/ && response[:error][:message] =~ /session has been invalidated/
|
30
35
|
raise InvalidSession.new("#{response[:error][:type]} :: #{response[:error][:message]}")
|
@@ -94,7 +94,13 @@ module FbGraph
|
|
94
94
|
date, index, mode = key.split('_')
|
95
95
|
index = index.to_i - 1
|
96
96
|
date, mode = date.to_sym, mode.to_sym
|
97
|
-
|
97
|
+
if value.class == Fixnum
|
98
|
+
# The Unix "time" returned is a weird approximation of the string value.
|
99
|
+
# Example: "20:00" might be represented as 446400, which is 1970-01-05T20:00:00-08:00
|
100
|
+
time = Time.at(value).in_time_zone("Pacific Time (US & Canada)")
|
101
|
+
else
|
102
|
+
time = Time.parse(value)
|
103
|
+
end
|
98
104
|
time = Time.utc(1970, 1, 1, time.hour, time.min)
|
99
105
|
@hours[date] ||= []
|
100
106
|
@hours[date][index] ||= {}
|
@@ -109,4 +115,4 @@ module FbGraph
|
|
109
115
|
|
110
116
|
include CategoryAttributes
|
111
117
|
end
|
112
|
-
end
|
118
|
+
end
|
@@ -91,6 +91,18 @@ describe FbGraph::Exception, ".handle_httpclient_error" do
|
|
91
91
|
it "should raise an InvalidToken exception" do
|
92
92
|
lambda {FbGraph::Exception.handle_httpclient_error(parsed_response, headers)}.should raise_exception(FbGraph::InvalidToken)
|
93
93
|
end
|
94
|
+
|
95
|
+
context "with a variant capitalization of the header" do
|
96
|
+
let(:headers) do
|
97
|
+
{
|
98
|
+
"Www-Authenticate" => 'OAuth "Facebook Platform" "invalid_token" "Invalid OAuth access token."'
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should raise an InvalidToken exception" do
|
103
|
+
lambda {FbGraph::Exception.handle_httpclient_error(parsed_response, headers)}.should raise_exception(FbGraph::InvalidToken)
|
104
|
+
end
|
105
|
+
end
|
94
106
|
end
|
95
107
|
|
96
108
|
context "with an invalid request" do
|
@@ -62,4 +62,27 @@ describe FbGraph::Page do
|
|
62
62
|
)
|
63
63
|
end
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
|
+
context 'for local_business category with hours as Fixnums' do
|
67
|
+
let :page do
|
68
|
+
mock_graph :get, 'local_business', 'pages/categories/local_business_fixnum' do
|
69
|
+
FbGraph::Page.new('local_business').fetch
|
70
|
+
end
|
71
|
+
end
|
72
|
+
subject { page }
|
73
|
+
|
74
|
+
its(:hours) { should be_instance_of Hash }
|
75
|
+
its(:hours) do
|
76
|
+
should == {
|
77
|
+
:mon => [{
|
78
|
+
:open => Time.parse('1970-01-01 10:00:00 UTC'),
|
79
|
+
:close => Time.parse('1970-01-01 20:00:00 UTC')
|
80
|
+
}],
|
81
|
+
:tue=>[{
|
82
|
+
:open => Time.parse('1970-01-01 10:00:00 UTC'),
|
83
|
+
:close => Time.parse('1970-01-01 20:00:00 UTC')
|
84
|
+
}]
|
85
|
+
}
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
{
|
2
|
+
"id": "196723247025808",
|
3
|
+
"name": "Local Business Sample",
|
4
|
+
"picture": "http:\/\/profile.ak.fbcdn.net\/static-ak\/rsrc.php\/v1\/y0\/r\/XsEg9L6Ie5_.jpg",
|
5
|
+
"link": "http:\/\/www.facebook.com\/pages\/Local-Business-Sample\/196723247025808",
|
6
|
+
"category": "Bar",
|
7
|
+
"location": {
|
8
|
+
"street": "\u65b0\u7530\u8fba",
|
9
|
+
"city": "Kyoto",
|
10
|
+
"country": "Japan",
|
11
|
+
"zip": "513001"
|
12
|
+
},
|
13
|
+
"parking": {
|
14
|
+
"street": 1,
|
15
|
+
"lot": 0,
|
16
|
+
"valet": 1
|
17
|
+
},
|
18
|
+
"price_range": "$ (0-10)",
|
19
|
+
"public_transit": "30 min from Kyoto St.",
|
20
|
+
"hours": {
|
21
|
+
"mon_1_open": 64800,
|
22
|
+
"mon_1_close": 100800,
|
23
|
+
"tue_1_open": 64800,
|
24
|
+
"tue_1_close": 100800
|
25
|
+
},
|
26
|
+
"attire": "Casual",
|
27
|
+
"payment_options": {
|
28
|
+
"cash_only": 0,
|
29
|
+
"visa": 1,
|
30
|
+
"amex": 1,
|
31
|
+
"mastercard": 1,
|
32
|
+
"discover": 0
|
33
|
+
},
|
34
|
+
"culinary_team": "Team FbGraph!",
|
35
|
+
"general_manager": "Nov Matake",
|
36
|
+
"restaurant_services": {
|
37
|
+
"reserve": 1,
|
38
|
+
"walkins": 0,
|
39
|
+
"groups": 1,
|
40
|
+
"kids": 0,
|
41
|
+
"takeout": 0,
|
42
|
+
"delivery": 0,
|
43
|
+
"catering": 0,
|
44
|
+
"waiter": 0,
|
45
|
+
"outdoor": 0
|
46
|
+
},
|
47
|
+
"restaurant_specialties": {
|
48
|
+
"breakfast": 0,
|
49
|
+
"lunch": 0,
|
50
|
+
"dinner": 1,
|
51
|
+
"coffee": 0,
|
52
|
+
"drinks": 1
|
53
|
+
},
|
54
|
+
"phone": "1234567890",
|
55
|
+
"can_post": true
|
56
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fb_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httpclient
|
16
|
-
requirement: &
|
16
|
+
requirement: &70278768617680 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.2.0.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70278768617680
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rack-oauth2
|
27
|
-
requirement: &
|
27
|
+
requirement: &70278768615940 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,21 @@ dependencies:
|
|
32
32
|
version: 0.14.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70278768615940
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: tzinfo
|
38
|
+
requirement: &70278768614800 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70278768614800
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: rake
|
38
|
-
requirement: &
|
49
|
+
requirement: &70278768612440 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ! '>='
|
@@ -43,10 +54,10 @@ dependencies:
|
|
43
54
|
version: '0.8'
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *70278768612440
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: cover_me
|
49
|
-
requirement: &
|
60
|
+
requirement: &70278768608100 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ! '>='
|
@@ -54,10 +65,10 @@ dependencies:
|
|
54
65
|
version: 1.2.0
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *70278768608100
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: rspec
|
60
|
-
requirement: &
|
71
|
+
requirement: &70278768605200 !ruby/object:Gem::Requirement
|
61
72
|
none: false
|
62
73
|
requirements:
|
63
74
|
- - ! '>='
|
@@ -65,10 +76,10 @@ dependencies:
|
|
65
76
|
version: '2'
|
66
77
|
type: :development
|
67
78
|
prerelease: false
|
68
|
-
version_requirements: *
|
79
|
+
version_requirements: *70278768605200
|
69
80
|
- !ruby/object:Gem::Dependency
|
70
81
|
name: webmock
|
71
|
-
requirement: &
|
82
|
+
requirement: &70278768602580 !ruby/object:Gem::Requirement
|
72
83
|
none: false
|
73
84
|
requirements:
|
74
85
|
- - ! '>='
|
@@ -76,10 +87,10 @@ dependencies:
|
|
76
87
|
version: 1.6.2
|
77
88
|
type: :development
|
78
89
|
prerelease: false
|
79
|
-
version_requirements: *
|
90
|
+
version_requirements: *70278768602580
|
80
91
|
- !ruby/object:Gem::Dependency
|
81
92
|
name: actionpack
|
82
|
-
requirement: &
|
93
|
+
requirement: &70278768601400 !ruby/object:Gem::Requirement
|
83
94
|
none: false
|
84
95
|
requirements:
|
85
96
|
- - ! '>='
|
@@ -87,7 +98,7 @@ dependencies:
|
|
87
98
|
version: 3.0.6
|
88
99
|
type: :development
|
89
100
|
prerelease: false
|
90
|
-
version_requirements: *
|
101
|
+
version_requirements: *70278768601400
|
91
102
|
description: A full-stack Facebook Graph API wrapper in Ruby.
|
92
103
|
email: nov@matake.jp
|
93
104
|
executables: []
|
@@ -472,6 +483,7 @@ files:
|
|
472
483
|
- spec/mock_json/pages/blocked/show_blocked.json
|
473
484
|
- spec/mock_json/pages/blocked/show_non_blocked.json
|
474
485
|
- spec/mock_json/pages/categories/local_business.json
|
486
|
+
- spec/mock_json/pages/categories/local_business_fixnum.json
|
475
487
|
- spec/mock_json/pages/categories/movie.json
|
476
488
|
- spec/mock_json/pages/categories/music.json
|
477
489
|
- spec/mock_json/pages/categories/person.json
|
@@ -835,6 +847,7 @@ test_files:
|
|
835
847
|
- spec/mock_json/pages/blocked/show_blocked.json
|
836
848
|
- spec/mock_json/pages/blocked/show_non_blocked.json
|
837
849
|
- spec/mock_json/pages/categories/local_business.json
|
850
|
+
- spec/mock_json/pages/categories/local_business_fixnum.json
|
838
851
|
- spec/mock_json/pages/categories/movie.json
|
839
852
|
- spec/mock_json/pages/categories/music.json
|
840
853
|
- spec/mock_json/pages/categories/person.json
|