schemurai 2.2.3 → 2.3.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.
data/lib/schemurai.rb CHANGED
@@ -72,19 +72,19 @@ module Schemurai
72
72
  # Register every external schema with +schemas:+ before compiling. A registry
73
73
  # can be made shareable once registration and compilation are complete.
74
74
  class SchemaRegistry
75
- # The selected backend, either +:ruby+ or +:vm+.
75
+ # The selected backend, +:ruby+, +:vm+, or +:native+.
76
76
  attr_reader :backend
77
77
 
78
78
  # Creates a registry.
79
79
  #
80
80
  # +schemas+ maps absolute URI strings to JSON-shaped Ruby schemas. Pass
81
81
  # +validate_schema: true+ to validate every registered and compiled schema
82
- # against its meta-schema. +backend+ accepts +:ruby+, +:vm+, or +:default+.
82
+ # against its meta-schema. +backend+ accepts +:ruby+, +:vm+, +:native+, or +:default+.
83
83
  def initialize(schemas: {}, validate_schema: false, backend: Backend.requested)
84
84
  @backend = Backend.resolve(backend)
85
85
  @validate_schema = validate_schema
86
86
  @graph = Internal::SchemaGraph.new(schemas: schemas)
87
- @compiler = VM::Compiler.new(@graph) if @backend == :vm
87
+ @compiler = VM::Compiler.new(@graph) if %i[vm native].include?(@backend)
88
88
  schemas.each_value { |schema| validate_schema!(schema) } if validate_schema?
89
89
  end
90
90
 
@@ -150,7 +150,8 @@ module Schemurai
150
150
  private def build_validator(root, content:, format:)
151
151
  evaluator = if @compiler
152
152
  program = @compiler.compile(root)
153
- VM::Evaluator.new(@graph, @compiler, program, content: content, format: format)
153
+ evaluator_class = (@backend == :native) ? Native::Evaluator : VM::Evaluator
154
+ evaluator_class.new(@graph, @compiler, program, content: content, format: format)
154
155
  else
155
156
  Internal::Evaluator.new(@graph, root, content: content, format: format)
156
157
  end
@@ -177,7 +178,7 @@ module Schemurai
177
178
  @evaluator = evaluator
178
179
  end
179
180
 
180
- # The backend reported by the evaluator, either +:ruby+ or +:vm+.
181
+ # The backend reported by the evaluator, +:ruby+, +:vm+, or +:native+.
181
182
  def backend
182
183
  @evaluator.backend
183
184
  end
@@ -193,7 +194,7 @@ module Schemurai
193
194
  end
194
195
  end
195
196
 
196
- # Returns the backend selected by SCHEMURAI_BACKEND, either +:ruby+ or +:vm+.
197
+ # Returns the backend selected by SCHEMURAI_BACKEND, +:ruby+, +:vm+, or +:native+.
197
198
  module_function def backend
198
199
  Backend.resolve
199
200
  end
@@ -202,7 +203,7 @@ module Schemurai
202
203
  #
203
204
  # +schemas+ maps external URI strings to schemas. +base_uri+ supplies the
204
205
  # schema's base URI. Optional content and format assertions are disabled by
205
- # default. +backend+ accepts +:ruby+, +:vm+, or +:default+.
206
+ # default. +backend+ accepts +:ruby+, +:vm+, +:native+, or +:default+.
206
207
  module_function def compile(schema, schemas: {}, base_uri: nil, content: false, format: false, validate_schema: false, backend: Backend.requested)
207
208
  SchemaRegistry.new(schemas: schemas, validate_schema: validate_schema, backend: backend).compile(
208
209
  schema,
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
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: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuya KOHARA (oakcask)
@@ -28,13 +28,29 @@ 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/content.rs
47
+ - ext/schemurai_native/src/diagnostics.rs
48
+ - ext/schemurai_native/src/format.rs
49
+ - ext/schemurai_native/src/lib.rs
50
+ - ext/schemurai_native/src/number.rs
51
+ - ext/schemurai_native/src/pattern.rs
52
+ - ext/schemurai_native/src/scope.rs
53
+ - ext/schemurai_native/src/tracking.rs
38
54
  - lib/schemurai.rb
39
55
  - lib/schemurai/backend.rb
40
56
  - lib/schemurai/dialect.rb
@@ -50,6 +66,8 @@ files:
50
66
  - lib/schemurai/meta_schemas/draft2019_09.rb
51
67
  - lib/schemurai/meta_schemas/draft2020_12.rb
52
68
  - lib/schemurai/meta_schemas/draft7.rb
69
+ - lib/schemurai/native/diagnostics.rb
70
+ - lib/schemurai/native/evaluator.rb
53
71
  - lib/schemurai/schema_domain.rb
54
72
  - lib/schemurai/schema_graph.rb
55
73
  - lib/schemurai/schema_node.rb
@@ -64,7 +82,7 @@ licenses:
64
82
  metadata:
65
83
  homepage_uri: https://github.com/oakcask/schemurai
66
84
  source_code_uri: https://github.com/oakcask/schemurai/tree/main
67
- documentation_uri: https://rubydoc.info/gems/schemurai/2.2.3
85
+ documentation_uri: https://rubydoc.info/gems/schemurai/2.3.0
68
86
  rubygems_mfa_required: 'true'
69
87
  rdoc_options:
70
88
  - "--main"
@@ -90,5 +108,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
108
  requirements: []
91
109
  rubygems_version: 4.0.20
92
110
  specification_version: 4
93
- summary: A fast, Ractor-safe, pure Ruby JSON Schema Draft 7+ validator
111
+ summary: A fast, Ractor-safe JSON Schema Draft 7+ validator
94
112
  test_files: []