rust_json_schema 0.1.2-aarch64-linux → 0.3.0-aarch64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0b3e12b6f6e00db3410f03030c8f3f1d122ee67622aa3e4fe40145a2591bcfa
4
- data.tar.gz: bd4a64760f85b38bcf0601e22037ab9cf391414378e72a8edb97558e3ed7e604
3
+ metadata.gz: 8c43cf0d778cc4090f1ce40231632df629ddcb453f5dade93c509ea6e96b6f06
4
+ data.tar.gz: 5b6397a1ca7d54835a9d19f505249c8b0350fc34a49fd4aa53483c3666ce360c
5
5
  SHA512:
6
- metadata.gz: f37d55cf171b4c3fc92ae8f79fe2710d021bae267aaaff46fe32247c8fa66f4ff01e810da45eba902d47337538db911fc920ba978a9444f2c90239f08103c738
7
- data.tar.gz: 0e57a35a246e2ed9178988b7d9a9152c5c6d7868dab8c58cfc719bd02e784eff4cc84f67e55aff689d9149a468cd8ca75f742c99b40f356d9f57746daa1bc695
6
+ metadata.gz: fc03cb568fa5bb8c07a6baba180b83906e0f4584d31f31e99a11d4daf2eec5306e6e730ce6d4704f9c7f0887cb291413f304355de3085ff2ff4cd6abc57a34f9
7
+ data.tar.gz: 73feab58c0a217fa4bfded1d703926db1dd5b90fbb1a2cab46294f27faa471852d83132d80649ecdda7d5295723ab442bcfc560d40b758d6f638721fdffd68c4
data/README.md CHANGED
@@ -4,13 +4,18 @@
4
4
 
5
5
  `rust_json_schema` is a Ruby wrapper gem for Rust's [jsonschema-rs crate](https://github.com/Stranger6667/jsonschema-rs).
6
6
 
7
- This gem ships with precompiled binaries for Linux and macOS. Check the available gems on [Rubygems](https://rubygems.org/gems/rust_json_schema).
7
+ > [!IMPORTANT]
8
+ > This gem is built with `json_schema` crate version `0.19.1`, and therefore does not support any features for any potential future versions of the crate. I will review and accept PRs if you would like to work on adding support for newer versions of the crate. I generally am trying to keep things up to date but I am not cutting new releases for each new patch version of the crate.
8
9
 
9
- ## Warning
10
+ The minimum Ruby version required by this gem is 3.0, due to the runtime Rust libraries that make the extensions possible (and easy).
11
+
12
+ This gem ships with precompiled binaries for Linux and macOS. Check the available gems on [Rubygems](https://rubygems.org/gems/rust_json_schema). Precompiled binaries do not exist for non-standard rubies like JRuby or TruffleRuby, nor do they exist for Windows. I will review and accept PRs if you would like to work on adding these build targets.
13
+
14
+ [rusty_json_schema](https://github.com/driv3r/rusty_json_schema) is a direct source of inspiration. 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), and by extension, the [oxidize-rb team](https://github.com/oxidize-rb).
10
15
 
11
- 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.
16
+ ## Warning
12
17
 
13
- [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), and by extension, the [oxidize-rb team](https://github.com/oxidize-rb).
18
+ My experience with Rust is limited, but this gem does have tests, and it is deployed in production. Please confirm that the gem is working as expected before using it in any production-critical situation. If you are using this gem in a production environment, and have any comments or feedback, I would love to hear about it.
14
19
 
15
20
  ## Installation
16
21
 
@@ -25,7 +30,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
25
30
  ## Usage
26
31
 
27
32
  ```ruby
28
- validator = RustJSONSchema::Validator.new(<<~JSON)
33
+ schema = <<~JSON
29
34
  {
30
35
  "properties": {
31
36
  "foo": { "type": "string" },
@@ -36,6 +41,8 @@ validator = RustJSONSchema::Validator.new(<<~JSON)
36
41
  }
37
42
  JSON
38
43
 
44
+ validator = RustJSONSchema::Validator.new(schema, draft: :draft7)
45
+
39
46
  errors = validator.validate('{ "foo": 1, "bar": "wadus" }')
40
47
  # => [
41
48
  # 'path "/bar": "wadus" is not of type "number"',
@@ -44,19 +51,28 @@ errors = validator.validate('{ "foo": 1, "bar": "wadus" }')
44
51
  # ]
45
52
  ```
46
53
 
54
+ ### Options
55
+
56
+ - `:draft` - Select the JSON schema draft number to use. Valid options are `draft4`, `draft6`, `draft7`, `draft201909`, and `draft202012`. Supported drafts are entirely determined by the `jsonschema` crate. The default draft is also determined by the crate. If new versions of the crate support additional draft versions, a code change in this gem will be required. I'm open to PRs to solve this problem - I don't know enough Rust to tell if it's easily done. _Both `draft201909` and `draft202012` are reported to have "some keywords not implemented", so use them at your own risk._
57
+
58
+ Any additional options provided by the `jsonschema` crate are options I do not understand or may not make sense to implement in a wrapper library such as this.
59
+
60
+ `RustJSONSchema::Validator#options` is provided and will return a Hash containing configuration options from the underlying Rust library. While I make an effort for them to look similar, or identical, to the options passed into the `Validator` initializer, the initializer arguments and the returned Hash should not be considered one-to-one. It exists as a way to confirm the configuration of the underlying schema validator instance.
61
+
47
62
  ### Errors
48
63
 
49
64
  - All errors are subclasses of `RustJSONSchema::Error`.
50
65
  - Calling `RustJSONSchema::Validator#new`, `#validate` or `#valid?` with a string which is not valid JSON will raise `RustJSONSchema::JSONParseError`.
51
66
  - Calling `RustJSONSchema::Validator#new` with an invalid schema will raise `RustJSONSchema::SchemaParseError`.
67
+ - Calling `RustJSONSchema::Validator#new` with an invalid draft version value will raise `RustJSONSchema::InvalidOptionsError`.
52
68
 
53
- ## TODO
69
+ ## Development
54
70
 
55
- - Support passing options as `jsonschema-rs` does
71
+ The rust extension is located at `ext/rust_json_schema`, and can be compiled using the `rake-compiler` tasks, usually `bin/rake compile`. Don't attempt to `cargo build` the extension separately, that typically doesn't work. View other rake tasks with `bin/rake --tasks`.
56
72
 
57
- ## Development
73
+ You can run the tests with `bin/rspec`, but ensure any changes to the rust extension are compiled first.
58
74
 
59
- TODO
75
+ To release a new version, update the version number in `version.rb`, tag the new commit with the version number, and push the tag to GitHub. The gem will be built and pushed to Rubygems automatically. This will also automatically build the platform-specific binaries and attach them to the release.
60
76
 
61
77
  ## Contributing
62
78
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RustJSONSchema
4
- VERSION = "0.1.2"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -8,6 +8,8 @@ module RustJSONSchema
8
8
  class JSONParseError < Error; end
9
9
 
10
10
  class SchemaParseError < Error; end
11
+
12
+ class InvalidOptionsError < Error; end
11
13
  end
12
14
 
13
15
  # Tries to require the extension for the given Ruby version first
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rust_json_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.3.0
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Taylor Thurlow
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-12 00:00:00.000000000 Z
11
+ date: 2024-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -57,13 +57,13 @@ files:
57
57
  - lib/rust_json_schema/3.3/rust_json_schema.so
58
58
  - lib/rust_json_schema/version.rb
59
59
  - sig/rust_json_schema.rbs
60
- homepage: https://github.com/taylorthurlow/rust_json_schema
60
+ homepage: https://github.com/taylorthurlow/rust_json_schema-rb
61
61
  licenses:
62
62
  - MIT
63
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
64
+ homepage_uri: https://github.com/taylorthurlow/rust_json_schema-rb
65
+ source_code_uri: https://github.com/taylorthurlow/rust_json_schema-rb
66
+ changelog_uri: https://github.com/taylorthurlow/rust_json_schema-rb/releases
67
67
  post_install_message:
68
68
  rdoc_options: []
69
69
  require_paths: