Class: Idcf::JsonHyperSchema::Analyst

Inherits:
Object
  • Object
show all
Defined in:
lib/idcf/json_hyper_schema/analyst.rb

Overview

json-hyper-schema analyst

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#load_schemaObject (readonly)

Returns the value of attribute load_schema.



7
8
9
# File 'lib/idcf/json_hyper_schema/analyst.rb', line 7

def load_schema
  @load_schema
end

#process_versionObject (readonly)

Returns the value of attribute process_version.



7
8
9
# File 'lib/idcf/json_hyper_schema/analyst.rb', line 7

def process_version
  @process_version
end

#schemaObject (readonly)

Returns the value of attribute schema.



7
8
9
# File 'lib/idcf/json_hyper_schema/analyst.rb', line 7

def schema
  @schema
end

Instance Method Details

#expand(schema, options = {}) ⇒ Expand::Base

json file laod

Parameters:

  • (defaults to: {})

Returns:

Raises:



41
42
43
44
45
46
47
# File 'lib/idcf/json_hyper_schema/analyst.rb', line 41

def expand(schema, options = {})
  return schema unless schema.class == Hash
  @process_version = schema_version(schema)
  result           = expand_class.new(options)
  result.do!(schema)
  result
end

#json_schema_initObject



9
10
11
12
13
14
15
# File 'lib/idcf/json_hyper_schema/analyst.rb', line 9

def json_schema_init
  configuration = JsonSchema.configuration
  Idcf::JsonHyperSchema::Validation.validations.each do |key, val|
    configuration.register_format(key, val)
  end
  self
end

links

Returns:

  • Expands::LinkInfoBase



52
53
54
55
56
57
58
# File 'lib/idcf/json_hyper_schema/analyst.rb', line 52

def links
  json_schema_init
  p_schema         = JsonSchema.parse!(@load_schema)
  @process_version = schema_version(p_schema)
  p_schema.expand_references!
  find_links(p_schema)
end

#load(path, options = {}) ⇒ Hash

json file laod

Parameters:

  • (defaults to: {})

Returns:

Raises:



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/idcf/json_hyper_schema/analyst.rb', line 23

def load(path, options = {})
  @schema ||= {}
  unless @schema[path].nil?
    @load_schema = @schema[path]
    return self
  end
  j             = JSON.parse(File.read(path))
  @load_schema  = expand(j, options).schema
  @schema[path] = @load_schema
  self
end

schema links

Parameters:

  • (defaults to: {})

Returns:

  • Expands::LinkInfoBase



65
66
67
68
69
70
71
72
73
74
# File 'lib/idcf/json_hyper_schema/analyst.rb', line 65

def schema_links(schema, options = {})
  ex_schema = expand(schema, options)
  json_schema_init
  p_schema = JsonSchema.parse!(ex_schema.schema)
  t_v      = @process_version
  p_schema.expand_references!
  result           = find_links(p_schema)
  @process_version = t_v
  result
end