Class: Tapioca::Loaders::Dsl

Inherits:
Loader
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/tapioca/loaders/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GemHelper

#gem_in_app_dir?, #gem_in_bundle_path?, #gem_in_ruby_path?, #to_realpath

Methods included from CliHelper

#netrc_file, #rbi_formatter, #say_error

Class Method Details

.load_application(tapioca_path:, eager_load: true, app_root: ".", halt_upon_load_error: true) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/tapioca/loaders/dsl.rb', line 20

def load_application(
  tapioca_path:,
  eager_load: true,
  app_root: ".",
  halt_upon_load_error: true
)
  new(
    tapioca_path: tapioca_path,
    eager_load: eager_load,
    app_root: app_root,
    halt_upon_load_error: halt_upon_load_error,
  ).load
end

Instance Method Details

#loadObject



36
37
38
39
40
# File 'lib/tapioca/loaders/dsl.rb', line 36

def load
  load_dsl_extensions
  load_application
  load_dsl_compilers
end

#load_dsl_extensions_and_compilersObject



43
44
45
46
# File 'lib/tapioca/loaders/dsl.rb', line 43

def load_dsl_extensions_and_compilers
  load_dsl_extensions
  load_dsl_compilers
end

#reload_custom_compilersObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/tapioca/loaders/dsl.rb', line 49

def reload_custom_compilers
  # Remove all loaded custom compilers
  ::Tapioca::Dsl::Compiler.descendants.each do |compiler|
    name = compiler.name
    next unless name && @custom_compiler_paths.include?(Module.const_source_location(name)&.first)

    *parts, unqualified_name = name.split("::")

    if parts.empty?
      Object.send(:remove_const, unqualified_name)
    else
      parts.join("::").safe_constantize.send(:remove_const, unqualified_name)
    end
  end

  # Remove from $LOADED_FEATURES each workspace compiler file and then re-load
  @custom_compiler_paths.each { |path| $LOADED_FEATURES.delete(path) }
  load_custom_dsl_compilers
end