schemurai 2.2.3 → 3.0.0

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +81 -7
  3. data/ext/schemurai_native/Cargo.lock +99 -0
  4. data/ext/schemurai_native/Cargo.toml +21 -0
  5. data/ext/schemurai_native/build.rs +35 -0
  6. data/ext/schemurai_native/extconf.rb +63 -0
  7. data/ext/schemurai_native/glue.c +780 -0
  8. data/ext/schemurai_native/protocol.def +63 -0
  9. data/ext/schemurai_native/protocol.h +10 -0
  10. data/ext/schemurai_native/src/budget.rs +101 -0
  11. data/ext/schemurai_native/src/content.rs +574 -0
  12. data/ext/schemurai_native/src/diagnostics.rs +1135 -0
  13. data/ext/schemurai_native/src/enumeration.rs +154 -0
  14. data/ext/schemurai_native/src/evaluation.rs +219 -0
  15. data/ext/schemurai_native/src/format.rs +357 -0
  16. data/ext/schemurai_native/src/graph.rs +50 -0
  17. data/ext/schemurai_native/src/instance_graph.rs +84 -0
  18. data/ext/schemurai_native/src/lib.rs +3139 -0
  19. data/ext/schemurai_native/src/memo.rs +1149 -0
  20. data/ext/schemurai_native/src/memo_scope.rs +240 -0
  21. data/ext/schemurai_native/src/number.rs +1054 -0
  22. data/ext/schemurai_native/src/pattern.rs +431 -0
  23. data/ext/schemurai_native/src/scope.rs +420 -0
  24. data/ext/schemurai_native/src/structural.rs +86 -0
  25. data/ext/schemurai_native/src/tracking.rs +687 -0
  26. data/lib/schemurai/backend.rb +3 -1
  27. data/lib/schemurai/evaluator.rb +45 -3
  28. data/lib/schemurai/limit_budget.rb +78 -0
  29. data/lib/schemurai/limit_exceeded.rb +18 -0
  30. data/lib/schemurai/limited_evaluator.rb +100 -0
  31. data/lib/schemurai/native/diagnostics.rb +52 -0
  32. data/lib/schemurai/native/evaluator.rb +59 -0
  33. data/lib/schemurai/schema_domain.rb +12 -7
  34. data/lib/schemurai/schema_graph.rb +10 -1
  35. data/lib/schemurai/unique_items.rb +2 -0
  36. data/lib/schemurai/version.rb +1 -1
  37. data/lib/schemurai/vm/compiler.rb +7 -3
  38. data/lib/schemurai/vm/evaluator.rb +50 -3
  39. data/lib/schemurai/vm/limited_evaluator.rb +97 -0
  40. data/lib/schemurai.rb +81 -33
  41. data/sig/schemurai.rbs +21 -13
  42. metadata +36 -6
data/sig/schemurai.rbs CHANGED
@@ -9,7 +9,7 @@ module Schemurai
9
9
  type schemas = Hash[String, schema]
10
10
 
11
11
  # A resolved evaluator backend.
12
- type backend = :ruby | :vm
12
+ type backend = :ruby | :vm | :native
13
13
 
14
14
  # A backend accepted when configuring a validator.
15
15
  type backend_selection = backend | :default
@@ -19,6 +19,14 @@ module Schemurai
19
19
  class Error < StandardError
20
20
  end
21
21
 
22
+ class LimitExceeded < Error
23
+ attr_reader limit: Symbol
24
+ attr_reader maximum: Integer | Float
25
+ attr_reader attempted: Integer | Float
26
+
27
+ def initialize: (Symbol limit, Integer | Float maximum, Integer | Float attempted) -> void
28
+ end
29
+
22
30
  class ResolutionError < Error
23
31
  end
24
32
 
@@ -63,10 +71,10 @@ module Schemurai
63
71
  end
64
72
 
65
73
  class Validator
66
- def initialize: (_Evaluator evaluator) -> void
74
+ def initialize: (_Evaluator evaluator, ?max_errors: Integer?, ?timeout: (Integer | Float)?, ?bounded_evaluator: (^() -> untyped)?) -> void
67
75
  def backend: () -> backend
68
- def validate: (json_value instance) -> Result
69
- def valid?: (json_value instance) -> bool
76
+ def validate: (json_value instance, ?max_errors: Integer?, ?timeout: (Integer | Float)?) -> Result
77
+ def valid?: (json_value instance, ?max_errors: Integer?, ?timeout: (Integer | Float)?) -> bool
70
78
  end
71
79
 
72
80
  class SchemaRegistry
@@ -76,25 +84,25 @@ module Schemurai
76
84
 
77
85
  def validate_schema?: () -> bool
78
86
 
79
- def compile: (schema schema, ?base_uri: String?, ?content: bool, ?format: bool) -> Validator
87
+ def compile: (schema schema, ?base_uri: String?, ?content: bool, ?format: bool, ?max_errors: Integer?, ?timeout: (Integer | Float)?) -> Validator
80
88
 
81
- def validate_schema: (schema schema) -> Result
82
- def valid_schema?: (schema schema) -> bool
89
+ def validate_schema: (schema schema, ?max_errors: Integer?, ?timeout: (Integer | Float)?) -> Result
90
+ def valid_schema?: (schema schema, ?max_errors: Integer?, ?timeout: (Integer | Float)?) -> bool
83
91
  def make_shareable: () -> self
84
92
  def shareable?: () -> bool
85
93
 
86
- def validator_for: (String uri, ?content: bool, ?format: bool) -> Validator
94
+ def validator_for: (String uri, ?content: bool, ?format: bool, ?max_errors: Integer?, ?timeout: (Integer | Float)?) -> Validator
87
95
  end
88
96
 
89
97
  def self.backend: () -> backend
90
98
 
91
- def self.compile: (schema schema, ?schemas: schemas, ?base_uri: String?, ?content: bool, ?format: bool, ?validate_schema: bool, ?backend: backend_selection) -> Validator
99
+ def self.compile: (schema schema, ?schemas: schemas, ?base_uri: String?, ?content: bool, ?format: bool, ?validate_schema: bool, ?backend: backend_selection, ?max_errors: Integer?, ?timeout: (Integer | Float)?) -> Validator
92
100
 
93
- def self.validate_schema: (schema schema, ?schemas: schemas, ?backend: backend_selection) -> Result
101
+ def self.validate_schema: (schema schema, ?schemas: schemas, ?backend: backend_selection, ?max_errors: Integer?, ?timeout: (Integer | Float)?) -> Result
94
102
 
95
- def self.valid_schema?: (schema schema, ?schemas: schemas, ?backend: backend_selection) -> bool
103
+ def self.valid_schema?: (schema schema, ?schemas: schemas, ?backend: backend_selection, ?max_errors: Integer?, ?timeout: (Integer | Float)?) -> bool
96
104
 
97
- def self.validate: (schema schema, json_value instance, ?schemas: schemas, ?base_uri: String?, ?content: bool, ?format: bool, ?validate_schema: bool, ?backend: backend_selection) -> Result
105
+ def self.validate: (schema schema, json_value instance, ?schemas: schemas, ?base_uri: String?, ?content: bool, ?format: bool, ?validate_schema: bool, ?backend: backend_selection, ?max_errors: Integer?, ?timeout: (Integer | Float)?) -> Result
98
106
 
99
- def self.valid?: (schema schema, json_value instance, ?schemas: schemas, ?base_uri: String?, ?content: bool, ?format: bool, ?validate_schema: bool, ?backend: backend_selection) -> bool
107
+ def self.valid?: (schema schema, json_value instance, ?schemas: schemas, ?base_uri: String?, ?content: bool, ?format: bool, ?validate_schema: bool, ?backend: backend_selection, ?max_errors: Integer?, ?timeout: (Integer | Float)?) -> bool
100
108
  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: 2.2.3
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuya KOHARA (oakcask)
@@ -28,13 +28,37 @@ description: Validates Ruby values against JSON Schema Draft 7, 2019-09, and 202
28
28
  email:
29
29
  - kuya.kohara@gmail.com
30
30
  executables: []
31
- extensions: []
31
+ extensions:
32
+ - ext/schemurai_native/extconf.rb
32
33
  extra_rdoc_files:
33
34
  - LICENSE
34
35
  - README.md
35
36
  files:
36
37
  - LICENSE
37
38
  - README.md
39
+ - ext/schemurai_native/Cargo.lock
40
+ - ext/schemurai_native/Cargo.toml
41
+ - ext/schemurai_native/build.rs
42
+ - ext/schemurai_native/extconf.rb
43
+ - ext/schemurai_native/glue.c
44
+ - ext/schemurai_native/protocol.def
45
+ - ext/schemurai_native/protocol.h
46
+ - ext/schemurai_native/src/budget.rs
47
+ - ext/schemurai_native/src/content.rs
48
+ - ext/schemurai_native/src/diagnostics.rs
49
+ - ext/schemurai_native/src/enumeration.rs
50
+ - ext/schemurai_native/src/evaluation.rs
51
+ - ext/schemurai_native/src/format.rs
52
+ - ext/schemurai_native/src/graph.rs
53
+ - ext/schemurai_native/src/instance_graph.rs
54
+ - ext/schemurai_native/src/lib.rs
55
+ - ext/schemurai_native/src/memo.rs
56
+ - ext/schemurai_native/src/memo_scope.rs
57
+ - ext/schemurai_native/src/number.rs
58
+ - ext/schemurai_native/src/pattern.rs
59
+ - ext/schemurai_native/src/scope.rs
60
+ - ext/schemurai_native/src/structural.rs
61
+ - ext/schemurai_native/src/tracking.rs
38
62
  - lib/schemurai.rb
39
63
  - lib/schemurai/backend.rb
40
64
  - lib/schemurai/dialect.rb
@@ -46,10 +70,15 @@ files:
46
70
  - lib/schemurai/evaluation.rb
47
71
  - lib/schemurai/evaluator.rb
48
72
  - lib/schemurai/formats.rb
73
+ - lib/schemurai/limit_budget.rb
74
+ - lib/schemurai/limit_exceeded.rb
75
+ - lib/schemurai/limited_evaluator.rb
49
76
  - lib/schemurai/meta_schemas.rb
50
77
  - lib/schemurai/meta_schemas/draft2019_09.rb
51
78
  - lib/schemurai/meta_schemas/draft2020_12.rb
52
79
  - lib/schemurai/meta_schemas/draft7.rb
80
+ - lib/schemurai/native/diagnostics.rb
81
+ - lib/schemurai/native/evaluator.rb
53
82
  - lib/schemurai/schema_domain.rb
54
83
  - lib/schemurai/schema_graph.rb
55
84
  - lib/schemurai/schema_node.rb
@@ -57,6 +86,7 @@ files:
57
86
  - lib/schemurai/version.rb
58
87
  - lib/schemurai/vm/compiler.rb
59
88
  - lib/schemurai/vm/evaluator.rb
89
+ - lib/schemurai/vm/limited_evaluator.rb
60
90
  - sig/schemurai.rbs
61
91
  homepage: https://github.com/oakcask/schemurai
62
92
  licenses:
@@ -64,7 +94,7 @@ licenses:
64
94
  metadata:
65
95
  homepage_uri: https://github.com/oakcask/schemurai
66
96
  source_code_uri: https://github.com/oakcask/schemurai/tree/main
67
- documentation_uri: https://rubydoc.info/gems/schemurai/2.2.3
97
+ documentation_uri: https://rubydoc.info/gems/schemurai/3.0.0
68
98
  rubygems_mfa_required: 'true'
69
99
  rdoc_options:
70
100
  - "--main"
@@ -74,14 +104,14 @@ rdoc_options:
74
104
  - "--visibility"
75
105
  - public
76
106
  - "--exclude"
77
- - lib/schemurai/(?!version\.rb)
107
+ - lib/schemurai/(?!(?:version|limit_exceeded)\.rb)
78
108
  require_paths:
79
109
  - lib
80
110
  required_ruby_version: !ruby/object:Gem::Requirement
81
111
  requirements:
82
112
  - - ">="
83
113
  - !ruby/object:Gem::Version
84
- version: '3.4'
114
+ version: '4.0'
85
115
  required_rubygems_version: !ruby/object:Gem::Requirement
86
116
  requirements:
87
117
  - - ">="
@@ -90,5 +120,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
120
  requirements: []
91
121
  rubygems_version: 4.0.20
92
122
  specification_version: 4
93
- summary: A fast, Ractor-safe, pure Ruby JSON Schema Draft 7+ validator
123
+ summary: A fast, Ractor-safe JSON Schema Draft 7+ validator
94
124
  test_files: []