sinatra-param 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/coverage/index.html +2 -2
- data/lib/sinatra/param.rb +2 -2
- data/lib/sinatra/param/version.rb +1 -1
- data/sinatra-param-1.2.1.gem +0 -0
- data/spec/dummy/app.rb +5 -0
- data/spec/parameter_transformations_spec.rb +7 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bfb3b1d56f4f3f6121fc255807db2ab2955c821
|
4
|
+
data.tar.gz: 1ee2431a66db098230a2547154caaec38657e3ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c9c46a5f50f40bf28163357db2875f0156bccb5887f907c84a0ebfb889ecb84b0715cc3db5f3ed7c102717a14cdce4eadb49165fe63d23b011818cebfde18c9
|
7
|
+
data.tar.gz: 8857b062e3ac962278f880d8e922cd9686c525b5ee43318150aee043d223df21fc4667f81cf5640e1a7f0b9b5a48cf0aeba92a0a3cdcbe9c8b93085f38576cd5
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sinatra-param (1.2.
|
4
|
+
sinatra-param (1.2.2)
|
5
5
|
sinatra (~> 1.3)
|
6
6
|
|
7
7
|
GEM
|
@@ -10,7 +10,7 @@ GEM
|
|
10
10
|
diff-lcs (1.2.4)
|
11
11
|
multi_json (1.7.2)
|
12
12
|
rack (1.5.2)
|
13
|
-
rack-protection (1.5.
|
13
|
+
rack-protection (1.5.3)
|
14
14
|
rack
|
15
15
|
rack-test (0.6.2)
|
16
16
|
rack (>= 1.0)
|
@@ -27,7 +27,7 @@ GEM
|
|
27
27
|
multi_json (~> 1.0)
|
28
28
|
simplecov-html (~> 0.7.1)
|
29
29
|
simplecov-html (0.7.1)
|
30
|
-
sinatra (1.4.
|
30
|
+
sinatra (1.4.5)
|
31
31
|
rack (~> 1.4)
|
32
32
|
rack-protection (~> 1.4)
|
33
33
|
tilt (~> 1.3, >= 1.3.4)
|
data/coverage/index.html
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
<img src="./assets/0.7.1/loading.gif" alt="loading"/>
|
15
15
|
</div>
|
16
16
|
<div id="wrapper" style="display:none;">
|
17
|
-
<div class="timestamp">Generated <abbr class="timeago" title="2014-04-
|
17
|
+
<div class="timestamp">Generated <abbr class="timeago" title="2014-04-08T11:42:12-07:00">2014-04-08T11:42:12-07:00</abbr></div>
|
18
18
|
<ul class="group_tabs"></ul>
|
19
19
|
|
20
20
|
<div id="content">
|
@@ -213,7 +213,7 @@
|
|
213
213
|
<li class="covered" data-hits="74" data-linenumber="21">
|
214
214
|
<span class="hits">74</span>
|
215
215
|
|
216
|
-
<code class="ruby"> params[name] = (options[:default].call if options[:default].
|
216
|
+
<code class="ruby"> params[name] = (options[:default].call if options[:default].respond_to?(:call)) || options[:default] if params[name].nil? and options[:default]</code>
|
217
217
|
</li>
|
218
218
|
|
219
219
|
<li class="covered" data-hits="74" data-linenumber="22">
|
data/lib/sinatra/param.rb
CHANGED
@@ -18,8 +18,8 @@ module Sinatra
|
|
18
18
|
|
19
19
|
begin
|
20
20
|
params[name] = coerce(params[name], type, options)
|
21
|
-
params[name] = (options[:default].call if options[:default].
|
22
|
-
params[name] = options[:transform].to_proc.call(params[name]) if options[:transform]
|
21
|
+
params[name] = (options[:default].call if options[:default].respond_to?(:call)) || options[:default] if params[name].nil? and options[:default]
|
22
|
+
params[name] = options[:transform].to_proc.call(params[name]) if params[name] and options[:transform]
|
23
23
|
validate!(params[name], options)
|
24
24
|
rescue InvalidParameterError => exception
|
25
25
|
if options[:raise] or (settings.raise_sinatra_param_exceptions rescue false)
|
Binary file
|
data/spec/dummy/app.rb
CHANGED
@@ -100,6 +100,11 @@ class App < Sinatra::Base
|
|
100
100
|
params.to_json
|
101
101
|
end
|
102
102
|
|
103
|
+
get '/transform/required' do
|
104
|
+
param :order, String, required: true, transform: :upcase
|
105
|
+
params.to_json
|
106
|
+
end
|
107
|
+
|
103
108
|
get '/validation/required' do
|
104
109
|
param :arg, String, required: true
|
105
110
|
params.to_json
|
@@ -24,5 +24,12 @@ describe 'Parameter Transformations' do
|
|
24
24
|
JSON.parse(response.body)['order'].should == 'ASC'
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
28
|
+
it 'skips transformations when the value is nil' do
|
29
|
+
get('/transform/required') do |response|
|
30
|
+
response.status.should == 400
|
31
|
+
JSON.parse(response.body)['message'].should eq('Invalid Parameter: order')
|
32
|
+
end
|
33
|
+
end
|
27
34
|
end
|
28
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-param
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattt Thompson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- ./sinatra-param-1.1.1.gem
|
145
145
|
- ./sinatra-param-1.1.2.gem
|
146
146
|
- ./sinatra-param-1.2.0.gem
|
147
|
+
- ./sinatra-param-1.2.1.gem
|
147
148
|
- ./sinatra-param.gemspec
|
148
149
|
- spec/dummy/app.rb
|
149
150
|
- spec/parameter_raise_spec.rb
|