Class: Xmi::EaRoot

Inherits:
Object show all
Defined in:
lib/xmi/ea_root.rb

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

MODULE_TEMPLATE =
<<~TEXT
  module Xmi
    class EaRoot
      module #MODULE_NAME#
  #KLASSES#
      end
    end
  end
TEXT
KLASS_TEMPLATE =
<<~TEXT
        class #KLASS_NAME# < #FROM_KLASS#
          #ROOT_TAG_LINE#

  #ATTRIBUTES##XML_MAPPING#
        end
TEXT
XML_MAPPING =
<<~TEXT
          xml do
            root "#ROOT_TAG#"
  #MAP_ATTRIBUTES#
          end
TEXT
ATTRIBUTE_LINE =
<<~TEXT
  attribute :#TAG_NAME#, #ATTRIBUTE_TYPE#
TEXT
MAP_ATTRIBUTES =
<<~TEXT
  map_attribute "#ATTRIBUTE_NAME#", to: :#ATTRIBUTE_METHOD#
TEXT
MAP_ELEMENT =
<<~TEXT
  map_element "#ELEMENT_NAME#",
              to: :#ELEMENT_METHOD#,
              namespace: "#NAMESPACE#",
              prefix: "#PREFIX#"
TEXT

Class Method Summary collapse

Class Method Details

.load_extension(options) ⇒ Object



56
57
58
59
# File 'lib/xmi/ea_root.rb', line 56

def load_extension(options)
  @content = gen_content(options)
  Object.class_eval @content
end

.load_mdg_extension(xml_path) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/xmi/ea_root.rb', line 48

def load_mdg_extension(xml_path)
  options = {}
  options[:input_xml_path] = xml_path
  options[:module_name] = "Mdg"
  load_extension(options)
  update_mdg_mappings
end

.output_rb_file(output_rb_path) ⇒ Object



61
62
63
# File 'lib/xmi/ea_root.rb', line 61

def output_rb_file(output_rb_path)
  File.open(output_rb_path, "w") { |file| file.write(@content) }
end