Module: JsonStructure
- Defined in:
- lib/jsonstructure.rb,
lib/jsonstructure/ffi.rb,
lib/jsonstructure/version.rb,
lib/jsonstructure/binary_installer.rb,
lib/jsonstructure/schema_validator.rb,
lib/jsonstructure/validation_result.rb,
lib/jsonstructure/instance_validator.rb
Overview
JSON Structure SDK for Ruby
This gem provides Ruby bindings to the JSON Structure C library via FFI (Foreign Function Interface). It allows you to validate JSON Structure schemas and validate JSON instances against schemas.
## Thread Safety
This library is thread-safe. Multiple threads can perform validations concurrently without synchronization. The underlying C library uses proper synchronization primitives to protect shared state.
Defined Under Namespace
Modules: FFI Classes: BinaryInstaller, Error, InstanceValidationError, InstanceValidator, SchemaValidationError, SchemaValidator, ValidationError, ValidationResult
Constant Summary collapse
- VERSION =
Version of the JSON Structure Ruby SDK
'0.5.5'
Class Method Summary collapse
-
.safe_cleanup ⇒ Object
private
Safely clean up the library, waiting for active validations.
-
.validation_completed ⇒ Object
private
Track when a validation completes.
-
.validation_started ⇒ Object
private
Track when a validation starts.
-
.validations_active? ⇒ Boolean
private
Check if any validations are currently active.
Class Method Details
.safe_cleanup ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Safely clean up the library, waiting for active validations
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/jsonstructure.rb', line 87 def safe_cleanup @cleanup_mutex.synchronize do @shutting_down = true end # Wait briefly for active validations to complete (up to 1 second) 10.times do break unless validations_active? sleep 0.1 end # Perform cleanup - the C library is thread-safe, so this is safe # even if a validation is somehow still running FFI.js_cleanup end |
.validation_completed ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Track when a validation completes
71 72 73 74 75 |
# File 'lib/jsonstructure.rb', line 71 def validation_completed @cleanup_mutex.synchronize do @active_validations -= 1 end end |
.validation_started ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Track when a validation starts
61 62 63 64 65 66 67 |
# File 'lib/jsonstructure.rb', line 61 def validation_started @cleanup_mutex.synchronize do raise Error, 'Library is shutting down' if @shutting_down @active_validations += 1 end end |
.validations_active? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if any validations are currently active
79 80 81 82 83 |
# File 'lib/jsonstructure.rb', line 79 def validations_active? @cleanup_mutex.synchronize do @active_validations > 0 end end |