Class: Praxis::BootloaderStages::WarnUnloadedFiles

Inherits:
Stage
  • Object
show all
Defined in:
lib/praxis/bootloader_stages/warn_unloaded_files.rb

Class Attribute Summary collapse

Attributes inherited from Stage

#after_callbacks, #before_callbacks, #context, #name, #stages

Instance Method Summary collapse

Methods inherited from Stage

#after, #application, #before, #callback_args, #execute_callbacks, #initialize, #run, #setup!, #setup_deferred_callbacks!

Constructor Details

This class inherits a constructor from Praxis::Stage

Class Attribute Details

.enabledObject

Returns the value of attribute enabled.



13
14
15
# File 'lib/praxis/bootloader_stages/warn_unloaded_files.rb', line 13

def enabled
  @enabled
end

Instance Method Details

#executeObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/praxis/bootloader_stages/warn_unloaded_files.rb', line 16

def execute
  return unless self.class.enabled

  return if application.file_layout[:app] == []

  base = application.file_layout[:app].base
  return unless base.exist?

  file_enum = base.find.to_a
  files = file_enum.select do |file|
    path = file.relative_path_from(base)
    path.extname == '.rb'
  end

  missing = Set.new(files) - application.loaded_files
  return unless missing.any?

  msg = "The following application files under #{base} were not loaded:\n"
  missing.each do |file|
    path = file.relative_path_from(base)
    msg << " * #{path}\n"
  end
  warn msg
end