Class: Blumquist

Inherits:
Object
  • Object
show all
Defined in:
lib/blumquist/json_pointer.rb,
lib/blumquist.rb,
lib/blumquist/error.rb,
lib/blumquist/version.rb,
lib/blumquist/errors/validation.rb,
lib/blumquist/errors/invalid_pointer.rb,
lib/blumquist/errors/unsupported_type.rb,
lib/blumquist/errors/validation_error.rb,
lib/blumquist/errors/missing_properties.rb,
lib/blumquist/errors/unsupported_schema.rb,
lib/blumquist/errors/unsupported_pointer.rb,
lib/blumquist/errors/no_compatible_one_of.rb,
lib/blumquist/errors/missing_array_items_type.rb

Overview

JSON Pointer This is a VERY BASIC implementation to support pointers in the form of:

 1. #/key1/key2/.../keyN
 2. path_to_file.json
 3. path_to_file.json#/key1/key2/.../keyN

More about JSON Pointer & Reference Specification
https://cswr.github.io/JsonSchema/spec/definitions_references/#json-pointers

Defined Under Namespace

Modules: Errors Classes: Error, JSONPointer

Constant Summary collapse

PRIMITIVE_TYPES =
%w{null boolean number string enum integer}.freeze
VERSION =
'0.10.1'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Blumquist

Returns a new instance of Blumquist.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/blumquist.rb', line 13

def initialize(options)
  # Poor man's deep clone: json 🆗 🆒
  @data = JSON.parse(options.fetch(:data).to_json)
  @schema = options.fetch(:schema).with_indifferent_access
  @original_properties = options.fetch(:schema).with_indifferent_access[:properties]
  @validate = options.fetch(:validate, true)

  validate_schema
  validate_data

  resolve_json_pointers
  define_getters
end

Instance Attribute Details

#_typeObject

Returns the value of attribute _type.



11
12
13
# File 'lib/blumquist.rb', line 11

def _type
  @_type
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



39
40
41
# File 'lib/blumquist.rb', line 39

def ==(other)
  self.class == other.class && other.marshal_dump == marshal_dump
end

#marshal_dumpObject



31
32
33
# File 'lib/blumquist.rb', line 31

def marshal_dump
  [@schema, @data, @validate]
end

#marshal_load(array) ⇒ Object



35
36
37
# File 'lib/blumquist.rb', line 35

def marshal_load(array)
  @schema, @data, @validate = array
end

#to_sObject



27
28
29
# File 'lib/blumquist.rb', line 27

def to_s
  inspect
end