koala 3.3.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3709b2644f9f0259e68e181d629754ffe3ba0213322cfb3bad0d369ad04543c
4
- data.tar.gz: 7c3e3760d2ee7958b199713c7308f291552ee80a7badddc9ea9434a71cb024a9
3
+ metadata.gz: fe8f0af88bb59626abb6b309322ed98a0e5f5faceca7931968f6ce8842451b0d
4
+ data.tar.gz: f813925e9a5905f34b27c95b45cef4ca282e12cee0e4a09db58160b8f5de2e78
5
5
  SHA512:
6
- metadata.gz: a22e1b9de96408d3273816150d5e0d55768f72b8b48a93ea276b7d2dc5d35f45de38cb8aad847345faf9c6997d7d0f19d21f177882cfb024e472e8681c9bbd2d
7
- data.tar.gz: 5d66a1c10d8bd3d8153eb8faa02ee7ae901aae7321141d12f39abaeb33b6193cea2e3c7215b813942b714965d6048abda867f1d269de39dbdfc0bc137f3a0dc6
6
+ metadata.gz: e6b17b4a746648c7910b6c946178f62b3fc9aadd79439e82c61169ecb98a9f1e0e47c2d54fb4a9918b620431dce46a6340c5fa1317c809ee9c287a8a9f38a14b
7
+ data.tar.gz: 1ba2fcc4f6bb844c14dba797d49d4042d7e8cab78d53251a0c2e3b88edbfcb31512a27e4f3e62e2cd2da8174f7e381c87571887954121edc3119324464e1014c
data/changelog.md CHANGED
@@ -15,6 +15,20 @@ Testing improvements:
15
15
 
16
16
  Others:
17
17
 
18
+ v3.5.0 (2023-08-23)
19
+ ======
20
+
21
+ Internal improvements:
22
+ * Raise ClientError instead of NoMethodError when body is 'null' ([#673](https://github.com/arsduo/koala/issues/673))
23
+
24
+ v3.4.0 (2023-01-05)
25
+ ======
26
+
27
+ Updated features:
28
+
29
+ * Force use by default of HTTPS (instead of HTTP) when there is no access token.
30
+ HTTP can still be used by passing :use_ssl => false in the options hash for an api call ([#678](https://github.com/arsduo/koala/pull/678/files))
31
+
18
32
  v3.3.0 (2022-09-27)
19
33
  ======
20
34
 
@@ -61,7 +61,8 @@ module Koala
61
61
  # Normally, we start with the response body. If it isn't valid JSON, we start with an empty
62
62
  # hash and fill it with error data.
63
63
  @response_hash ||= begin
64
- JSON.parse(body)
64
+ parsed_body = JSON.parse(body)
65
+ parsed_body.is_a?(Hash) ? parsed_body : {}
65
66
  rescue JSON::ParserError
66
67
  {}
67
68
  end
@@ -106,9 +106,7 @@ module Koala
106
106
  end
107
107
 
108
108
  def add_ssl_options(opts)
109
- # require https if there's a token
110
- return opts unless raw_args["access_token"]
111
-
109
+ # require https by default (can be overriden by explicitly setting other SSL options)
112
110
  {
113
111
  use_ssl: true,
114
112
  ssl: {verify: true}.merge(opts[:ssl] || {})
data/lib/koala/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Koala
2
- VERSION = "3.3.0"
2
+ VERSION = "3.5.0"
3
3
  end
@@ -63,6 +63,12 @@ module Koala
63
63
  expect(error.response_body).to eq(body)
64
64
  end
65
65
 
66
+ it "returns a ClientError if the body is null" do
67
+ body.replace("null")
68
+ expect(error).to be_a(ClientError)
69
+ expect(error.response_body).to eq(body)
70
+ end
71
+
66
72
  it "adds error data from the body" do
67
73
  error_data = {
68
74
  "type" => "FB error type",
@@ -176,9 +176,9 @@ module Koala
176
176
  end
177
177
 
178
178
  describe "ssl options" do
179
- it "does nothing if there's no access token" do
179
+ it "includes the default SSL options even if there's no access token" do
180
180
  request_options = Request.new(path: path, args: args.delete_if {|k, _v| k == "access_token"}, verb: verb, options: options).options
181
- expect(request_options).not_to include(:ssl, :use_ssl)
181
+ expect(request_options).to include(use_ssl: true, ssl: {verify: true})
182
182
  end
183
183
 
184
184
  context "if there is an access_token" do
@@ -193,9 +193,9 @@ module Koala
193
193
  end
194
194
 
195
195
  it "overrides default SSL options with what's provided" do
196
- new_ssl_options = {verify: :dunno}
197
- request_options = Request.new(path: path, args: args, verb: verb, options: options.merge(ssl: new_ssl_options)).options
198
- expect(request_options[:ssl]).to include(new_ssl_options)
196
+ new_ssl_options = {use_ssl: false, ssl:{verify: :dunno}}
197
+ request_options = Request.new(path: path, args: args, verb: verb, options: options.merge(new_ssl_options)).options
198
+ expect(request_options).to include(new_ssl_options)
199
199
  end
200
200
  end
201
201
  end
@@ -211,9 +211,17 @@ module Koala
211
211
  expect(request.server).to eq("https://foo")
212
212
  end
213
213
 
214
- context "if options[:use_ssl] is false (e.g. no access token)" do
214
+ context "if there is no access token" do
215
215
  let(:args) { {"a" => "b"} }
216
216
 
217
+ it "uses https" do
218
+ expect(request.server).to eq("https://graph.facebook.com")
219
+ end
220
+ end
221
+
222
+ context "if options[:use_ssl] is false" do
223
+ let(:options) { {use_ssl: false} }
224
+
217
225
  it "uses http" do
218
226
  expect(request.server).to eq("http://graph.facebook.com")
219
227
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koala
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Koppel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-27 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -158,7 +158,7 @@ homepage: http://github.com/arsduo/koala
158
158
  licenses:
159
159
  - MIT
160
160
  metadata: {}
161
- post_install_message:
161
+ post_install_message:
162
162
  rdoc_options:
163
163
  - "--line-numbers"
164
164
  - "--inline-source"
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  version: '0'
179
179
  requirements: []
180
180
  rubygems_version: 3.4.0.dev
181
- signing_key:
181
+ signing_key:
182
182
  specification_version: 4
183
183
  summary: A lightweight, flexible library for Facebook with support for the Graph API,
184
184
  the REST API, realtime updates, and OAuth authentication.