gourami 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57a2782368b91dd6d00f1fd52402fe45fc631436
4
- data.tar.gz: b48276105fc9f4028bba1fc7ca08ab65d3e6708a
3
+ metadata.gz: 603c7eab7f67f882417c3d2c3972b8632e50d420
4
+ data.tar.gz: d9ddbf73b7e29f40443d3f2ff421f434c66ee073
5
5
  SHA512:
6
- metadata.gz: d4621445ee8bad894787813e7a00b6c67a7d1b0d02ac364c0ddc953ce76b6afb0e421a393ef39f49578662254e10383fa25e1e1c66a2f94675d546af2f28462f
7
- data.tar.gz: db710b63482399707da8e3a78928315f9535b1be8166a63c2fbf4ae7d2b7aafed884dbf4100c055da8483800d301dcc626c950dec78e3a06f4a7033d0e3401f4
6
+ metadata.gz: 2e98badb6ec80ba426d32da18e915944c7461e9154348efdc5c401cac9053224e4a82ed16ca78d89d81c6506cce4d6c940cf53e84e253e4ea87d1a7008634d1b
7
+ data.tar.gz: dddd5426e7a1c497ccd0ff57c2536944d51077dd7317637fa3961943605afed939045047043017e2bdfe3bd2b8a8f22b93e11558a3f6e47206477b63cbceb57b
@@ -24,15 +24,15 @@ module Gourami
24
24
  # @param value [Object]
25
25
  # @option allow_nil [Boolean] (true)
26
26
  # @option upcase [Boolean] (false)
27
- # @option strip [Boolean] (false)
27
+ # @option strip [Boolean] (true)
28
28
  #
29
29
  # @return [String, nil]
30
30
  def coerce_string(value, options = {})
31
31
  return nil if value.nil? && options.fetch(:allow_nil, true)
32
32
 
33
33
  value = value.to_s.dup.force_encoding(Encoding::UTF_8)
34
- value.strip! if options[:strip]
35
- value.upcase! if options[:upcase]
34
+ value.strip! if options.fetch(:strip, true)
35
+ value.upcase! if options.fetch(:upcase, false)
36
36
 
37
37
  value
38
38
  end
@@ -150,12 +150,18 @@ module Gourami
150
150
 
151
151
  if value
152
152
  length = value.size
153
+ did_append_error = false
154
+
153
155
  if min && length < min
156
+ did_append_error = true
154
157
  append_error(attribute_name, options.fetch(:min_message, nil) || :is_too_short)
155
158
  end
156
159
  if max && length > max
160
+ did_append_error = true
157
161
  append_error(attribute_name, options.fetch(:max_message, nil) || :is_too_long)
158
162
  end
163
+
164
+ errors[attribute_name] if did_append_error
159
165
  end
160
166
  end
161
167
 
@@ -207,6 +213,7 @@ module Gourami
207
213
  end
208
214
  end
209
215
 
216
+ # TODO: Spec return value in spec/validations_spec.rb
210
217
  # Validate the range in which the attribute can be. If the value is less
211
218
  # than the min a :less_than_min error will be appended. If the value is
212
219
  # greater than the max a :greater_than_max error will be appended.
@@ -1,3 +1,3 @@
1
1
  module Gourami
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "0.4.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gourami
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TSMMark
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-02 00:00:00.000000000 Z
11
+ date: 2019-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry