rust_json_schema 0.1.1-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.standard.yml +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +65 -0
- data/Rakefile +24 -0
- data/lib/rust_json_schema/3.0/rust_json_schema.so +0 -0
- data/lib/rust_json_schema/3.1/rust_json_schema.so +0 -0
- data/lib/rust_json_schema/3.2/rust_json_schema.so +0 -0
- data/lib/rust_json_schema/3.3/rust_json_schema.so +0 -0
- data/lib/rust_json_schema/version.rb +5 -0
- data/lib/rust_json_schema.rb +19 -0
- data/sig/rust_json_schema.rbs +4 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ed875d1520e782d339da205e717e3096608c3c72b3cbebd9a2804d2a6e4fda27
|
4
|
+
data.tar.gz: 9374e434c3546812b2681bb6d13997e95602d5270f05ff98062fb572a4a9a386
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 12719f58bf15a60bdf26a581f8ae86910d14b1ea4da98a8a743b0f6f7ce71afdab3cb231017a27bccafb80829ed2833c374e0c1b36e15855182ef1f943dad9cc
|
7
|
+
data.tar.gz: 9f611191c75f6d9a4f421c9fe5acbbe910b0fb15b64e2aa2ec47ce338b2c7a5fa125f1cf657c4f07ed2f675b06ffb9f5cc216a19f9ccb82c5bd46dbaff54e8a1
|
data/.rspec
ADDED
data/.standard.yml
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Taylor Thurlow
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# `rust_json_schema`
|
2
|
+
|
3
|
+
`rust_json_schema` is a Ruby wrapper gem for Rust's [jsonschema-rs crate](https://github.com/Stranger6667/jsonschema-rs).
|
4
|
+
|
5
|
+
## Warning
|
6
|
+
|
7
|
+
I do not have any significant Rust programming experience, but this gem satisifies a need for a performant JSON Schema validation tool in Ruby land. While I intend to use this gem in a production environment, consider this code and library entirely experimental, at least until a 1.0 release, if it ever comes to that.
|
8
|
+
|
9
|
+
[rusty_json_schema](https://github.com/driv3r/rusty_json_schema) is a direct source of inspiration (and in some cases, literal copy and paste, like some fixtures/specs). Now that [bundler has explicit support for rust-backed Ruby gems](https://bundler.io/blog/2023/01/31/rust-gem-skeleton.html) as of early 2023, the Rust library code is a lot simpler that it previously needed to be, largely thanks to [magnus crate](https://github.com/matsadler/magnus) and the [rb-sys gem](https://github.com/oxidize-rb/rb-sys/tree/main/gem).
|
10
|
+
|
11
|
+
Eventually I intend to ship common platform binaries as part of this gem, eliminating the need for a Rust toolchain on client machines, but that is not yet the case.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Install the gem and add to the application's Gemfile by executing:
|
16
|
+
|
17
|
+
$ bundle add rust_json_schema
|
18
|
+
|
19
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
20
|
+
|
21
|
+
$ gem install rust_json_schema
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
validator = RustJSONSchema::Validator.new(<<~JSON)
|
27
|
+
{
|
28
|
+
"properties": {
|
29
|
+
"foo": { "type": "string" },
|
30
|
+
"bar": { "type": "integer" },
|
31
|
+
"baz": {},
|
32
|
+
},
|
33
|
+
"required": ["foo", "baz"],
|
34
|
+
}
|
35
|
+
JSON
|
36
|
+
|
37
|
+
errors = validator.validate('{ "foo": 1, "bar": "wadus" }')
|
38
|
+
# => [
|
39
|
+
# 'path "/bar": "wadus" is not of type "number"',
|
40
|
+
# 'path "/foo": 1 is not of type "string"',
|
41
|
+
# 'path "/": "baz" is a required property'
|
42
|
+
# ]
|
43
|
+
```
|
44
|
+
|
45
|
+
### Errors
|
46
|
+
|
47
|
+
- All errors are subclasses of `RustJSONSchema::Error`.
|
48
|
+
- Calling `RustJSONSchema::Validator#new`, `#validate` or `#valid?` with a string which is not valid JSON will raise `RustJSONSchema::JSONParseError`.
|
49
|
+
- Calling `RustJSONSchema::Validator#new` with an invalid schema will raise `RustJSONSchema::SchemaParseError`.
|
50
|
+
|
51
|
+
## TODO
|
52
|
+
|
53
|
+
- Support passing options as `jsonschema-rs` does
|
54
|
+
|
55
|
+
## Development
|
56
|
+
|
57
|
+
TODO
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
Bug reports and pull requests are welcome.
|
62
|
+
|
63
|
+
## License
|
64
|
+
|
65
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
require "standard/rake"
|
9
|
+
|
10
|
+
require "rb_sys/extensiontask"
|
11
|
+
|
12
|
+
task build: :compile
|
13
|
+
|
14
|
+
rubies = ["3.3.0", "3.2.0", "3.1.0", "3.0.0"]
|
15
|
+
ENV["RUBY_CC_VERSION"] ||= rubies.join(":")
|
16
|
+
|
17
|
+
spec = Bundler::GemHelper.gemspec
|
18
|
+
RbSys::ExtensionTask.new("rust_json_schema", spec) do |ext|
|
19
|
+
ext.lib_dir = "lib/rust_json_schema"
|
20
|
+
|
21
|
+
ext.cross_compile = true
|
22
|
+
end
|
23
|
+
|
24
|
+
task default: %i[compile spec standard]
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "rust_json_schema/version"
|
4
|
+
|
5
|
+
# Tries to require the extension for the given Ruby version first
|
6
|
+
begin
|
7
|
+
RUBY_VERSION =~ /(\d+\.\d+)/
|
8
|
+
require "rust_json_schema/#{Regexp.last_match(1)}/rust_json_schema"
|
9
|
+
rescue LoadError
|
10
|
+
require_relative "rust_json_schema/rust_json_schema"
|
11
|
+
end
|
12
|
+
|
13
|
+
module RustJSONSchema
|
14
|
+
class Error < StandardError; end
|
15
|
+
|
16
|
+
class JSONParseError < Error; end
|
17
|
+
|
18
|
+
class SchemaParseError < Error; end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rust_json_schema
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: x86_64-linux
|
6
|
+
authors:
|
7
|
+
- Taylor Thurlow
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-01-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake-compiler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake-compiler-dock
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Ruby wrapper for jsonschema-rs
|
42
|
+
email:
|
43
|
+
- thurlow@hey.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".rspec"
|
49
|
+
- ".standard.yml"
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/rust_json_schema.rb
|
54
|
+
- lib/rust_json_schema/3.0/rust_json_schema.so
|
55
|
+
- lib/rust_json_schema/3.1/rust_json_schema.so
|
56
|
+
- lib/rust_json_schema/3.2/rust_json_schema.so
|
57
|
+
- lib/rust_json_schema/3.3/rust_json_schema.so
|
58
|
+
- lib/rust_json_schema/version.rb
|
59
|
+
- sig/rust_json_schema.rbs
|
60
|
+
homepage: https://github.com/taylorthurlow/rust_json_schema
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata:
|
64
|
+
homepage_uri: https://github.com/taylorthurlow/rust_json_schema
|
65
|
+
source_code_uri: https://github.com/taylorthurlow/rust_json_schema
|
66
|
+
changelog_uri: https://github.com/taylorthurlow/rust_json_schema/releases
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 3.4.dev
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 3.3.11
|
84
|
+
requirements: []
|
85
|
+
rubygems_version: 3.4.4
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Ruby wrapper for jsonschema-rs
|
89
|
+
test_files: []
|