Method: OpenC3::ConfigParser#read_file

Defined in:
lib/openc3/config/config_parser.rb

#read_file(filename) ⇒ Object

Can be called during parsing to read a referenced file



173
174
175
176
177
178
179
180
181
182
183
# File 'lib/openc3/config/config_parser.rb', line 173

def read_file(filename)
  # Assume the file is there. If not we raise a pretty obvious error
  if File.expand_path(filename) == filename # absolute path
    path = filename
  else # relative to the current @filename
    path = File.join(File.dirname(@filename), filename)
  end
  OpenC3.set_working_dir(File.dirname(path)) do
    return File.read(path)
  end
end