Class: DtkCommon::DSL::FileParser

Inherits:
Object
  • Object
show all
Defined in:
lib/dsl/file_parser.rb,
lib/dsl/file_parser/file_types/assembly/v2/assembly.rb,
lib/dsl/file_parser/file_types/component_module_refs/v1/component_module_refs.rb

Direct Known Subclasses

Assembly, ComponentModuleRefs

Defined Under Namespace

Classes: Assembly, ComponentModuleRefs, InputHash, OutputArray, OutputHash

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_hash_class) ⇒ FileParser

Returns a new instance of FileParser.



74
75
76
# File 'lib/dsl/file_parser.rb', line 74

def initialize(input_hash_class)
  @input_hash_class = input_hash_class
end

Class Method Details

.generate_hash(file_type, output_array, opts = {}) ⇒ Object



102
103
104
105
# File 'lib/dsl/file_parser.rb', line 102

def self.generate_hash(file_type,output_array,opts={})
  file_parser = Loader.file_parser(file_type,opts[:version])
  file_parser.generate_hash(output_array)
end

.implements_method?(method_name) ⇒ Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/dsl/file_parser.rb', line 78

def self.implements_method?(method_name)
  [:parse_content,:generate_hash].include?(method_name)
end

.parse_content(file_type, file_content, opts = {}) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/dsl/file_parser.rb', line 82

def self.parse_content(file_type,file_content,opts={})
  ret = OutputArray.new
  # if there is no content (nil) return empty array as if content was empty
  return ret unless file_content
  file_parser = Loader.file_parser(file_type,opts[:version])
  # raw_hash_content = convert_json_content_to_hash(file_content,opts)
  #TODO: for Rich
  # we need to implement dsl v3 parser, this is just temp fix for autoimport
  # just changed parser to yaml instead of json because new modules/services
  # are in yaml format now
  raw_hash_content = convert_yaml_content_to_hash(file_content,opts)
  return raw_hash_content if raw_hash_content.is_a?(ErrorUsage::DSLParsing::JSONParsing)

  file_parser.parse_hash_content_aux(raw_hash_content)
end

Instance Method Details

#parse_hash_content_aux(raw_hash) ⇒ Object



98
99
100
# File 'lib/dsl/file_parser.rb', line 98

def parse_hash_content_aux(raw_hash)
  parse_hash_content(input_form(raw_hash))
end