Class: JsonSchemaView::SchemaSet

Inherits:
Object
  • Object
show all
Includes:
ConstantSearchHelper
Defined in:
lib/json_schema_view/schema_set.rb,
lib/json_schema_view/schema_set/constant_search_helper.rb

Overview

Builder build components

Defined Under Namespace

Modules: ConstantSearchHelper

Instance Method Summary collapse

Methods included from ConstantSearchHelper

#all_constants, #search_component_classes, #search_constants

Instance Method Details

#clear_export_pathvoid

This method returns an undefined value.



54
55
56
# File 'lib/json_schema_view/schema_set.rb', line 54

def clear_export_path
  FileUtils.rm_rf(export_path) if Dir.exist?(export_path)
end

#export_json_schemas(print_logs: false) ⇒ void

This method returns an undefined value.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/json_schema_view/schema_set.rb', line 33

def export_json_schemas(print_logs: false)
  puts "Exports resource classes in #{self.class.name}..." if print_logs
  export_pathname = Pathname.new(export_path)

  exports = resource_classes_to_export.map do |resource_class|
    destination = export_pathname.join("#{resource_class.name.demodulize}.json")
    klass = resource_class < JsonSchemaView::BaseComponent ? resource_class.props_class : resource_class

    [destination, resource_class, klass.to_json_schema]
  end

  clear_export_path

  exports.each do |destination, resource_class, json_schema|
    FileUtils.mkdir_p(destination.dirname)
    destination.write(json_schema)
    puts "#{resource_class.name} -> #{destination}" if print_logs
  end
end

#export_pathString

This method is abstract.

Returns:

  • (String)

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/json_schema_view/schema_set.rb', line 23

def export_path
  raise NotImplementedError
end

#resource_classes_to_exportArray<Class<JsonSchemaDefinable>>

Returns:



28
29
30
# File 'lib/json_schema_view/schema_set.rb', line 28

def resource_classes_to_export
  []
end

#root_pathString

This method is abstract.

Returns:

  • (String)

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/json_schema_view/schema_set.rb', line 17

def root_path
  raise NotImplementedError
end