rust_json_schema 0.1.1-arm-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8f422049544619170cd38d18de349ab4d32a5e6714474b7fd4c1e87e6a3ae82c
4
+ data.tar.gz: 69d23a30a9a43a730312f996827a0b108473622f2cabe636b59311519eb1b9ac
5
+ SHA512:
6
+ metadata.gz: 1dbb51b2d4628c56474a57c30bb98cc23a6e96050d3d661c2626ba083bce7d99ff1de1d8168d4bff7e0dce9adb3f0ad2c33c89227e56fef9c9f5bcdfb5426358
7
+ data.tar.gz: e55b9fd7f6df2a6f252c7f0922bb5f230974f4ee39fc45f9efac6893e0b62501ca701277df1a39583a168d43721c871bd6f31a06da5110ee8c5fda1aa05b700f
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
3
+ ruby_version: 2.6
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]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RustJSONSchema
4
+ VERSION = "0.1.1"
5
+ end
@@ -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
@@ -0,0 +1,4 @@
1
+ module RustJSONSchema
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ 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: arm-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: []