Class: Suma::SvgQuality::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/suma/svg_quality/scanner.rb

Overview

Deep module behind the SVG-quality seam: takes paths in, returns Report / BatchReport out. Owns validator construction and per-file result capture. Does not own file discovery, sorting, filtering, or presentation — those stay in the CLI adapter.

The progress adapter is injected: pass any object responding to #call(index, total, report). NullProgress is the default no-op; the CLI passes a lambda that writes to $stderr.

Defined Under Namespace

Classes: NullProgress

Constant Summary collapse

DEFAULT_PROFILE =
:metanorma

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile: DEFAULT_PROFILE, progress: NullProgress.new) ⇒ Scanner

Returns a new instance of Scanner.



20
21
22
23
24
# File 'lib/suma/svg_quality/scanner.rb', line 20

def initialize(profile: DEFAULT_PROFILE,
               progress: NullProgress.new)
  @profile = profile
  @progress = progress
end

Instance Attribute Details

#profileObject (readonly)

Returns the value of attribute profile.



18
19
20
# File 'lib/suma/svg_quality/scanner.rb', line 18

def profile
  @profile
end

#progressObject (readonly)

Returns the value of attribute progress.



18
19
20
# File 'lib/suma/svg_quality/scanner.rb', line 18

def progress
  @progress
end

Instance Method Details

#scan(paths) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/suma/svg_quality/scanner.rb', line 26

def scan(paths)
  validator = build_validator
  reports = paths.each_with_index.map do |path, index|
    scan_one(validator, path, index, paths.size)
  end
  BatchReport.new(reports)
end

#scan_file(path) ⇒ Object



34
35
36
37
# File 'lib/suma/svg_quality/scanner.rb', line 34

def scan_file(path)
  Report.new(path.to_s, build_validator.validate_file(path.to_s,
                                                      profile: profile))
end