Class: Jets::Booter

Inherits:
Object
  • Object
show all
Defined in:
lib/jets/booter.rb

Class Method Summary collapse

Class Method Details

.app_initializersObject

All Turbines



36
37
38
39
40
# File 'lib/jets/booter.rb', line 36

def app_initializers
  Dir.glob("#{Jets.root}/config/initializers/**/*").sort.each do |path|
    load path
  end
end

.boot!Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jets/booter.rb', line 6

def boot!
  return if @booted
  confirm_jets_project!

  # Registration phase
  Jets::Bundle.require    # engine config and register initializers
  load_internal_engine    # internal engine initializers
  require_application!    # override with user customizations

  # Run phase
  Jets.application.initialize!
  @booted = true
end

.check_config_ru!Object



67
68
69
70
71
72
73
74
75
76
# File 'lib/jets/booter.rb', line 67

def check_config_ru!
  config_ru = File.read("#{Jets.root}/config.ru")
  unless config_ru.include?("Jets.boot")
    puts 'The config.ru file is missing Jets.boot.  Please add Jets.boot after require "jets"'.color(:red)
    puts "This was changed as made in Jets v1.1.0."
    puts "To have Jets update the config.fu file for you, you can run:\n\n"
    puts "    jets-upgrade"
    exit 1
  end
end

.check_old_jets_code!Object



53
54
55
56
57
58
59
60
61
# File 'lib/jets/booter.rb', line 53

def check_old_jets_code!
  application_rb = "#{Jets.root}/config/application.rb"
  return unless File.exist?(application_rb)
  return if File.read(application_rb).include?(' < Jets::Application')
  puts "ERROR: Based on config/application.rb, it looks like your app code was written with an older version of Jets.".color(:red)
  puts "Please install and run the jets-upgrade command to upgrade your project."
  puts "  jets-upgrade go".color(:green)
  exit 1
end

.confirm_jets_project!Object

Cannot call this for the jets new We check that within a jets project again as Jets.boot Also checked in the jets/cli.rb more generally



45
46
47
48
49
50
51
# File 'lib/jets/booter.rb', line 45

def confirm_jets_project!
  return if defined?(ENGINE_PATH)
  unless File.exist?("#{Jets.root}/config/application.rb")
    puts "It does not look like you are running this command within a jets project.  Please confirm that you are in a jets project and try again.".color(:red)
    exit 1
  end
end

.load_internal_engineObject



31
32
33
# File 'lib/jets/booter.rb', line 31

def load_internal_engine
  require File.expand_path("../../engines/internal/lib/internal/engine.rb", __dir__)
end

.messageObject



63
64
65
# File 'lib/jets/booter.rb', line 63

def message
  "Jets booting up in #{Jets.env.color(:green)} mode!"
end

.require_application!Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/jets/booter.rb', line 20

def require_application!
  require ENGINE_PATH if defined?(ENGINE_PATH)

  if defined?(APP_PATH)
    check_old_jets_code!
    require APP_PATH
  else
    require "#{Jets.root}/config/application"
  end
end