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

: (tapioca_path: String, ?eager_load: bool, ?app_root: String, ?halt_upon_load_error: bool) -> void



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tapioca/loaders/dsl.rb', line 13

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

: -> void



30
31
32
33
34
# File 'lib/tapioca/loaders/dsl.rb', line 30

def load
  load_dsl_extensions
  load_application
  load_dsl_compilers
end

#load_dsl_extensions_and_compilersObject

: -> void



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

def load_dsl_extensions_and_compilers
  load_dsl_extensions
  load_dsl_compilers
end

#reload_custom_compilersObject

: -> void



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/tapioca/loaders/dsl.rb', line 43

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