Class: Suma::Cli::CheckSvgQuality
- Inherits:
-
Object
- Object
- Suma::Cli::CheckSvgQuality
- Defined in:
- lib/suma/cli/check_svg_quality.rb
Overview
Check SVG quality. Thin adapter around Suma::SvgQuality::Scanner:
argument parsing, file discovery, sorting, filtering, output
formatting. The deep scanner module owns validation orchestration
and is reachable from specs without invoking Thor.
Constant Summary collapse
- DATA_PATH =
"schemas"- DEFAULT_PATTERN =
"**/*.svg"- DEFAULT_PROFILE =
:metanorma
Instance Method Summary collapse
-
#initialize(pattern: DEFAULT_PATTERN, profile: DEFAULT_PROFILE, format: "terminal", output: nil, min_errors: nil, summary_only: false, progress: false, limit: nil, sort: "errors") ⇒ CheckSvgQuality
constructor
A new instance of CheckSvgQuality.
- #run(path = DATA_PATH) ⇒ Object
Constructor Details
#initialize(pattern: DEFAULT_PATTERN, profile: DEFAULT_PROFILE, format: "terminal", output: nil, min_errors: nil, summary_only: false, progress: false, limit: nil, sort: "errors") ⇒ CheckSvgQuality
Returns a new instance of CheckSvgQuality.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/suma/cli/check_svg_quality.rb', line 16 def initialize(pattern: DEFAULT_PATTERN, profile: DEFAULT_PROFILE, format: "terminal", output: nil, min_errors: nil, summary_only: false, progress: false, limit: nil, sort: "errors") @options = { pattern: pattern, profile: profile, format: format, output: output, min_errors: min_errors, summary_only: summary_only, progress: progress, limit: limit, sort: sort.to_sym, } end |
Instance Method Details
#run(path = DATA_PATH) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/suma/cli/check_svg_quality.rb', line 33 def run(path = DATA_PATH) require "svg_conform" path_obj = Pathname.new(path). show_progress = [:progress] || ($stdout.tty? && ![:output]) sync_stdio! if show_progress files = discover_files(path_obj) return if files.empty? if single_file?(path_obj, files) print_single_report(scan_single(files.first)) else scan_and_output(files, show_progress) end end |