sinatra-browse 0.6 → 0.6.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
  SHA1:
3
- metadata.gz: 5bdedea1f30918fa4b4e9e40329b5d36d376e26a
4
- data.tar.gz: a3f543ea671453b43857a83971491ebc70469aef
3
+ metadata.gz: 384ebcd1b7b85008042e92d2e9c4b7a78b9f006f
4
+ data.tar.gz: cbb00fef429bd54edd3c5adbdb57c8f684e9f58f
5
5
  SHA512:
6
- metadata.gz: 5d9ca106f1fc4d51484e5985cfa8f6e66ff18a2fd5deedb325010decb99e1d76dbb86925a436fb1b47e4c1f2cedc0c8f1190d75d92dbba9d39db92c7db378ad9
7
- data.tar.gz: 792cb9ccd3f3103046644bc72eb23aa71de835cb7b1b2af7cc0cd5313a8fa9b4a63c0f3cf4fe56ab8af5f63222548fe833b4684dcffce8095a986c80bce3e66e
6
+ metadata.gz: bd0eb333f9d40697743186ed15895917b7f32485b752feaa590f9124168e2758601ec479c69d25b7994b0ec1a84953c91f024c03fbad5585b12efc9a8f2de675
7
+ data.tar.gz: b4ae0d59dee7d1fb5a2dbc9d49ea19f0ae316d683cb3fb183a8b06ed23de36eea45bbf18c013dfa48d3491d254e3822132588b9cc76344ad2a9789b5ce96ef9a
@@ -53,6 +53,10 @@ module Sinatra::Browse
53
53
  @default.is_a?(Proc) ? @default.call : @default
54
54
  end
55
55
 
56
+ def default_set?
57
+ ! @default.nil?
58
+ end
59
+
56
60
  def required?
57
61
  @required
58
62
  end
@@ -40,7 +40,7 @@ module Sinatra::Browse
40
40
  @param_declarations.each do |name, pd|
41
41
  name = name.to_s # The params hash uses strings but declarations use symbols
42
42
 
43
- params[name] ||= pd.default
43
+ params[name] ||= pd.default if pd.default_set?
44
44
 
45
45
  # We specifically check for nil here since a boolean's default can be false
46
46
  if params[name].nil?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-browse
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Axsh Co. LTD
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-24 00:00:00.000000000 Z
11
+ date: 2015-07-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Parameter declaration framework and browsable API for Sinatra
14
14
  email: dev@axsh.net
@@ -22,7 +22,6 @@ files:
22
22
  - lib/sinatra/browse/erb_templates/html.erb
23
23
  - lib/sinatra/browse/parameter_type.rb
24
24
  - lib/sinatra/browse/errors.rb
25
- - lib/sinatra/browse/validators/in.rb
26
25
  - lib/sinatra/browse/route.rb
27
26
  - lib/sinatra/browse/parameter_types/min_max.rb
28
27
  - lib/sinatra/browse/parameter_types/float.rb
@@ -1,25 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- module Sinatra::Browse
4
- module Validators
5
- class In < Validator
6
- class InvalidFormat < Exception; end
7
- class UnableToCoerce < Exception; end
8
-
9
- def intialize(parameter_type, criteria)
10
- if ! criteria.respond_to?(:each)
11
- raise InvalidFormat, "#{criteria} does not have an .each method. " +
12
- "Can't be used for 'in'."
13
- end
14
-
15
- criteria.map!
16
-
17
- super(parameter_type, criteria)
18
- end
19
-
20
- def _validate
21
- @criteria.member?(@value)
22
- end
23
- end
24
- end
25
- end