Class: Everywhere::Framework::Rails

Inherits:
Framework
  • Object
show all
Defined in:
lib/everywhere/framework.rb

Overview

---- build/dev (CLI side) ------------------------------------------------

Instance Method Summary collapse

Instance Method Details

#boot!(port:) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/everywhere/framework.rb', line 137

def boot!(port:)
  # Normally defined by bin/rails; the server command requires it.
  ::Object.const_set(:APP_PATH, File.join(root, "config/application")) unless defined?(::APP_PATH)
  # native_boot.rb requires this gem BEFORE Rails exists, so the engine
  # guard in everywhere.rb saw no ::Rails::Engine — and Bundler.require
  # won't re-require an already-loaded gem when the app boots below.
  # Without this, packaged apps silently lose the engine (bridge asset
  # path + "@rubyeverywhere/bridge" importmap pin).
  unless defined?(Everywhere::Engine)
    require "rails" # rails/engine alone lacks the AS core_ext it uses
    require "rails/engine"
    require_relative "engine"
  end
  require File.join(root, "config/environment")
  Everywhere::Database.prepare!(root)

  require "rails/command"
  ::Rails::Command.invoke :server, ["--binding=127.0.0.1", "--port=#{port}"]
end

#boot_stubObject

Rails loads its bundle through config/boot.rb (with bootsnap guarded).



161
162
163
# File 'lib/everywhere/framework.rb', line 161

def boot_stub
  render_boot_stub(env_exports, "require_relative \"config/boot\"")
end

#cleanup_commandObject



129
# File 'lib/everywhere/framework.rb', line 129

def cleanup_command = "bin/rails assets:clobber"

#dev_commandObject

CLI



119
120
121
# File 'lib/everywhere/framework.rb', line 119

def dev_command
  File.exist?(File.join(root, "bin", "dev")) ? "bin/dev" : "bundle exec rails server"
end

#env_exportsObject

Install



158
# File 'lib/everywhere/framework.rb', line 158

def env_exports = { "RAILS_ENV" => "production" }

#nameObject



116
# File 'lib/everywhere/framework.rb', line 116

def name = "rails"

#precompile_commandObject



127
# File 'lib/everywhere/framework.rb', line 127

def precompile_command = "bin/rails assets:precompile"

#precompile_envObject



123
124
125
# File 'lib/everywhere/framework.rb', line 123

def precompile_env
  { "RAILS_ENV" => "production", "SECRET_KEY_BASE" => "precompile-only" }
end

#prepare_runtime_envObject

Runtime



132
133
134
135
# File 'lib/everywhere/framework.rb', line 132

def prepare_runtime_env
  ENV["RAILS_ENV"] ||= "production"
  ENV["SOLID_QUEUE_IN_PUMA"] ||= "1"
end