schemurai 2.1.0 → 2.2.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.
data/sig/schemurai.rbs ADDED
@@ -0,0 +1,100 @@
1
+ module Schemurai
2
+ # A JSON-shaped Ruby value accepted as a schema value or validation instance.
3
+ type json_value = nil | bool | Integer | Float | String | Array[json_value] | Hash[String, json_value]
4
+
5
+ # A JSON Schema root.
6
+ type schema = bool | Hash[String, json_value]
7
+
8
+ # External schemas indexed by their absolute URI.
9
+ type schemas = Hash[String, schema]
10
+
11
+ # A resolved evaluator backend.
12
+ type backend = :ruby | :vm
13
+
14
+ # A backend accepted when configuring a validator.
15
+ type backend_selection = backend | :default
16
+
17
+ VERSION: String
18
+
19
+ class Error < StandardError
20
+ end
21
+
22
+ class ResolutionError < Error
23
+ end
24
+
25
+ class UnsupportedFormatError < Error
26
+ end
27
+
28
+ class InvalidSchemaError < Error
29
+ attr_reader result: Result
30
+
31
+ def initialize: (Result result) -> void
32
+ end
33
+
34
+ class ValidationError < Data
35
+ attr_reader keyword: String
36
+ attr_reader instance_path: String
37
+ attr_reader schema_path: String
38
+ attr_reader message: String
39
+
40
+ def self.new: (String keyword, String instance_path, String schema_path, String message) -> ValidationError
41
+ | (keyword: String, instance_path: String, schema_path: String, message: String) -> ValidationError
42
+
43
+ def self.[]: (String keyword, String instance_path, String schema_path, String message) -> ValidationError
44
+ | (keyword: String, instance_path: String, schema_path: String, message: String) -> ValidationError
45
+
46
+ def to_h: () -> { keyword: String, instance_path: String, schema_path: String, message: String }
47
+ end
48
+
49
+ class Result
50
+ attr_reader errors: Array[ValidationError]
51
+
52
+ def initialize: (Array[ValidationError] errors) -> void
53
+ def valid?: () -> bool
54
+ alias success? valid?
55
+ end
56
+
57
+ interface _Evaluator
58
+ def backend: () -> backend
59
+
60
+ def validate: (json_value instance) -> Result
61
+
62
+ def valid?: (json_value instance) -> bool
63
+ end
64
+
65
+ class Validator
66
+ def initialize: (_Evaluator evaluator) -> void
67
+ def backend: () -> backend
68
+ def validate: (json_value instance) -> Result
69
+ def valid?: (json_value instance) -> bool
70
+ end
71
+
72
+ class SchemaRegistry
73
+ attr_reader backend: backend
74
+
75
+ def initialize: (?schemas: schemas, ?validate_schema: bool, ?backend: backend_selection) -> void
76
+
77
+ def validate_schema?: () -> bool
78
+
79
+ def compile: (schema schema, ?base_uri: String?, ?content: bool, ?format: bool) -> Validator
80
+
81
+ def validate_schema: (schema schema) -> Result
82
+ def valid_schema?: (schema schema) -> bool
83
+ def make_shareable: () -> self
84
+ def shareable?: () -> bool
85
+
86
+ def validator_for: (String uri, ?content: bool, ?format: bool) -> Validator
87
+ end
88
+
89
+ def self.backend: () -> backend
90
+
91
+ def self.compile: (schema schema, ?schemas: schemas, ?base_uri: String?, ?content: bool, ?format: bool, ?validate_schema: bool, ?backend: backend_selection) -> Validator
92
+
93
+ def self.validate_schema: (schema schema, ?schemas: schemas, ?backend: backend_selection) -> Result
94
+
95
+ def self.valid_schema?: (schema schema, ?schemas: schemas, ?backend: backend_selection) -> bool
96
+
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
98
+
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
100
+ 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.1.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuya KOHARA (oakcask)
@@ -56,13 +56,14 @@ files:
56
56
  - lib/schemurai/version.rb
57
57
  - lib/schemurai/vm/compiler.rb
58
58
  - lib/schemurai/vm/evaluator.rb
59
+ - sig/schemurai.rbs
59
60
  homepage: https://github.com/oakcask/schemurai
60
61
  licenses:
61
62
  - MIT
62
63
  metadata:
63
64
  homepage_uri: https://github.com/oakcask/schemurai
64
65
  source_code_uri: https://github.com/oakcask/schemurai/tree/main
65
- documentation_uri: https://rubydoc.info/gems/schemurai/2.1.0
66
+ documentation_uri: https://rubydoc.info/gems/schemurai/2.2.1
66
67
  rubygems_mfa_required: 'true'
67
68
  rdoc_options:
68
69
  - "--main"