pliny 0.27.0 → 0.27.1

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: 89f96d51333f4f66bf1f811901534d2298b2a27ce8151cfe7d1ccd98cc28580d
4
- data.tar.gz: 8282e7296e129a9abbafd1ff9bd9faba51458596759568646d5b09528dda5289
3
+ metadata.gz: a4f293533ee05722c6e85a425dd35414c8bf88e8055371a6b4208486334c6063
4
+ data.tar.gz: 10c679736c876907897d054ef84053dd1b7fb48b75cf7b364557dfc7e0e644c1
5
5
  SHA512:
6
- metadata.gz: 1ea78c66a6bceadaaaeaa4a4314b41fe4fcc8c89b012e4d9ea5f5abeef4c582917b6ff725e4bf174b5d3b4bbce52eb1007e81b9e5d038f67498dd334560b4675
7
- data.tar.gz: 22d625853f9a7185ad1209af6c2d6374f4d4c3d1e92d122f68ca294bcdcae4e53f383b0414c4aa340886b316d04c93c1ab8a529bb1500c00452cb7655a59b365
6
+ metadata.gz: bbe4f48bb7a51e5709684dc8a2261a7286a146b9a58d2326e87f6cf581d2850a1de1f09ad8f469537b1cc7ed19807521ee7e01e0d8244994b83f37a5095fc175
7
+ data.tar.gz: 9c1360812d50eb5832de40ca3fe3c569e204794397157d985da0fa0c353a16ffece435b158a7073a01627dd263a8932d1be0ccf32961d24bf7574cacaa946b52
@@ -1,6 +1,7 @@
1
1
  require "logger"
2
2
  require "sequel"
3
3
  require "sequel/extensions/migration"
4
+ require "stringio"
4
5
 
5
6
  module Pliny
6
7
  class DbSupport
@@ -21,10 +21,21 @@ module Pliny::Helpers
21
21
  def load_params(data)
22
22
  # Sinatra 1.x only supports the method. Sinatra 2.x only supports the class
23
23
  if defined?(Sinatra::IndifferentHash)
24
- Sinatra::IndifferentHash[data]
24
+ indifferent_params_v2(data)
25
25
  else
26
26
  indifferent_params(data)
27
27
  end
28
28
  end
29
+
30
+ def indifferent_params_v2(data)
31
+ case data
32
+ when Hash
33
+ Sinatra::IndifferentHash[data]
34
+ when Array
35
+ data.map { |item| indifferent_params_v2(item) }
36
+ else
37
+ data
38
+ end
39
+ end
29
40
  end
30
41
  end
@@ -1,3 +1,3 @@
1
1
  module Pliny
2
- VERSION = "0.27.0"
2
+ VERSION = "0.27.1"
3
3
  end
@@ -1,7 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Pliny::Helpers::Params do
4
-
5
4
  def app
6
5
  Sinatra.new do
7
6
  helpers Pliny::Helpers::Params
@@ -12,17 +11,27 @@ describe Pliny::Helpers::Params do
12
11
  end
13
12
 
14
13
  it "loads json params" do
15
- post "/", {hello: "world"}.to_json, {'CONTENT_TYPE' => 'application/json'}
14
+ post "/", {hello: "world"}.to_json, {"CONTENT_TYPE" => "application/json"}
16
15
  assert_equal "{\"hello\":\"world\"}", last_response.body
17
16
  end
18
17
 
18
+ it "loads json array of params" do
19
+ post "/", [{hello: "world"}, {goodbye: "moon"}].to_json, {"CONTENT_TYPE" => "application/json"}
20
+ assert_equal "[{\"hello\":\"world\"},{\"goodbye\":\"moon\"}]", last_response.body
21
+ end
22
+
23
+ it "loads json array of arrays of params" do
24
+ post "/", [[{hello: "world"}], [{goodbye: "moon"}]].to_json, {"CONTENT_TYPE" => "application/json"}
25
+ assert_equal "[[{\"hello\":\"world\"}],[{\"goodbye\":\"moon\"}]]", last_response.body
26
+ end
27
+
19
28
  it "loads form data params" do
20
29
  post "/", {hello: "world"}
21
30
  assert_equal "{\"hello\":\"world\"}", last_response.body
22
31
  end
23
32
 
24
33
  it "loads from an unknown content type" do
25
- post "/", "<hello>world</hello>", {'CONTENT_TYPE' => 'application/xml'}
34
+ post "/", "<hello>world</hello>", {"CONTENT_TYPE" => "application/xml"}
26
35
  assert_equal "{}", last_response.body
27
36
  end
28
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pliny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.0
4
+ version: 0.27.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandur Leach
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-18 00:00:00.000000000 Z
12
+ date: 2020-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -195,22 +195,22 @@ dependencies:
195
195
  name: rspec
196
196
  requirement: !ruby/object:Gem::Requirement
197
197
  requirements:
198
- - - "~>"
199
- - !ruby/object:Gem::Version
200
- version: '3.1'
201
198
  - - ">="
202
199
  - !ruby/object:Gem::Version
203
200
  version: 3.1.0
201
+ - - "~>"
202
+ - !ruby/object:Gem::Version
203
+ version: '3.1'
204
204
  type: :development
205
205
  prerelease: false
206
206
  version_requirements: !ruby/object:Gem::Requirement
207
207
  requirements:
208
- - - "~>"
209
- - !ruby/object:Gem::Version
210
- version: '3.1'
211
208
  - - ">="
212
209
  - !ruby/object:Gem::Version
213
210
  version: 3.1.0
211
+ - - "~>"
212
+ - !ruby/object:Gem::Version
213
+ version: '3.1'
214
214
  - !ruby/object:Gem::Dependency
215
215
  name: sinatra-contrib
216
216
  requirement: !ruby/object:Gem::Requirement
@@ -303,42 +303,42 @@ dependencies:
303
303
  name: rollbar
304
304
  requirement: !ruby/object:Gem::Requirement
305
305
  requirements:
306
- - - "~>"
307
- - !ruby/object:Gem::Version
308
- version: '2.11'
309
306
  - - ">="
310
307
  - !ruby/object:Gem::Version
311
308
  version: 2.11.0
309
+ - - "~>"
310
+ - !ruby/object:Gem::Version
311
+ version: '2.11'
312
312
  type: :development
313
313
  prerelease: false
314
314
  version_requirements: !ruby/object:Gem::Requirement
315
315
  requirements:
316
- - - "~>"
317
- - !ruby/object:Gem::Version
318
- version: '2.11'
319
316
  - - ">="
320
317
  - !ruby/object:Gem::Version
321
318
  version: 2.11.0
319
+ - - "~>"
320
+ - !ruby/object:Gem::Version
321
+ version: '2.11'
322
322
  - !ruby/object:Gem::Dependency
323
323
  name: sequel
324
324
  requirement: !ruby/object:Gem::Requirement
325
325
  requirements:
326
- - - "~>"
327
- - !ruby/object:Gem::Version
328
- version: '4.9'
329
326
  - - ">="
330
327
  - !ruby/object:Gem::Version
331
328
  version: 4.9.0
329
+ - - "~>"
330
+ - !ruby/object:Gem::Version
331
+ version: '4.9'
332
332
  type: :development
333
333
  prerelease: false
334
334
  version_requirements: !ruby/object:Gem::Requirement
335
335
  requirements:
336
- - - "~>"
337
- - !ruby/object:Gem::Version
338
- version: '4.9'
339
336
  - - ">="
340
337
  - !ruby/object:Gem::Version
341
338
  version: 4.9.0
339
+ - - "~>"
340
+ - !ruby/object:Gem::Version
341
+ version: '4.9'
342
342
  - !ruby/object:Gem::Dependency
343
343
  name: rubocop
344
344
  requirement: !ruby/object:Gem::Requirement
@@ -530,8 +530,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
530
530
  - !ruby/object:Gem::Version
531
531
  version: '0'
532
532
  requirements: []
533
- rubyforge_project:
534
- rubygems_version: 2.7.4
533
+ rubygems_version: 3.0.6
535
534
  signing_key:
536
535
  specification_version: 4
537
536
  summary: Basic tooling to support API apps in Sinatra