Module: UniverseCompiler::Package::Bootstrap

Included in:
Base
Defined in:
lib/universe_compiler/package/bootstrap.rb

Constant Summary collapse

DEFAULT_BOOTSTRAP_FILE =
'main.rb'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pathObject

Returns the value of attribute path.



8
9
10
# File 'lib/universe_compiler/package/bootstrap.rb', line 8

def path
  @path
end

Instance Method Details

#bootstrap_fileObject



20
21
22
23
24
25
26
27
# File 'lib/universe_compiler/package/bootstrap.rb', line 20

def bootstrap_file
  return nil unless path_valid?
  if File.file? path
    path
  else
    default_bootstrap_file
  end
end

#loadObject



29
30
31
32
33
34
35
# File 'lib/universe_compiler/package/bootstrap.rb', line 29

def load
  require bootstrap_file
rescue ScriptError => e
  msg = "Invalid package: '#{bootstrap_file}': #{e.message}"
  UniverseCompiler.logger.error msg
  raise UniverseCompiler::Error.from(e, msg)
end

#path_valid?(path = self.path) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/universe_compiler/package/bootstrap.rb', line 14

def path_valid?(path = self.path)
  return false unless path.is_a?(String) && File.readable?(path)
  return true if File.file? path
  File.exist? default_bootstrap_file(path)
end