Method: DBGeni::Config#include_file

Defined in:
lib/dbgeni/config.rb

#include_file(*p) ⇒ Object



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/dbgeni/config.rb', line 297

def include_file(*p)
  file = p[0]
  if !is_absolute_path?(file)
    file = File.join(@base_directory, file)
  end
  begin
    raw_config = ''
    File.open(file) do |f|
      raw_config = f.read
    end
    self.load(raw_config)
  rescue Errno::ENOENT
    raise DBGeni::ConfigFileNotExist, "Included config #{file} does not exist"
  rescue DBGeni::ConfigSyntaxError
    raise DBGeni::ConfigSyntaxError,  "Included config #{file} contains errors: #{e.to_s}"
  end
end