Module: Kiba::LegacyParser

Defined in:
lib/kiba-legacy-cli/legacy_parser.rb

Overview

NOTE: using the “Kiba::Parser” declaration, as I discovered, provides increased isolation to the declared ETL script, compared to 2 nested modules. Before that, a user creating entities named Control, Context or DSLExtensions would see a conflict with Kiba own classes, as by default instance_eval will resolve references by adding the module containing the parser class (initially “Kiba”). Now, the classes appear to be further hidden from the user, as Kiba::Parser is its own module. This allows the user to create a Parser, Context, Control class without it being interpreted as reopening Kiba::Parser, Kiba::Context, etc. See test in test_cli.rb (test_namespace_conflict)

Class Method Summary collapse

Class Method Details

.parse(source_as_string = nil, source_file = nil, &source_as_block) ⇒ Object



17
18
19
20
21
22
# File 'lib/kiba-legacy-cli/legacy_parser.rb', line 17

def parse(source_as_string = nil, source_file = nil, &source_as_block)
  control = Kiba::Control.new
  context = Kiba::Context.new(control)
  context.instance_eval(*[source_as_string, source_file].compact)
  control
end