Module: TyranoDsl::ParsingWords::IncludeFile

Includes:
ParsingWordsModule
Defined in:
lib/tyrano_dsl/parsing_words/include_file.rb

Instance Method Summary collapse

Instance Method Details

#include_file(file_path) ⇒ void

This method returns an undefined value.

Parameters:

  • file_path (String)

Raises:



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tyrano_dsl/parsing_words/include_file.rb', line 12

def include_file(file_path)
  log {"Reading content file at [#{file_path}]"}
  complete_file_path = File.absolute_path(file_path, File.dirname(included_files_hierarchy.last))
  unless File.exist? complete_file_path
    raise TyranoDsl::TyranoException, "File not found [#{complete_file_path}]"
  end
  included_files_hierarchy << complete_file_path
  log {"Start parsing [#{complete_file_path}]"}
  file_content = IO.read(complete_file_path)
  instance_eval(file_content, complete_file_path, 1)
  log {"End parsing [#{complete_file_path}]"}
  included_files_hierarchy.pop
end