class Kafo::DataTypeParser

Constants

TYPE_DEFINITION

Attributes

types[R]

Public Class Methods

new(manifest) click to toggle source
# File lib/kafo/data_type_parser.rb, line 9
def initialize(manifest)
  @logger = KafoConfigure.logger

  lines = []
  type_line_without_newlines = +''
  manifest.each_line do |line|
    line = line.force_encoding("UTF-8").strip
    next if line.start_with?('#')

    line = line.split(' #').first.strip
    if line =~ TYPE_DEFINITION
      lines << type_line_without_newlines
      type_line_without_newlines = line
    else
      type_line_without_newlines << line
    end
  end
  lines << type_line_without_newlines

  @types = {}
  lines.each do |line|
    if (type = TYPE_DEFINITION.match(line))
      @types[type[1]] = type[2]
    end
  end
end

Public Instance Methods

register() click to toggle source
# File lib/kafo/data_type_parser.rb, line 36
def register
  @types.each do |name,target|
    @logger.debug("Registering extended data type #{name}")
    DataType.register_type(name, target)
  end
end