koala 1.0.0 → 1.2.0beta1
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/.autotest +12 -0
- data/.gitignore +3 -1
- data/.travis.yml +9 -0
- data/CHANGELOG +52 -2
- data/Gemfile +8 -0
- data/Rakefile +0 -1
- data/autotest/discover.rb +1 -0
- data/koala.gemspec +14 -14
- data/lib/koala/batch_operation.rb +74 -0
- data/lib/koala/graph_api.rb +157 -133
- data/lib/koala/graph_batch_api.rb +87 -0
- data/lib/koala/graph_collection.rb +54 -0
- data/lib/koala/http_service.rb +177 -0
- data/lib/koala/oauth.rb +181 -0
- data/lib/koala/realtime_updates.rb +23 -29
- data/lib/koala/rest_api.rb +13 -8
- data/lib/koala/test_users.rb +33 -16
- data/lib/koala/uploadable_io.rb +152 -87
- data/lib/koala/utils.rb +11 -0
- data/lib/koala.rb +54 -217
- data/readme.md +71 -52
- data/spec/cases/api_base_spec.rb +6 -6
- data/spec/cases/error_spec.rb +32 -0
- data/spec/cases/graph_and_rest_api_spec.rb +20 -3
- data/spec/cases/graph_api_batch_spec.rb +600 -0
- data/spec/cases/graph_api_spec.rb +21 -4
- data/spec/cases/http_service_spec.rb +446 -0
- data/spec/cases/koala_spec.rb +50 -0
- data/spec/cases/oauth_spec.rb +220 -201
- data/spec/cases/realtime_updates_spec.rb +45 -31
- data/spec/cases/rest_api_spec.rb +23 -7
- data/spec/cases/test_users_spec.rb +112 -52
- data/spec/cases/uploadable_io_spec.rb +92 -37
- data/spec/cases/utils_spec.rb +10 -0
- data/spec/fixtures/cat.m4v +0 -0
- data/spec/fixtures/facebook_data.yml +23 -22
- data/spec/fixtures/mock_facebook_responses.yml +201 -76
- data/spec/spec_helper.rb +30 -5
- data/spec/support/graph_api_shared_examples.rb +134 -56
- data/spec/support/json_testing_fix.rb +42 -0
- data/spec/support/koala_test.rb +163 -0
- data/spec/support/mock_http_service.rb +60 -57
- data/spec/support/ordered_hash.rb +205 -0
- data/spec/support/rest_api_shared_examples.rb +139 -15
- data/spec/support/uploadable_io_shared_examples.rb +2 -8
- metadata +98 -112
- data/lib/koala/http_services.rb +0 -146
- data/spec/cases/http_services/http_service_spec.rb +0 -54
- data/spec/cases/http_services/net_http_service_spec.rb +0 -350
- data/spec/cases/http_services/typhoeus_service_spec.rb +0 -144
- data/spec/support/live_testing_data_helper.rb +0 -40
- data/spec/support/setup_mocks_or_live.rb +0 -52
metadata
CHANGED
|
@@ -1,202 +1,188 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: koala
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 1
|
|
8
|
-
- 0
|
|
9
|
-
- 0
|
|
10
|
-
version: 1.0.0
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.2.0beta1
|
|
5
|
+
prerelease: 5
|
|
11
6
|
platform: ruby
|
|
12
|
-
authors:
|
|
7
|
+
authors:
|
|
13
8
|
- Alex Koppel, Chris Baclig, Rafi Jacoby, Context Optional
|
|
14
9
|
autorequire:
|
|
15
10
|
bindir: bin
|
|
16
11
|
cert_chain: []
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
dependencies:
|
|
20
|
-
- !ruby/object:Gem::Dependency
|
|
21
|
-
|
|
22
|
-
requirement: &
|
|
12
|
+
date: 2011-08-17 00:00:00.000000000 +02:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: multi_json
|
|
17
|
+
requirement: &70190931210420 !ruby/object:Gem::Requirement
|
|
23
18
|
none: false
|
|
24
|
-
requirements:
|
|
19
|
+
requirements:
|
|
25
20
|
- - ~>
|
|
26
|
-
- !ruby/object:Gem::Version
|
|
27
|
-
|
|
28
|
-
segments:
|
|
29
|
-
- 1
|
|
30
|
-
- 0
|
|
31
|
-
version: "1.0"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '1.0'
|
|
32
23
|
type: :runtime
|
|
33
|
-
name: json
|
|
34
|
-
version_requirements: *id001
|
|
35
|
-
- !ruby/object:Gem::Dependency
|
|
36
24
|
prerelease: false
|
|
37
|
-
|
|
25
|
+
version_requirements: *70190931210420
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: faraday
|
|
28
|
+
requirement: &70190931209740 !ruby/object:Gem::Requirement
|
|
38
29
|
none: false
|
|
39
|
-
requirements:
|
|
30
|
+
requirements:
|
|
40
31
|
- - ~>
|
|
41
|
-
- !ruby/object:Gem::Version
|
|
42
|
-
|
|
43
|
-
segments:
|
|
44
|
-
- 1
|
|
45
|
-
- 0
|
|
46
|
-
version: "1.0"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 0.7.4
|
|
47
34
|
type: :runtime
|
|
48
|
-
name: multipart-post
|
|
49
|
-
version_requirements: *id002
|
|
50
|
-
- !ruby/object:Gem::Dependency
|
|
51
35
|
prerelease: false
|
|
52
|
-
|
|
36
|
+
version_requirements: *70190931209740
|
|
37
|
+
- !ruby/object:Gem::Dependency
|
|
38
|
+
name: faraday-stack
|
|
39
|
+
requirement: &70190931200940 !ruby/object:Gem::Requirement
|
|
53
40
|
none: false
|
|
54
|
-
requirements:
|
|
41
|
+
requirements:
|
|
55
42
|
- - ~>
|
|
56
|
-
- !ruby/object:Gem::Version
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- 2
|
|
60
|
-
- 5
|
|
61
|
-
- 0
|
|
62
|
-
version: 2.5.0
|
|
63
|
-
type: :development
|
|
64
|
-
name: rspec
|
|
65
|
-
version_requirements: *id003
|
|
66
|
-
- !ruby/object:Gem::Dependency
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: 0.1.3
|
|
45
|
+
type: :runtime
|
|
67
46
|
prerelease: false
|
|
68
|
-
|
|
47
|
+
version_requirements: *70190931200940
|
|
48
|
+
- !ruby/object:Gem::Dependency
|
|
49
|
+
name: rspec
|
|
50
|
+
requirement: &70190931200100 !ruby/object:Gem::Requirement
|
|
69
51
|
none: false
|
|
70
|
-
requirements:
|
|
52
|
+
requirements:
|
|
71
53
|
- - ~>
|
|
72
|
-
- !ruby/object:Gem::Version
|
|
73
|
-
|
|
74
|
-
segments:
|
|
75
|
-
- 0
|
|
76
|
-
- 8
|
|
77
|
-
- 7
|
|
78
|
-
version: 0.8.7
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '2.5'
|
|
79
56
|
type: :development
|
|
80
|
-
name: rake
|
|
81
|
-
version_requirements: *id004
|
|
82
|
-
- !ruby/object:Gem::Dependency
|
|
83
57
|
prerelease: false
|
|
84
|
-
|
|
58
|
+
version_requirements: *70190931200100
|
|
59
|
+
- !ruby/object:Gem::Dependency
|
|
60
|
+
name: rake
|
|
61
|
+
requirement: &70190931198560 !ruby/object:Gem::Requirement
|
|
85
62
|
none: false
|
|
86
|
-
requirements:
|
|
63
|
+
requirements:
|
|
87
64
|
- - ~>
|
|
88
|
-
- !ruby/object:Gem::Version
|
|
89
|
-
|
|
90
|
-
segments:
|
|
91
|
-
- 0
|
|
92
|
-
- 2
|
|
93
|
-
- 4
|
|
94
|
-
version: 0.2.4
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: 0.8.7
|
|
95
67
|
type: :development
|
|
96
|
-
|
|
97
|
-
version_requirements: *
|
|
98
|
-
description: Koala is a lightweight, flexible Ruby SDK for Facebook. It allows read/write
|
|
68
|
+
prerelease: false
|
|
69
|
+
version_requirements: *70190931198560
|
|
70
|
+
description: Koala is a lightweight, flexible Ruby SDK for Facebook. It allows read/write
|
|
71
|
+
access to the social graph via the Graph and REST APIs, as well as support for realtime
|
|
72
|
+
updates and OAuth and Facebook Connect authentication. Koala is fully tested and
|
|
73
|
+
supports Net::HTTP and Typhoeus connections out of the box and can accept custom
|
|
74
|
+
modules for other services.
|
|
99
75
|
email: alex@alexkoppel.com
|
|
100
76
|
executables: []
|
|
101
|
-
|
|
102
77
|
extensions: []
|
|
103
|
-
|
|
104
|
-
extra_rdoc_files:
|
|
78
|
+
extra_rdoc_files:
|
|
105
79
|
- readme.md
|
|
106
80
|
- CHANGELOG
|
|
107
|
-
files:
|
|
81
|
+
files:
|
|
82
|
+
- .autotest
|
|
108
83
|
- .gitignore
|
|
84
|
+
- .travis.yml
|
|
109
85
|
- CHANGELOG
|
|
110
86
|
- Gemfile
|
|
111
87
|
- LICENSE
|
|
112
88
|
- Manifest
|
|
113
89
|
- Rakefile
|
|
90
|
+
- autotest/discover.rb
|
|
114
91
|
- koala.gemspec
|
|
115
92
|
- lib/koala.rb
|
|
93
|
+
- lib/koala/batch_operation.rb
|
|
116
94
|
- lib/koala/graph_api.rb
|
|
117
|
-
- lib/koala/
|
|
95
|
+
- lib/koala/graph_batch_api.rb
|
|
96
|
+
- lib/koala/graph_collection.rb
|
|
97
|
+
- lib/koala/http_service.rb
|
|
98
|
+
- lib/koala/oauth.rb
|
|
118
99
|
- lib/koala/realtime_updates.rb
|
|
119
100
|
- lib/koala/rest_api.rb
|
|
120
101
|
- lib/koala/test_users.rb
|
|
121
102
|
- lib/koala/uploadable_io.rb
|
|
103
|
+
- lib/koala/utils.rb
|
|
122
104
|
- readme.md
|
|
123
105
|
- spec/cases/api_base_spec.rb
|
|
106
|
+
- spec/cases/error_spec.rb
|
|
124
107
|
- spec/cases/graph_and_rest_api_spec.rb
|
|
108
|
+
- spec/cases/graph_api_batch_spec.rb
|
|
125
109
|
- spec/cases/graph_api_spec.rb
|
|
126
|
-
- spec/cases/
|
|
127
|
-
- spec/cases/
|
|
128
|
-
- spec/cases/http_services/typhoeus_service_spec.rb
|
|
110
|
+
- spec/cases/http_service_spec.rb
|
|
111
|
+
- spec/cases/koala_spec.rb
|
|
129
112
|
- spec/cases/oauth_spec.rb
|
|
130
113
|
- spec/cases/realtime_updates_spec.rb
|
|
131
114
|
- spec/cases/rest_api_spec.rb
|
|
132
115
|
- spec/cases/test_users_spec.rb
|
|
133
116
|
- spec/cases/uploadable_io_spec.rb
|
|
117
|
+
- spec/cases/utils_spec.rb
|
|
134
118
|
- spec/fixtures/beach.jpg
|
|
119
|
+
- spec/fixtures/cat.m4v
|
|
135
120
|
- spec/fixtures/facebook_data.yml
|
|
136
121
|
- spec/fixtures/mock_facebook_responses.yml
|
|
137
122
|
- spec/spec_helper.rb
|
|
138
123
|
- spec/support/graph_api_shared_examples.rb
|
|
139
|
-
- spec/support/
|
|
124
|
+
- spec/support/json_testing_fix.rb
|
|
125
|
+
- spec/support/koala_test.rb
|
|
140
126
|
- spec/support/mock_http_service.rb
|
|
127
|
+
- spec/support/ordered_hash.rb
|
|
141
128
|
- spec/support/rest_api_shared_examples.rb
|
|
142
|
-
- spec/support/setup_mocks_or_live.rb
|
|
143
129
|
- spec/support/uploadable_io_shared_examples.rb
|
|
130
|
+
has_rdoc: true
|
|
144
131
|
homepage: http://github.com/arsduo/koala
|
|
145
132
|
licenses: []
|
|
146
|
-
|
|
147
133
|
post_install_message:
|
|
148
|
-
rdoc_options:
|
|
134
|
+
rdoc_options:
|
|
149
135
|
- --line-numbers
|
|
150
136
|
- --inline-source
|
|
151
137
|
- --title
|
|
152
138
|
- Koala
|
|
153
|
-
require_paths:
|
|
139
|
+
require_paths:
|
|
154
140
|
- lib
|
|
155
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
142
|
none: false
|
|
157
|
-
requirements:
|
|
158
|
-
- -
|
|
159
|
-
- !ruby/object:Gem::Version
|
|
160
|
-
|
|
161
|
-
segments:
|
|
143
|
+
requirements:
|
|
144
|
+
- - ! '>='
|
|
145
|
+
- !ruby/object:Gem::Version
|
|
146
|
+
version: '0'
|
|
147
|
+
segments:
|
|
162
148
|
- 0
|
|
163
|
-
|
|
164
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
|
+
hash: 4017352999765369439
|
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
151
|
none: false
|
|
166
|
-
requirements:
|
|
167
|
-
- -
|
|
168
|
-
- !ruby/object:Gem::Version
|
|
169
|
-
|
|
170
|
-
segments:
|
|
171
|
-
- 1
|
|
172
|
-
- 2
|
|
173
|
-
version: "1.2"
|
|
152
|
+
requirements:
|
|
153
|
+
- - ! '>='
|
|
154
|
+
- !ruby/object:Gem::Version
|
|
155
|
+
version: '1.2'
|
|
174
156
|
requirements: []
|
|
175
|
-
|
|
176
157
|
rubyforge_project:
|
|
177
|
-
rubygems_version: 1.
|
|
158
|
+
rubygems_version: 1.6.2
|
|
178
159
|
signing_key:
|
|
179
160
|
specification_version: 3
|
|
180
|
-
summary: A lightweight, flexible library for Facebook with support for the Graph API,
|
|
181
|
-
|
|
161
|
+
summary: A lightweight, flexible library for Facebook with support for the Graph API,
|
|
162
|
+
the REST API, realtime updates, and OAuth authentication.
|
|
163
|
+
test_files:
|
|
182
164
|
- spec/cases/api_base_spec.rb
|
|
165
|
+
- spec/cases/error_spec.rb
|
|
183
166
|
- spec/cases/graph_and_rest_api_spec.rb
|
|
167
|
+
- spec/cases/graph_api_batch_spec.rb
|
|
184
168
|
- spec/cases/graph_api_spec.rb
|
|
185
|
-
- spec/cases/
|
|
186
|
-
- spec/cases/
|
|
187
|
-
- spec/cases/http_services/typhoeus_service_spec.rb
|
|
169
|
+
- spec/cases/http_service_spec.rb
|
|
170
|
+
- spec/cases/koala_spec.rb
|
|
188
171
|
- spec/cases/oauth_spec.rb
|
|
189
172
|
- spec/cases/realtime_updates_spec.rb
|
|
190
173
|
- spec/cases/rest_api_spec.rb
|
|
191
174
|
- spec/cases/test_users_spec.rb
|
|
192
175
|
- spec/cases/uploadable_io_spec.rb
|
|
176
|
+
- spec/cases/utils_spec.rb
|
|
193
177
|
- spec/fixtures/beach.jpg
|
|
178
|
+
- spec/fixtures/cat.m4v
|
|
194
179
|
- spec/fixtures/facebook_data.yml
|
|
195
180
|
- spec/fixtures/mock_facebook_responses.yml
|
|
196
181
|
- spec/spec_helper.rb
|
|
197
182
|
- spec/support/graph_api_shared_examples.rb
|
|
198
|
-
- spec/support/
|
|
183
|
+
- spec/support/json_testing_fix.rb
|
|
184
|
+
- spec/support/koala_test.rb
|
|
199
185
|
- spec/support/mock_http_service.rb
|
|
186
|
+
- spec/support/ordered_hash.rb
|
|
200
187
|
- spec/support/rest_api_shared_examples.rb
|
|
201
|
-
- spec/support/setup_mocks_or_live.rb
|
|
202
188
|
- spec/support/uploadable_io_shared_examples.rb
|
data/lib/koala/http_services.rb
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
module Koala
|
|
2
|
-
class Response
|
|
3
|
-
attr_reader :status, :body, :headers
|
|
4
|
-
def initialize(status, body, headers)
|
|
5
|
-
@status = status
|
|
6
|
-
@body = body
|
|
7
|
-
@headers = headers
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
module HTTPService
|
|
12
|
-
# common functionality for all HTTP services
|
|
13
|
-
def self.included(base)
|
|
14
|
-
base.class_eval do
|
|
15
|
-
class << self
|
|
16
|
-
attr_accessor :always_use_ssl
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def self.server(options = {})
|
|
20
|
-
"#{options[:beta] ? "beta." : ""}#{options[:rest_api] ? Facebook::REST_SERVER : Facebook::GRAPH_SERVER}"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
protected
|
|
24
|
-
|
|
25
|
-
def self.params_require_multipart?(param_hash)
|
|
26
|
-
param_hash.any? { |key, value| value.kind_of?(Koala::UploadableIO) }
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def self.multipart_requires_content_type?
|
|
30
|
-
true
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
module NetHTTPService
|
|
37
|
-
# this service uses Net::HTTP to send requests to the graph
|
|
38
|
-
def self.included(base)
|
|
39
|
-
base.class_eval do
|
|
40
|
-
require "net/http" unless defined?(Net::HTTP)
|
|
41
|
-
require "net/https"
|
|
42
|
-
require "net/http/post/multipart"
|
|
43
|
-
|
|
44
|
-
include Koala::HTTPService
|
|
45
|
-
|
|
46
|
-
def self.make_request(path, args, verb, options = {})
|
|
47
|
-
# We translate args to a valid query string. If post is specified,
|
|
48
|
-
# we send a POST request to the given path with the given arguments.
|
|
49
|
-
|
|
50
|
-
# by default, we use SSL only for private requests
|
|
51
|
-
# this makes public requests faster
|
|
52
|
-
private_request = args["access_token"] || @always_use_ssl || options[:use_ssl]
|
|
53
|
-
|
|
54
|
-
# if the verb isn't get or post, send it as a post argument
|
|
55
|
-
args.merge!({:method => verb}) && verb = "post" if verb != "get" && verb != "post"
|
|
56
|
-
|
|
57
|
-
http = create_http(server(options), private_request, options)
|
|
58
|
-
http.use_ssl = true if private_request
|
|
59
|
-
|
|
60
|
-
result = http.start do |http|
|
|
61
|
-
response, body = if verb == "post"
|
|
62
|
-
if params_require_multipart? args
|
|
63
|
-
http.request Net::HTTP::Post::Multipart.new path, encode_multipart_params(args)
|
|
64
|
-
else
|
|
65
|
-
http.post(path, encode_params(args))
|
|
66
|
-
end
|
|
67
|
-
else
|
|
68
|
-
http.get("#{path}?#{encode_params(args)}")
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
Koala::Response.new(response.code.to_i, body, response)
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
protected
|
|
76
|
-
def self.encode_params(param_hash)
|
|
77
|
-
# unfortunately, we can't use to_query because that's Rails, not Ruby
|
|
78
|
-
# if no hash (e.g. no auth token) return empty string
|
|
79
|
-
((param_hash || {}).collect do |key_and_value|
|
|
80
|
-
key_and_value[1] = key_and_value[1].to_json if key_and_value[1].class != String
|
|
81
|
-
"#{key_and_value[0].to_s}=#{CGI.escape key_and_value[1]}"
|
|
82
|
-
end).join("&")
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def self.encode_multipart_params(param_hash)
|
|
86
|
-
Hash[*param_hash.collect do |key, value|
|
|
87
|
-
[key, value.kind_of?(Koala::UploadableIO) ? value.to_upload_io : value]
|
|
88
|
-
end.flatten]
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def self.create_http(server, private_request, options)
|
|
92
|
-
if options[:proxy]
|
|
93
|
-
proxy = URI.parse(options[:proxy])
|
|
94
|
-
http = Net::HTTP.new(server, private_request ? 443 : nil,
|
|
95
|
-
proxy.host, proxy.port, proxy.user, proxy.password)
|
|
96
|
-
else
|
|
97
|
-
http = Net::HTTP.new(server, private_request ? 443 : nil)
|
|
98
|
-
end
|
|
99
|
-
if options[:timeout]
|
|
100
|
-
http.open_timeout = options[:timeout]
|
|
101
|
-
http.read_timeout = options[:timeout]
|
|
102
|
-
end
|
|
103
|
-
http
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
module TyphoeusService
|
|
111
|
-
# this service uses Typhoeus to send requests to the graph
|
|
112
|
-
|
|
113
|
-
def self.included(base)
|
|
114
|
-
base.class_eval do
|
|
115
|
-
require "typhoeus" unless defined?(Typhoeus)
|
|
116
|
-
include Typhoeus
|
|
117
|
-
|
|
118
|
-
include Koala::HTTPService
|
|
119
|
-
|
|
120
|
-
def self.make_request(path, args, verb, options = {})
|
|
121
|
-
# if the verb isn't get or post, send it as a post argument
|
|
122
|
-
args.merge!({:method => verb}) && verb = "post" if verb != "get" && verb != "post"
|
|
123
|
-
|
|
124
|
-
# switch any UploadableIOs to the files Typhoeus expects
|
|
125
|
-
args.each_pair {|key, value| args[key] = value.to_file if value.is_a?(UploadableIO)}
|
|
126
|
-
|
|
127
|
-
# you can pass arguments directly to Typhoeus using the :typhoeus_options key
|
|
128
|
-
typhoeus_options = {:params => args}.merge(options[:typhoeus_options] || {})
|
|
129
|
-
|
|
130
|
-
# by default, we use SSL only for private requests (e.g. with access token)
|
|
131
|
-
# this makes public requests faster
|
|
132
|
-
prefix = (args["access_token"] || @always_use_ssl || options[:use_ssl]) ? "https" : "http"
|
|
133
|
-
|
|
134
|
-
response = self.send(verb, "#{prefix}://#{server(options)}#{path}", typhoeus_options)
|
|
135
|
-
Koala::Response.new(response.code, response.body, response.headers_hash)
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
private
|
|
139
|
-
|
|
140
|
-
def self.multipart_requires_content_type?
|
|
141
|
-
false # Typhoeus handles multipart file types, we don't have to require it
|
|
142
|
-
end
|
|
143
|
-
end # class_eval
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class Bear
|
|
5
|
-
include Koala::HTTPService
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
describe "Koala::HTTPService" do
|
|
9
|
-
|
|
10
|
-
describe "common methods" do
|
|
11
|
-
describe "always_use_ssl accessor" do
|
|
12
|
-
it "should be added" do
|
|
13
|
-
# in Ruby 1.8, .methods returns strings
|
|
14
|
-
# in Ruby 1.9, .method returns symbols
|
|
15
|
-
Bear.methods.collect {|m| m.to_sym}.should include(:always_use_ssl)
|
|
16
|
-
Bear.methods.collect {|m| m.to_sym}.should include(:always_use_ssl=)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe "server" do
|
|
21
|
-
describe "without options[:beta]" do
|
|
22
|
-
it "should return the rest server if options[:rest_api]" do
|
|
23
|
-
Bear.server(:rest_api => true).should == Koala::Facebook::REST_SERVER
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "should return the rest server if !options[:rest_api]" do
|
|
27
|
-
Bear.server(:rest_api => false).should == Koala::Facebook::GRAPH_SERVER
|
|
28
|
-
Bear.server({}).should == Koala::Facebook::GRAPH_SERVER
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
describe "without options[:beta]" do
|
|
33
|
-
before :each do
|
|
34
|
-
@options = {:beta => true}
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "should return the rest server if options[:rest_api]" do
|
|
38
|
-
server = Bear.server(@options.merge(:rest_api => true))
|
|
39
|
-
server.should =~ Regexp.new(Koala::Facebook::REST_SERVER)
|
|
40
|
-
server.should =~ /beta\./
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "should return the rest server if !options[:rest_api]" do
|
|
44
|
-
server = Bear.server(:beta => true)
|
|
45
|
-
server.should =~ Regexp.new(Koala::Facebook::GRAPH_SERVER)
|
|
46
|
-
server.should =~ /beta\./
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
end
|