formalism 0.2.1 → 0.3.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
  SHA256:
3
- metadata.gz: '008bc0a053e9967ac5ba5535cd0a6a3ef5f35d417e8f386289b9f1f23290e7f6'
4
- data.tar.gz: 9e0debe2a119f639b052c5eebf61162af7464424eacc421f7717e4511839031f
3
+ metadata.gz: 88548d0ecdb223bf0758367421978917b3e79e4416d9444fe6fd9543c9ee0cfb
4
+ data.tar.gz: 1683f2947e7c6c7c0a02c4c8cb88056b00fa727dfe7ed19f47ded701559b13ee
5
5
  SHA512:
6
- metadata.gz: 1d005d3d8e0d9fc5eb20f18446ffb1947dfc7ed2dab7d9213dc0c4a0ad75e4f63fac983b7da67a134605b2f99c29c7305ada9122f4f715328d89d44f2b58d36d
7
- data.tar.gz: f2e51c58039cc00a09bb43e7744859465c009a3b6273c0546a038e886796be4a188cf7c96d9b4bf4f490bb933ff896bbef98ae80e60f994f2e56ebdf42717acc
6
+ metadata.gz: 8fb481b7388afe09e10ee71f3df12564a9600855f90c8a202ead6ba83f007fe475ffde3edf8e14a8f6202ba6b98175b34842bdc0b98b2130cd0b2712081e413a
7
+ data.tar.gz: ef87193279b77951488443e089b4375f85f0004e39cfe2ae5efd8692bf84772acf3035ae2ea1fab510f9bb6acfbf183b5bbd5ad55e1ba6c979d5bbbcf9b76070
@@ -2,9 +2,12 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.3.0 (2020-09-28)
6
+
5
7
  ## 0.2.1 (2020-09-25)
6
8
 
7
9
  * Make `Form::Outcome` constant public.
10
+ Useful for re-defining `#run` method in modules.
8
11
 
9
12
  ## 0.2.0 (2020-09-23)
10
13
 
@@ -18,6 +18,10 @@ module Formalism
18
18
  def execute
19
19
  return unless self.class::VALUE_REGEXP.match? @value.to_s
20
20
 
21
+ send_conversion_method
22
+ end
23
+
24
+ def send_conversion_method
21
25
  @value.public_send(self.class::CONVERSION_METHOD)
22
26
  end
23
27
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'float'
4
+
5
+ module Formalism
6
+ class Form < Action
7
+ class Coercion
8
+ ## Class for coercion to BigDecimal
9
+ class BigDecimal < Float
10
+ private
11
+
12
+ def send_conversion_method
13
+ BigDecimal(@value)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -6,7 +6,8 @@ module Formalism
6
6
  ## Class for coercion to Float
7
7
  class Float < Numeric
8
8
  ## https://stackoverflow.com/a/36946626/2630849
9
- VALUE_REGEXP = wrap_value_regexp '[-+]?(?:\d+(?:\.\d*)?|\.\d+)'
9
+ ## and improvements for `BigDecimal` (e-notation)
10
+ VALUE_REGEXP = wrap_value_regexp '[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[-+]?\d+)?'
10
11
 
11
12
  CONVERSION_METHOD = :to_f
12
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Formalism
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formalism
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Popov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-25 00:00:00.000000000 Z
11
+ date: 2020-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gorilla_patch
@@ -196,6 +196,7 @@ files:
196
196
  - lib/formalism/form/coercion/_base.rb
197
197
  - lib/formalism/form/coercion/_numeric.rb
198
198
  - lib/formalism/form/coercion/array.rb
199
+ - lib/formalism/form/coercion/bigdecimal.rb
199
200
  - lib/formalism/form/coercion/boolean.rb
200
201
  - lib/formalism/form/coercion/date.rb
201
202
  - lib/formalism/form/coercion/float.rb