Class: Superstudio::SqlJsonBuilder

Inherits:
Object
  • Object
show all
Includes:
SchemaInternalDefiner, SchemaInterpreter, SchemaReader
Defined in:
lib/superstudio.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SchemaInternalDefiner

#add_to_describe_arrays, #convert_fork_paths_to_base_route_numbers, #generate_internal_fork_number_of_type, #handle_array_stop_path, #set_human_to_internal_mappings

Methods included from SchemaInterpreter

#create_template, #interpret_json_schema

Methods included from SchemaReader

#parse_json_schema, #read_schema, #replace_reference_keys, #schema_maps_directory, #schemas_directory

Constructor Details

#initialize(query, file_name = nil) ⇒ SqlJsonBuilder

Returns a new instance of SqlJsonBuilder.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/superstudio.rb', line 14

def initialize(query, file_name = nil)
  file_class_name = self.class.name
  file_class_name.slice!("Mapper")
  file_name ||= file_class_name.underscore << ".json.schema"

  @schema = read_schema(file_name)

  @sql_columns, @row_being_used = [], []
  @json_result = ""
  @json_nodes, @required_columns = {}, {}

  @unique_threes_tags, @human_readable_tags, @internal_use_tags, @quoted_tags, @do_not_hash, @depth_tags, @real_depth_tags, @column_names = [], [], [], [], [], [], [], []
  @type_2_paths, @type_3_paths, @type_4_paths, @type_5_paths = [], [], [], []
  @type_2_indicator_names, @type_4_indicator_names = ["root"], []
  @unique_threes_paths = []

  json_schema_interpretation = interpret_json_schema(@schema)

  if query.present?
    result_set = get_sql_results(query)
    set_human_to_internal_mappings(json_schema_interpretation)
    assemble_json(result_set)
  else
    create_template(json_schema_interpretation)
  end
end

Instance Attribute Details

#array_pathsObject

Returns the value of attribute array_paths.



12
13
14
# File 'lib/superstudio.rb', line 12

def array_paths
  @array_paths
end

#human_to_internalObject

Returns the value of attribute human_to_internal.



12
13
14
# File 'lib/superstudio.rb', line 12

def human_to_internal
  @human_to_internal
end

#json_nodesObject

Returns the value of attribute json_nodes.



12
13
14
# File 'lib/superstudio.rb', line 12

def json_nodes
  @json_nodes
end

#json_resultObject

Returns the value of attribute json_result.



12
13
14
# File 'lib/superstudio.rb', line 12

def json_result
  @json_result
end

#required_columnsObject

Returns the value of attribute required_columns.



12
13
14
# File 'lib/superstudio.rb', line 12

def required_columns
  @required_columns
end

#schemaObject

Returns the value of attribute schema.



12
13
14
# File 'lib/superstudio.rb', line 12

def schema
  @schema
end

#sql_columnsObject

Returns the value of attribute sql_columns.



12
13
14
# File 'lib/superstudio.rb', line 12

def sql_columns
  @sql_columns
end

#template_bodiesObject

Returns the value of attribute template_bodies.



12
13
14
# File 'lib/superstudio.rb', line 12

def template_bodies
  @template_bodies
end

#template_typesObject

Returns the value of attribute template_types.



12
13
14
# File 'lib/superstudio.rb', line 12

def template_types
  @template_types
end