Class: Asgard::Doctor
- Inherits:
-
Object
- Object
- Asgard::Doctor
- Includes:
- Report, TaskSections
- Defined in:
- lib/asgard/doctor.rb,
lib/asgard/doctor/report.rb,
lib/asgard/doctor/task_sections.rb
Overview
Diagnoses .loki resolution, import chains, and task definitions for a
directory — invoked via asgard --doctor. Deliberately bypasses the
normal Tasks boot sequence (see Asgard.run!) so it can still report
findings when that sequence would otherwise abort the whole process
(a broken file, a circular dependency, a silently overridden task).
Defined Under Namespace
Modules: ImportTracer, Report, TaskSections Classes: Finding
Class Method Summary collapse
-
.ancestor_markers(dir) ⇒ Object
Every ".loki" marker from
dirup to the filesystem root, nearest first — mirrors loki_up's walk, but collects every match instead of stopping at the first (so shadowed ancestor markers can be reported). -
.duplicate_methods(method_log) ⇒ Object
method_name => [[file, line], ...] entries defined more than once — same file or different, a later
defalways silently overrides an earlier one with the same name.
Instance Method Summary collapse
-
#initialize(dir = Dir.pwd) ⇒ Doctor
constructor
A new instance of Doctor.
- #run ⇒ Object
Constructor Details
#initialize(dir = Dir.pwd) ⇒ Doctor
Returns a new instance of Doctor.
20 21 22 23 24 25 |
# File 'lib/asgard/doctor.rb', line 20 def initialize(dir = Dir.pwd) @dir = File.(dir) @findings = [] @imports = [] @loaded_files = [] end |
Class Method Details
.ancestor_markers(dir) ⇒ Object
Every ".loki" marker from dir up to the filesystem root, nearest
first — mirrors loki_up's walk, but collects every match instead of
stopping at the first (so shadowed ancestor markers can be reported).
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/asgard/doctor.rb', line 39 def self.ancestor_markers(dir) markers = [] current = Pathname.new(dir) loop do candidate = current + ".loki" markers << candidate.to_s if candidate.exist? parent = current.parent break if parent == current current = parent end markers end |
.duplicate_methods(method_log) ⇒ Object
method_name => [[file, line], ...] entries defined more than once —
same file or different, a later def always silently overrides an
earlier one with the same name.
56 57 58 59 60 |
# File 'lib/asgard/doctor.rb', line 56 def self.duplicate_methods(method_log) method_log.each_with_object({}) do |(name, locations), acc| acc[name] = locations if locations.size > 1 end end |
Instance Method Details
#run ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/asgard/doctor.rb', line 27 def run report_markers load_chain report_imports build_task_sections report_dependencies print_report end |