Class: Plasma::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/plasma/loader.rb

Overview

Handles loading PLASMA projects

Class Method Summary collapse

Class Method Details

.handle_load_error(error) ⇒ Object



26
27
28
29
30
# File 'lib/plasma/loader.rb', line 26

def self.handle_load_error(error)
  message = error.is_a?(LoadError) ? "Error loading application" : "Error initializing application"
  puts "#{message}: #{error.message}"
  raise error
end

.load_projectObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/plasma/loader.rb', line 6

def self.load_project
  # Load the application boot file
  require_relative File.join(Dir.pwd, "config/boot")

  # Determine the application class name
  app_name = File.basename(Dir.pwd).gsub("-", "_").camelize

  # Load the application
  require_relative File.join(Dir.pwd, "config/application")

  # Get the application module and include it in the top-level scope
  app_module = Object.const_get(app_name)
  Object.include(app_module)

  # Return the application class
  Object.const_get("#{app_name}::Application")
rescue LoadError, NameError => e
  handle_load_error(e)
end