formalist 0.2.1 → 0.2.2

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: a7055c275618d555fa1188cb9174c29c787070fa
4
- data.tar.gz: 1910092503d719ca28d8ec33a648d6deaac5eaec
3
+ metadata.gz: 213025004cb07e1b9962e338b59d4170e2f20c9d
4
+ data.tar.gz: f17a38dd7de60b6672ec18027b988119b73be9f3
5
5
  SHA512:
6
- metadata.gz: 822979b3cbef49ec09764e240ccc0cafecaacba685e77ff72d872a7c8391573500170acfd044cc7f8fa5956f1d9698448844d0259410e862010ccb6d761af836
7
- data.tar.gz: bbc463e79885c2810241067084c210f00cf261fd5a820e65f3167068ebbce42efc7ab765529064c9580cc89d6f7002fa9102f9ad0060826444edd4f24e0c7797
6
+ metadata.gz: dafc943fc98d96e5a671b81ebbe6be0eebc20a9ab3f9558bae54ae4c8535cd542cb1e56b304dc6c89494b3f4d410694063192e993a51c79748d3aea2fa9b6681
7
+ data.tar.gz: b0bf744c37494e443e294f25d0a8cc4f549955149ffa205e44be3ccee791d0b53fc60ca5bfd3471ce6ed80c1dac277c5dcac36fa606eeccf82526e2e5d314707
data/Gemfile.lock CHANGED
@@ -13,10 +13,9 @@ GIT
13
13
  PATH
14
14
  remote: .
15
15
  specs:
16
- formalist (0.2.1)
16
+ formalist (0.2.2)
17
17
  dry-configurable
18
18
  dry-container
19
- dry-data (>= 0.4.2)
20
19
  dry-validation (~> 0.6.0)
21
20
  inflecto
22
21
 
@@ -1,4 +1,3 @@
1
- require "dry-data"
2
1
  require "formalist/form/result/component"
3
2
 
4
3
  module Formalist
@@ -1,29 +1,15 @@
1
- require "dry-data"
2
1
  require "formalist/form/result/field"
3
2
 
4
3
  module Formalist
5
4
  class Form
6
5
  module Definition
7
6
  class Field
8
- TYPES = %w[
9
- bool
10
- date
11
- date_time
12
- decimal
13
- float
14
- int
15
- string
16
- time
17
- ].freeze
18
-
19
7
  attr_reader :name
20
8
  attr_reader :type
21
9
  attr_reader :display_variant
22
10
  attr_reader :config
23
11
 
24
12
  def initialize(name, type, display_variant, config)
25
- raise ArgumentError, "type +#{type}+ not supported" unless TYPES.include?(type)
26
-
27
13
  @name = name
28
14
  @type = type
29
15
  @display_variant = display_variant
@@ -65,7 +65,7 @@ module Formalist
65
65
  definition.name,
66
66
  definition.type,
67
67
  definition.display_variant,
68
- Dry::Data[definition.type].(input),
68
+ input,
69
69
  predicates,
70
70
  errors,
71
71
  definition.config.to_a,
@@ -1,17 +1,5 @@
1
- require "dry-data"
2
-
3
1
  module Formalist
4
2
  class OutputCompiler
5
- FORM_TYPES = %w[
6
- bool
7
- date
8
- date_time
9
- decimal
10
- float
11
- int
12
- time
13
- ].freeze
14
-
15
3
  def call(ast)
16
4
  ast.map { |node| visit(node) }.inject(:merge)
17
5
  end
@@ -29,9 +17,9 @@ module Formalist
29
17
  end
30
18
 
31
19
  def visit_field(data)
32
- name, type, display_variant, value, predicates, errors = data
20
+ name, _type, _display_variant, value, _predicates, _errors = data
33
21
 
34
- {name => coerce(value, type: type)}
22
+ {name => value.to_s}
35
23
  end
36
24
 
37
25
  def visit_group(data)
@@ -51,15 +39,5 @@ module Formalist
51
39
 
52
40
  children.map { |node| visit(node) }.inject(:merge)
53
41
  end
54
-
55
- private
56
-
57
- def coerce(value, type:)
58
- if FORM_TYPES.include?(type)
59
- Dry::Data["form.#{type}"].(value)
60
- else
61
- Dry::Data[type].(value)
62
- end
63
- end
64
42
  end
65
43
  end
@@ -1,3 +1,3 @@
1
1
  module Formalist
2
- VERSION = "0.2.1".freeze
2
+ VERSION = "0.2.2".freeze
3
3
  end
data/spec/examples.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  example_id | status | run_time |
2
2
  ------------------------------------------------ | ------ | --------------- |
3
- ./spec/integration/display_adapters_spec.rb[1:1] | passed | 0.00173 seconds |
4
- ./spec/integration/display_adapters_spec.rb[1:2] | passed | 0.00183 seconds |
5
- ./spec/integration/form_spec.rb[1:1] | passed | 0.00389 seconds |
6
- ./spec/integration/validation_spec.rb[1:1] | passed | 0.00369 seconds |
7
- ./spec/unit/output_compiler_spec.rb[1:1] | passed | 0.00443 seconds |
3
+ ./spec/integration/display_adapters_spec.rb[1:1] | passed | 0.00188 seconds |
4
+ ./spec/integration/display_adapters_spec.rb[1:2] | passed | 0.00209 seconds |
5
+ ./spec/integration/form_spec.rb[1:1] | passed | 0.00379 seconds |
6
+ ./spec/integration/validation_spec.rb[1:1] | passed | 0.00545 seconds |
7
+ ./spec/unit/output_compiler_spec.rb[1:1] | passed | 0.00317 seconds |
@@ -44,19 +44,19 @@ RSpec.describe Formalist::OutputCompiler do
44
44
  let(:input) {
45
45
  {
46
46
  title: "Aurora",
47
- rating: 10,
47
+ rating: "10",
48
48
  reviews: [
49
49
  {
50
50
  description: "Wonderful",
51
- rating: 10,
51
+ rating: "10",
52
52
  },
53
53
  {
54
54
  description: "Enchanting",
55
- rating: 9,
55
+ rating: "9",
56
56
  }
57
57
  ],
58
58
  meta: {
59
- pages: 321,
59
+ pages: "321",
60
60
  publisher: "Orbit",
61
61
  },
62
62
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formalist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Riley
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: dry-data
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 0.4.2
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 0.4.2
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: dry-validation
57
43
  requirement: !ruby/object:Gem::Requirement