finitio 0.5.1 → 0.5.2

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: 01d0b7cc775a7a49d837efeb5649b844b495a324
4
- data.tar.gz: 6ba20d99543010822f871f13c7134d458000fabb
3
+ metadata.gz: 46d8b55dce1f11c02ca0a953a8688fe6f6e66851
4
+ data.tar.gz: 9278c34a8fc3e05e89b05a9925539dabfbbc1ca5
5
5
  SHA512:
6
- metadata.gz: c0ae0a3ddfb5f74be525b87d6aa6f70b766b67528f6971a03ac578260736d411793d18498b851477669b85b174c1a53d43bca4bbd56ce6983669ead477869e0c
7
- data.tar.gz: 187708343da19fb59b3cb711c94fc58f14dff12dfef6435525d455704edc5c7af403dddd76772cf54591467ae79ba47e9eb3bdee1af2560436d961e536cda1c4
6
+ metadata.gz: dfc507bf5246aa52b6d54743ff88aad279e2aa0c8bcef499740484e13c977ebfdc751e3d0a3ca2d1daa48fc50fe565b9e98e74b6ee28edea4b5892f2091d4f14
7
+ data.tar.gz: ac994264f34c3c161c7a1a962ce57c28be8fc18235737cd9000ba26ff3b661fcca6fe16ec0e9e382cfb228093b010f9637c25ecf886f9ac88705d3941140693f
@@ -1,3 +1,10 @@
1
+ # 0.5.1 / 2017-01-08
2
+
3
+ * Disable memoization in parser because it leads to terrible performance
4
+ issues on some schemas.
5
+ * Avoid alternatives on high-level rules (Union, SubType) to prevent many
6
+ fallbacks that kill performance without memoization enabled.
7
+
1
8
  # 0.5.1 / 2015-09-22
2
9
 
3
10
  * Enabled memoization in parser to avoid very long parsing time on complex
@@ -17,18 +17,18 @@ module Finitio
17
17
  end
18
18
 
19
19
  def self.ast(source)
20
- parse(source, root: "system", memoize: true).to_ast
20
+ parse(source, root: "system").to_ast
21
21
  end
22
22
 
23
23
  def self.compile(source, cpl = nil)
24
24
  cpl = Compilation.coerce(cpl)
25
- parse(source, root: "system", memoize: true).compile(cpl)
25
+ parse(source, root: "system").compile(cpl)
26
26
  cpl.resolve_proxies!.system
27
27
  end
28
28
 
29
29
  def self.compile_type(source, cpl = nil)
30
30
  cpl = Compilation.coerce(cpl)
31
- parse(source, root: "type", memoize: true).compile(cpl)
31
+ parse(source, root: "type").compile(cpl)
32
32
  end
33
33
 
34
34
  end # module Syntax
@@ -7,12 +7,19 @@ module Finitio
7
7
 
8
8
  def compile(factory)
9
9
  s = rel_type.compile(factory)
10
- c = constraint_def.compile(factory)
11
- factory.subtype(s, c)
10
+ if c = constraint_def
11
+ factory.subtype(s, c.compile(factory))
12
+ else
13
+ s
14
+ end
12
15
  end
13
16
 
14
17
  def to_ast
15
- [:sub_type, rel_type.to_ast] + constraint_def.to_ast
18
+ if c = constraint_def
19
+ [:sub_type, rel_type.to_ast] + constraint_def.to_ast
20
+ else
21
+ rel_type.to_ast
22
+ end
16
23
  end
17
24
 
18
25
  end # module SubType
@@ -5,11 +5,12 @@ module Finitio
5
5
 
6
6
  def compile(factory)
7
7
  cds = captures[:sub_type].map{|x| x.compile(factory) }
8
- factory.union(cds)
8
+ cds.size == 1 ? cds.first : factory.union(cds)
9
9
  end
10
10
 
11
11
  def to_ast
12
- captures[:sub_type].map(&:to_ast).unshift(:union_type)
12
+ cds = captures[:sub_type].map(&:to_ast)
13
+ cds.size == 1 ? cds.first : cds.unshift(:union_type)
13
14
  end
14
15
 
15
16
  end # module UnionType
@@ -22,15 +22,13 @@ grammar Finitio::Syntax::Types
22
22
  # union and sub types
23
23
 
24
24
  rule union_type
25
- (sub_type (pipe sub_type)+)
26
- <Finitio::Syntax::UnionType>
27
- | sub_type
25
+ (sub_type (pipe sub_type)*)
26
+ <Finitio::Syntax::UnionType>
28
27
  end
29
28
 
30
29
  rule sub_type
31
- (rel_type constraint_def)
32
- <Finitio::Syntax::SubType>
33
- | rel_type
30
+ (rel_type constraint_def?)
31
+ <Finitio::Syntax::SubType>
34
32
  end
35
33
 
36
34
  rule constraint_def
@@ -52,7 +52,7 @@ module Finitio
52
52
  protected
53
53
 
54
54
  def looks_a_tuple?(value)
55
- value.is_a?(Hash) or value.respond_to?(:fetch)
55
+ value.is_a?(Hash) or [:keys, :fetch].all?{|k| value.respond_to?(k) }
56
56
  end
57
57
 
58
58
  def attr_names
@@ -3,7 +3,7 @@ module Finitio
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 5
6
- TINY = 1
6
+ TINY = 2
7
7
 
8
8
  def self.to_s
9
9
  [ MAJOR, MINOR, TINY ].join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finitio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-22 00:00:00.000000000 Z
11
+ date: 2017-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: citrus