eapi 0.7.0 → 0.7.1

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: 8185b8ffb82603d48217ba5da50433b6ed456692
4
- data.tar.gz: ec4580aa551539d3dd3954af9370831fa81f8279
3
+ metadata.gz: ed4d9b9872835a5ee521394efc52e6c68161032a
4
+ data.tar.gz: ba5624ff813cb94a6cf979a33f556f5c323c3071
5
5
  SHA512:
6
- metadata.gz: 4e8c053064f3c3ea658a71791ade20c42b1f2b66e6e3ffbe38e8f1bc6d52a33eb191e1d8284b4e050a965f27ff87ad727794ee79797933d56d2bd8c2d82e05e4
7
- data.tar.gz: d71bf06c7941f1218c9fa7486b9d7aa3ccae398e4fe4a09f235abe405477267cf4daa5ef8833f49c2c54ef7a246c067fe292fcb306fcf0b0ab8fbac7c56072db
6
+ metadata.gz: e7b5f6a3856d15a5969f8497b910eb55b2f8927773f7111ce5bd0d5357313e5998339e9574273547944f0176092771290f8cc2d331fd7607a080b34c6b5f2efc
7
+ data.tar.gz: 731378d506958e49440a4b3b250bf8abbb2767e0ec5affd8258ad46db600e38fc945b7dc082af9b0e3c6487d981b8e3af051290642cdd15f92451c494c2e0e1d
data/README.md CHANGED
@@ -14,8 +14,14 @@ Main features:
14
14
  * list support
15
15
  * validation
16
16
  * rendering to `Hash` or `Array`
17
+ * custom conversion of values
17
18
  * raw `Hash` or `Array` support to skip type check validations
18
19
  * omit `nil` values automatically
20
+ * custom preparation of values before validation
21
+
22
+ ## WIP Warning
23
+
24
+ Until the release of the first stable version `1.0`, new versions can contain breaking changes.
19
25
 
20
26
  ## Usage
21
27
 
@@ -436,7 +442,7 @@ x.one # => :fluent
436
442
  res.equal? x # => true
437
443
  ```
438
444
 
439
- #### `converted_or_default_value_for` method
445
+ #### `converted_or_default_value_for` method (aka `final_value_for`)
440
446
 
441
447
  It will return the converted value for the property. If that value is to be ignored (following the rules described with the `ignore` option) then it will return the default one (defined by the `default` option), or `nil` if there is no default value.
442
448
 
@@ -450,9 +456,11 @@ end
450
456
  x = TestKlassWithDefault.new
451
457
  x.something ''
452
458
  x.converted_or_default_value_for(:something) # => 123
459
+ x.final_value_for(:something) # => 123
453
460
 
454
461
  x.something 'not blank'
455
462
  x.converted_or_default_value_for(:something) # => 'not blank'
463
+ x.final_value_for(:something) # => 'not blank'
456
464
 
457
465
 
458
466
  class TestKlassWithoutDefault
@@ -464,9 +472,11 @@ end
464
472
  x = TestKlassWithoutDefault.new
465
473
  x.something ''
466
474
  x.converted_or_default_value_for(:something) # => nil
475
+ x.final_value_for(:something) # => nil
467
476
 
468
477
  x.something 'not blank'
469
478
  x.converted_or_default_value_for(:something) # => 'not blank'
479
+ x.final_value_for(:something) # => 'not blank'
470
480
  ```
471
481
 
472
482
  #### `yield_final_value_for` method
@@ -41,6 +41,10 @@ module Eapi
41
41
  yield_final_value_for(property) { |val| return val }
42
42
  end
43
43
 
44
+ def final_value_for(property)
45
+ converted_or_default_value_for(property)
46
+ end
47
+
44
48
  # will yield the converted value if it is not to be ignored,
45
49
  # will yield the default value if it is set and the converted value is to be ignored
46
50
  # will not yield anything otherwise
@@ -1,3 +1,3 @@
1
1
  module Eapi
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
@@ -29,15 +29,17 @@ RSpec.describe Eapi do
29
29
  expect(subject.render).to eq expected
30
30
  end
31
31
 
32
- describe '#converted_or_default_value_for' do
32
+ describe '#converted_or_default_value_for and #final_value_for (same)' do
33
33
  it 'returns the converted value if it is not ignored' do
34
34
  subject.something 1
35
35
  expect(subject.converted_or_default_value_for :something).to eq 1
36
+ expect(subject.final_value_for :something).to eq 1
36
37
  end
37
38
 
38
39
  it 'returns the default value if it is ignored' do
39
40
  subject.something ""
40
41
  expect(subject.converted_or_default_value_for :something).to eq 123
42
+ expect(subject.final_value_for :something).to eq 123
41
43
  end
42
44
 
43
45
  describe 'without default value' do
@@ -46,6 +48,7 @@ RSpec.describe Eapi do
46
48
  it 'returns nil if the converted value is ignored' do
47
49
  subject.something ""
48
50
  expect(subject.converted_or_default_value_for :something).to be_nil
51
+ expect(subject.final_value_for :something).to be_nil
49
52
  end
50
53
  end
51
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Turiño