Class: Discharger::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/discharger/setup.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path, app_root: nil) ⇒ Setup

Returns a new instance of Setup.



23
24
25
26
# File 'lib/discharger/setup.rb', line 23

def initialize(config_path, app_root: nil)
  @config_path = config_path
  @app_root = app_root || Dir.pwd
end

Instance Attribute Details

#app_rootObject (readonly)

Returns the value of attribute app_root.



21
22
23
# File 'lib/discharger/setup.rb', line 21

def app_root
  @app_root
end

#config_pathObject (readonly)

Returns the value of attribute config_path.



21
22
23
# File 'lib/discharger/setup.rb', line 21

def config_path
  @config_path
end

Class Method Details

.run(config_path = "config/setup.yml", app_root: nil) ⇒ Object



28
29
30
# File 'lib/discharger/setup.rb', line 28

def self.run(config_path = "config/setup.yml", app_root: nil)
  new(config_path, app_root: app_root).run
end

Instance Method Details

#runObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/discharger/setup.rb', line 32

def run
  FileUtils.chdir(app_root) do
    validate_environment
    print_header

    # Phase 1: Load bundler first (activates correct gem versions)
    # This must happen before we parse YAML to avoid psych version conflicts
    load_bundler

    # Phase 2: Pre-Rails setup (env vars, system dependencies)
    # These run AFTER bundler but BEFORE Rails loads
    run_prerequisites

    # Phase 3: Load Rails (uses env vars from phase 2)
    load_rails

    # Phase 4: Run Discharger commands (after Rails loads)
    run_setup_commands

    print_footer
  end
end