facebook_sdk 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/facebook_sdk.gemspec +1 -1
- data/lib/facebook_sdk.rb +11 -3
- data/lib/facebook_sdk/apiexception.rb +13 -0
- data/lib/facebook_sdk/configuration.rb +2 -1
- data/lib/facebook_sdk/faraday-middleware/hashie_converter.rb +14 -0
- data/lib/facebook_sdk/{middleware → faraday-middleware}/json_decoder.rb +1 -1
- data/lib/facebook_sdk/faraday-middleware/raise_api_exception.rb +16 -0
- data/lib/facebook_sdk/{api.rb → modules/api.rb} +1 -4
- data/lib/facebook_sdk/version.rb +1 -1
- data/test/test_basic.rb +11 -0
- metadata +17 -14
data/facebook_sdk.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = FacebookSDK::VERSION
|
8
8
|
s.authors = ["Erick Zetta"]
|
9
9
|
s.email = ["erick.zetta@gmail.com"]
|
10
|
-
s.homepage = ""
|
10
|
+
s.homepage = "https://github.com/eckz/facebook_sdk"
|
11
11
|
s.summary = %q{Facebook SDK for Graph API}
|
12
12
|
s.description = %q{Facebook SDK for Graph API}
|
13
13
|
|
data/lib/facebook_sdk.rb
CHANGED
@@ -2,10 +2,14 @@ require "facebook_sdk/version"
|
|
2
2
|
require "forwardable"
|
3
3
|
require "faraday"
|
4
4
|
|
5
|
+
require "facebook_sdk/apiexception"
|
5
6
|
require "facebook_sdk/configuration"
|
6
|
-
require "facebook_sdk/api"
|
7
7
|
|
8
|
-
require "facebook_sdk/
|
8
|
+
require "facebook_sdk/modules/api"
|
9
|
+
|
10
|
+
require "facebook_sdk/faraday-middleware/json_decoder"
|
11
|
+
require "facebook_sdk/faraday-middleware/hashie_converter"
|
12
|
+
require "facebook_sdk/faraday-middleware/raise_api_exception"
|
9
13
|
|
10
14
|
module FacebookSDK
|
11
15
|
class Session
|
@@ -24,8 +28,12 @@ module FacebookSDK
|
|
24
28
|
#builder.use Faraday::Response::Logger # log the request to STDOUT
|
25
29
|
|
26
30
|
builder.use Faraday::Adapter::NetHttp # make http requests with Net::HTTP
|
27
|
-
builder.use FacebookSDK::Middleware::JSONDecoder # use own JSONDecoder
|
28
31
|
|
32
|
+
# order inversed (in response)
|
33
|
+
|
34
|
+
builder.use FacebookSDK::FaradayMiddleware::RaiseApiException
|
35
|
+
builder.use FacebookSDK::FaradayMiddleware::HashieConverter
|
36
|
+
builder.use FacebookSDK::FaradayMiddleware::JSONDecoder # use own JSONDecoder
|
29
37
|
|
30
38
|
@config = Configuration.new
|
31
39
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module FacebookSDK
|
4
|
+
module FaradayMiddleware
|
5
|
+
class RaiseApiException < Faraday::Response::Middleware
|
6
|
+
|
7
|
+
def on_complete(env)
|
8
|
+
case env[:status]
|
9
|
+
when 400...499
|
10
|
+
raise FacebookSDK::ApiException, env[:body]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/facebook_sdk/version.rb
CHANGED
data/test/test_basic.rb
CHANGED
@@ -17,4 +17,15 @@ class TestBasic < FacebookSDK::TestCase
|
|
17
17
|
assert_equal "Facebook Platform", p.name
|
18
18
|
assert_equal "http://developers.facebook.com", p.website
|
19
19
|
end
|
20
|
+
|
21
|
+
def test_exception_without_access_token
|
22
|
+
fb = FacebookSDK::Session.new do |config|
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
assert_raise FacebookSDK::ApiException do
|
27
|
+
p = fb.api '/me'
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
20
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facebook_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-21 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: test-unit
|
16
|
-
requirement: &
|
16
|
+
requirement: &73695500 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *73695500
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: turn
|
27
|
-
requirement: &
|
27
|
+
requirement: &73695190 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *73695190
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &73694830 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *73694830
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: hashie
|
49
|
-
requirement: &
|
49
|
+
requirement: &73694470 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *73694470
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: faraday
|
60
|
-
requirement: &
|
60
|
+
requirement: &73694040 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *73694040
|
69
69
|
description: Facebook SDK for Graph API
|
70
70
|
email:
|
71
71
|
- erick.zetta@gmail.com
|
@@ -78,13 +78,16 @@ files:
|
|
78
78
|
- Rakefile
|
79
79
|
- facebook_sdk.gemspec
|
80
80
|
- lib/facebook_sdk.rb
|
81
|
-
- lib/facebook_sdk/
|
81
|
+
- lib/facebook_sdk/apiexception.rb
|
82
82
|
- lib/facebook_sdk/configuration.rb
|
83
|
-
- lib/facebook_sdk/middleware/
|
83
|
+
- lib/facebook_sdk/faraday-middleware/hashie_converter.rb
|
84
|
+
- lib/facebook_sdk/faraday-middleware/json_decoder.rb
|
85
|
+
- lib/facebook_sdk/faraday-middleware/raise_api_exception.rb
|
86
|
+
- lib/facebook_sdk/modules/api.rb
|
84
87
|
- lib/facebook_sdk/version.rb
|
85
88
|
- test/helper.rb
|
86
89
|
- test/test_basic.rb
|
87
|
-
homepage:
|
90
|
+
homepage: https://github.com/eckz/facebook_sdk
|
88
91
|
licenses: []
|
89
92
|
post_install_message:
|
90
93
|
rdoc_options: []
|