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 +4 -4
- data/Gemfile.lock +1 -2
- data/lib/formalist/form/definition/component.rb +0 -1
- data/lib/formalist/form/definition/field.rb +0 -14
- data/lib/formalist/form/result/field.rb +1 -1
- data/lib/formalist/output_compiler.rb +2 -24
- data/lib/formalist/version.rb +1 -1
- data/spec/examples.txt +5 -5
- data/spec/unit/output_compiler_spec.rb +4 -4
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 213025004cb07e1b9962e338b59d4170e2f20c9d
|
4
|
+
data.tar.gz: f17a38dd7de60b6672ec18027b988119b73be9f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dafc943fc98d96e5a671b81ebbe6be0eebc20a9ab3f9558bae54ae4c8535cd542cb1e56b304dc6c89494b3f4d410694063192e993a51c79748d3aea2fa9b6681
|
7
|
+
data.tar.gz: b0bf744c37494e443e294f25d0a8cc4f549955149ffa205e44be3ccee791d0b53fc60ca5bfd3471ce6ed80c1dac277c5dcac36fa606eeccf82526e2e5d314707
|
data/Gemfile.lock
CHANGED
@@ -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
|
@@ -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,
|
20
|
+
name, _type, _display_variant, value, _predicates, _errors = data
|
33
21
|
|
34
|
-
{name =>
|
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
|
data/lib/formalist/version.rb
CHANGED
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.
|
4
|
-
./spec/integration/display_adapters_spec.rb[1:2] | passed | 0.
|
5
|
-
./spec/integration/form_spec.rb[1:1] | passed | 0.
|
6
|
-
./spec/integration/validation_spec.rb[1:1] | passed | 0.
|
7
|
-
./spec/unit/output_compiler_spec.rb[1:1] | passed | 0.
|
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.
|
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
|