Class: Lutaml::Lml::Preprocessor

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/lml/preprocessor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_file) ⇒ Preprocessor

Returns a new instance of Preprocessor.



8
9
10
# File 'lib/lutaml/lml/preprocessor.rb', line 8

def initialize(input_file)
  @input_file = input_file
end

Instance Attribute Details

#input_fileObject (readonly)

Returns the value of attribute input_file.



6
7
8
# File 'lib/lutaml/lml/preprocessor.rb', line 6

def input_file
  @input_file
end

Class Method Details

.call(input_file) ⇒ Object



13
14
15
# File 'lib/lutaml/lml/preprocessor.rb', line 13

def call(input_file)
  new(input_file).call
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
# File 'lib/lutaml/lml/preprocessor.rb', line 18

def call
  input_file.rewind
  include_root = input_file.is_a?(StringIO) ? Dir.pwd : File.dirname(input_file.path)
  input_file.read.split("\n").reduce([]) do |res, line|
    res.push(*process_dsl_line(include_root, line))
  end.join("\n")
end