sinatra-wanted 0.8.2 → 0.8.4

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: 7cebe8a6afda6c950d71167b5656d2456c22c8894d06a224a969f49c8f01e6f4
4
- data.tar.gz: 32ef7d621342e14718c5d4a4f18ae769d3141fa6bfea17b098e257f61b02aa94
3
+ metadata.gz: 9101f145fd635df26d860b131adc7d6fbe0f1196d228016dbd010c52bb939a33
4
+ data.tar.gz: b859f5eec52397e2ac3b7dde629f0fe2e9c78d28a3fe2ed452da9c8755ef69a8
5
5
  SHA512:
6
- metadata.gz: 0aa57b280ce6d9dc9f56def9bb3dd8a09f1e99269bcd968ad298c63f130b5390b269f94e4dc6e04fba3752727945e94c0f502897694ad4a28ca96478e006309b
7
- data.tar.gz: f8688d782efd075a6748485d12740c58b0369c1e6f1702db6006f4ec9dc2ab29020f78e37258047309a33a2e6451bb18494297dac7eafc91b45c261470f45ab7
6
+ metadata.gz: 3172c6004a66b9065ddbd488e9e1f96ee1b402cc1c0764901197401490a679324226ba9a800e7ead3ae4d9096eb318675dc88414aad75c0135f34ec87c061fd0
7
+ data.tar.gz: 851153cad21081aa85292ce156fa6e4ae17bbde52f4a4503c8a56c04406faf6c5cbb2dc68f9b8e745565a415f547a35c26a23c49adb7a5db2b44b6922fd361dc
@@ -2,7 +2,7 @@ module Sinatra
2
2
  module Helpers
3
3
  module Wanted
4
4
  # Version
5
- VERSION = "0.8.2"
5
+ VERSION = "0.8.4"
6
6
  end
7
7
  end
8
8
  end
@@ -11,6 +11,9 @@ module Sinatra::Helpers::Wanted
11
11
  end
12
12
  }.freeze
13
13
 
14
+ # List of exception that should be deal as Not Found
15
+ NotFoundList = []
16
+
14
17
  # Generic exception.
15
18
  # Only the inherited exceptions are raised.
16
19
  class WantedError < StandardError
@@ -110,8 +113,11 @@ module Sinatra::Helpers::Wanted
110
113
  end
111
114
  value, id = if param.kind_of?(Symbol)
112
115
  if params.include?(param)
113
- then [ params.fetch(param) { NO_VALUE }, param ]
114
- else [ nil, param ]
116
+ then
117
+ v = params[param]
118
+ [ v.nil? ? NO_VALUE : v, param ]
119
+ else
120
+ [ nil, param ]
115
121
  end
116
122
  else
117
123
  [ param, nil ]
@@ -141,14 +147,23 @@ module Sinatra::Helpers::Wanted
141
147
  value = Dry::Types::Undefined
142
148
  end
143
149
  end
144
-
150
+
145
151
  # Build value from various check/conversion
146
152
  if type_method
147
153
  value = type.public_send(type_method, value)
148
154
  end
149
155
  if !value.nil? && get_method
150
156
  val = value
151
- value = getter.public_send(get_method, value)
157
+ value = if NotFoundList.empty?
158
+ getter.public_send(get_method, value)
159
+ else
160
+ begin
161
+ getter.public_send(get_method, value)
162
+ rescue *NotFoundList
163
+ nil
164
+ end
165
+ end
166
+
152
167
  # Check if we consider it as not found
153
168
  if value.nil?
154
169
  case not_found
@@ -9,13 +9,9 @@ Gem::Specification.new do |s|
9
9
  s.description = <<~EOF
10
10
  Ease processing of parameters in Sinatra framework.
11
11
  Integrates well with dry-types, sequel, ...
12
-
13
- Example:
14
- want! :user, Dry::Types::String, User
15
- want? :expired, Dry::Types::Params::Bool.default(true)
16
12
  EOF
17
13
 
18
- s.homepage = 'https://gitlab.com/sdalu/sinatra-wanted'
14
+ s.homepage = 'https://github.com/sdalu/sinatra-wanted'
19
15
  s.license = 'MIT'
20
16
 
21
17
  s.authors = [ "Stéphane D'Alu" ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-wanted
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stéphane D'Alu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-28 00:00:00.000000000 Z
11
+ date: 2021-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -55,10 +55,6 @@ dependencies:
55
55
  description: |
56
56
  Ease processing of parameters in Sinatra framework.
57
57
  Integrates well with dry-types, sequel, ...
58
-
59
- Example:
60
- want! :user, Dry::Types::String, User
61
- want? :expired, Dry::Types::Params::Bool.default(true)
62
58
  email:
63
59
  - stephane.dalu@insa-lyon.fr
64
60
  executables: []
@@ -69,7 +65,7 @@ files:
69
65
  - lib/sinatra/helpers/wanted.rb
70
66
  - lib/sinatra/helpers/wanted/version.rb
71
67
  - sinatra-wanted.gemspec
72
- homepage: https://gitlab.com/sdalu/sinatra-wanted
68
+ homepage: https://github.com/sdalu/sinatra-wanted
73
69
  licenses:
74
70
  - MIT
75
71
  metadata: {}