formalist 0.2.0 → 0.2.1

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: 80737e639f603683df1a3527b2a1978591169aa0
4
- data.tar.gz: db8cc08289a1b651ee40f763245b5a917a08b6f2
3
+ metadata.gz: a7055c275618d555fa1188cb9174c29c787070fa
4
+ data.tar.gz: 1910092503d719ca28d8ec33a648d6deaac5eaec
5
5
  SHA512:
6
- metadata.gz: ca4062cdf2586ed0d562ae40e8163542453180fcf35d9310ae72c5eb050ee70a62110d972e25474be9644547dc475b0718d740a477fee965daca92b7e6866726
7
- data.tar.gz: 45c7fe326a700e1afe77207438bb9e6b400687516a8229d25a6d981e290e211b493f93ca62ef1a72b8bc20951dd43abcd885c298973f1348f38d8952f11cf39d
6
+ metadata.gz: 822979b3cbef49ec09764e240ccc0cafecaacba685e77ff72d872a7c8391573500170acfd044cc7f8fa5956f1d9698448844d0259410e862010ccb6d761af836
7
+ data.tar.gz: bbc463e79885c2810241067084c210f00cf261fd5a820e65f3167068ebbce42efc7ab765529064c9580cc89d6f7002fa9102f9ad0060826444edd4f24e0c7797
data/Gemfile.lock CHANGED
@@ -13,7 +13,7 @@ GIT
13
13
  PATH
14
14
  remote: .
15
15
  specs:
16
- formalist (0.2.0)
16
+ formalist (0.2.1)
17
17
  dry-configurable
18
18
  dry-container
19
19
  dry-data (>= 0.4.2)
@@ -1,5 +1,9 @@
1
+ require "json"
1
2
  require "dry-configurable"
3
+ require "dry-validation"
4
+ require "dry/validation/schema/form"
2
5
  require "formalist/definition_compiler"
6
+ require "formalist/output_compiler"
3
7
  require "formalist/display_adapters"
4
8
  require "formalist/form/definition"
5
9
  require "formalist/form/result"
@@ -33,12 +37,15 @@ module Formalist
33
37
  @schema = schema
34
38
  end
35
39
 
36
- def build(input)
40
+ def build(input = {})
37
41
  Result.new(schema, elements, input)
38
42
  end
39
43
 
40
44
  def receive(form_post)
41
- input = schema.(form_post).output
45
+ form_data = Formalist::OutputCompiler.new.call(JSON.parse(form_post))
46
+ form_schema = Dry::Validation::Schema::Form.new(schema.class.rules)
47
+
48
+ input = form_schema.(form_data).output
42
49
  build(input)
43
50
  end
44
51
  end
@@ -1,3 +1,3 @@
1
1
  module Formalist
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.2.1".freeze
3
3
  end
data/lib/formalist.rb CHANGED
@@ -2,6 +2,20 @@ module Formalist
2
2
  DEFAULT_DISPLAY_ADAPTER = "default".freeze
3
3
  end
4
4
 
5
+ # Temporarily monkey-patch over a dry-validation bug (intput type compiler for
6
+ # form schemas not being passed the right set of rules).
5
7
  require "dry-validation"
8
+ require "dry/validation/schema/form"
9
+ module Dry
10
+ module Validation
11
+ class Schema::Form < Schema
12
+ def initialize(rules = [])
13
+ super
14
+ # @input_type = InputTypeCompiler.new.(self.class.rules.map(&:to_ast))
15
+ @input_type = InputTypeCompiler.new.(self.class.rule_ast + rules.map(&:to_ast))
16
+ end
17
+ end
18
+ end
19
+ end
20
+
6
21
  require "formalist/form"
7
- require "formalist/output_compiler"
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.00184 seconds |
4
- ./spec/integration/display_adapters_spec.rb[1:2] | passed | 0.00228 seconds |
5
- ./spec/integration/form_spec.rb[1:1] | passed | 0.00232 seconds |
6
- ./spec/integration/validation_spec.rb[1:1] | passed | 0.00607 seconds |
7
- ./spec/unit/output_compiler_spec.rb[1:1] | passed | 0.00276 seconds |
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 |
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formalist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Riley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-22 00:00:00.000000000 Z
11
+ date: 2016-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable