schemurai 3.0.2 → 3.1.1
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 +4 -4
- data/README.md +22 -3
- data/ext/schemurai_native/Cargo.lock +14 -3
- data/ext/schemurai_native/Cargo.toml +4 -3
- data/ext/schemurai_native/build.rs +7 -6
- data/ext/schemurai_native/extconf.rb +4 -0
- data/ext/schemurai_native/glue.c +33 -10
- data/ext/schemurai_native/protocol.def +52 -0
- data/ext/schemurai_native/protocol.h +2 -0
- data/ext/schemurai_native/src/container.rs +6 -6
- data/ext/schemurai_native/src/content.rs +63 -31
- data/ext/schemurai_native/src/diagnostics.rs +75 -116
- data/ext/schemurai_native/src/lib.rs +56 -54
- data/ext/schemurai_native/src/memo.rs +68 -28
- data/ext/schemurai_native/src/memo_scope.rs +30 -0
- data/ext/schemurai_native/src/number/arbitrary.rs +57 -1
- data/ext/schemurai_native/src/number.rs +10 -10
- data/ext/schemurai_native/src/pointer.rs +19 -6
- data/ext/schemurai_native/src/runtime.rs +27 -0
- data/ext/schemurai_native/src/scope.rs +52 -5
- data/lib/schemurai/evaluation_limits.rb +65 -0
- data/lib/schemurai/limited_evaluator.rb +2 -59
- data/lib/schemurai/version.rb +1 -1
- data/lib/schemurai/vm/limited_evaluator.rb +2 -57
- metadata +3 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "../limit_exceeded"
|
|
4
|
-
require_relative "../
|
|
4
|
+
require_relative "../evaluation_limits"
|
|
5
5
|
require_relative "evaluator"
|
|
6
6
|
|
|
7
7
|
module Schemurai
|
|
@@ -10,73 +10,18 @@ module Schemurai
|
|
|
10
10
|
class LimitedEvaluator < Evaluator
|
|
11
11
|
include Internal::ValueEquality::Checkpoints
|
|
12
12
|
include Internal::StringChecks::TimedRegexps
|
|
13
|
-
|
|
14
|
-
def validate(instance, max_errors: nil, timeout: nil, budget: nil)
|
|
15
|
-
@budget = budget || Internal::LimitBudget.new(max_errors: max_errors, timeout: timeout)
|
|
16
|
-
result = super(instance)
|
|
17
|
-
@budget.check_deadline!
|
|
18
|
-
result
|
|
19
|
-
ensure
|
|
20
|
-
@budget = nil
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def valid?(instance, max_errors: nil, timeout: nil, budget: nil)
|
|
24
|
-
@budget = budget || Internal::LimitBudget.new(max_errors: max_errors, timeout: timeout)
|
|
25
|
-
result = super(instance)
|
|
26
|
-
@budget.check_deadline!
|
|
27
|
-
result
|
|
28
|
-
ensure
|
|
29
|
-
@budget = nil
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
private def evaluate(node, instance)
|
|
33
|
-
@budget.checkpoint
|
|
34
|
-
super
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
private def evaluate_valid(node, instance)
|
|
38
|
-
@budget.checkpoint
|
|
39
|
-
super
|
|
40
|
-
end
|
|
13
|
+
include Internal::EvaluationLimits
|
|
41
14
|
|
|
42
15
|
private def add_error(keyword, message = nil, append_keyword: true, &block)
|
|
43
16
|
@budget.reserve_error if @errors
|
|
44
17
|
super
|
|
45
18
|
end
|
|
46
19
|
|
|
47
|
-
private def valid_string?(node, value)
|
|
48
|
-
@budget.check_deadline!
|
|
49
|
-
result = super
|
|
50
|
-
@budget.check_deadline!
|
|
51
|
-
result
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
private def check_string(node, value)
|
|
55
|
-
@budget.check_deadline!
|
|
56
|
-
result = super
|
|
57
|
-
@budget.check_deadline!
|
|
58
|
-
result
|
|
59
|
-
end
|
|
60
|
-
|
|
61
20
|
private def number_state
|
|
62
21
|
state = super
|
|
63
22
|
state.budget = @budget
|
|
64
23
|
state
|
|
65
24
|
end
|
|
66
|
-
|
|
67
|
-
private def valid_content?(schema, value)
|
|
68
|
-
@budget.check_deadline!
|
|
69
|
-
result = super
|
|
70
|
-
@budget.check_deadline!
|
|
71
|
-
result
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
private def check_content(schema, value)
|
|
75
|
-
@budget.check_deadline!
|
|
76
|
-
result = super
|
|
77
|
-
@budget.check_deadline!
|
|
78
|
-
result
|
|
79
|
-
end
|
|
80
25
|
end
|
|
81
26
|
end
|
|
82
27
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: schemurai
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kuya KOHARA (oakcask)
|
|
@@ -84,6 +84,7 @@ files:
|
|
|
84
84
|
- lib/schemurai/ecma_regexp.rb
|
|
85
85
|
- lib/schemurai/error_message.rb
|
|
86
86
|
- lib/schemurai/evaluation.rb
|
|
87
|
+
- lib/schemurai/evaluation_limits.rb
|
|
87
88
|
- lib/schemurai/evaluation_pool.rb
|
|
88
89
|
- lib/schemurai/evaluator.rb
|
|
89
90
|
- lib/schemurai/formats.rb
|
|
@@ -117,7 +118,7 @@ licenses:
|
|
|
117
118
|
metadata:
|
|
118
119
|
homepage_uri: https://github.com/oakcask/schemurai
|
|
119
120
|
source_code_uri: https://github.com/oakcask/schemurai/tree/main
|
|
120
|
-
documentation_uri: https://rubydoc.info/gems/schemurai/3.
|
|
121
|
+
documentation_uri: https://rubydoc.info/gems/schemurai/3.1.1
|
|
121
122
|
rubygems_mfa_required: 'true'
|
|
122
123
|
rdoc_options:
|
|
123
124
|
- "--main"
|