Class: Tapioca::Runtime::Loader

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
GemHelper, Thor::Base
Defined in:
lib/tapioca/runtime/loader.rb

Instance Method Summary collapse

Methods included from GemHelper

#gem_in_app_dir?, #gem_in_bundle_path?, #to_realpath

Instance Method Details

#load_bundle(gemfile, initialize_file, require_file) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tapioca/runtime/loader.rb', line 14

def load_bundle(gemfile, initialize_file, require_file)
  require_helper(initialize_file)

  load_rails_application

  gemfile.require_bundle

  require_helper(require_file)

  load_rails_engines
end

#load_rails_application(environment_load: false, eager_load: false) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/tapioca/runtime/loader.rb', line 27

def load_rails_application(environment_load: false, eager_load: false)
  return unless File.exist?("config/application.rb")

  silence_deprecations

  if environment_load
    require "./config/environment"
  else
    require "./config/application"
  end

  eager_load_rails_app if eager_load
rescue LoadError, StandardError => e
  say("Tapioca attempted to load the Rails application after encountering a `config/application.rb` file, " \
    "but it failed. If your application uses Rails please ensure it can be loaded correctly before generating " \
    "RBIs.\n#{e}", :yellow)
  say("Continuing RBI generation without loading the Rails application.")
end