Class: SvgConform::Commands::SvgcheckCompare
- Inherits:
-
Object
- Object
- SvgConform::Commands::SvgcheckCompare
- Defined in:
- lib/svg_conform/commands/svgcheck_compare.rb
Overview
Compare command for comparing SvgConform validation with svgcheck reports
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(file, options) ⇒ SvgcheckCompare
constructor
A new instance of SvgcheckCompare.
Constructor Details
#initialize(file, options) ⇒ SvgcheckCompare
Returns a new instance of SvgcheckCompare.
9 10 11 12 13 |
# File 'lib/svg_conform/commands/svgcheck_compare.rb', line 9 def initialize(file, ) @file = file = # Paint doesn't need initialization like Pastel end |
Instance Method Details
#execute ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/svg_conform/commands/svgcheck_compare.rb', line 15 def execute # Determine the correct file to validate validation_file = determine_validation_file(@file) unless File.exist?(validation_file) puts Paint["Error: File '#{validation_file}' not found", :red] exit 1 end begin # Find or use specified svgcheck report svgcheck_report_path = find_svgcheck_report unless svgcheck_report_path && File.exist?(svgcheck_report_path) puts Paint["Error: svgcheck report not found", :red] if svgcheck_report_path puts Paint["Expected: #{svgcheck_report_path}", :dim] end exit 1 end # Load svgcheck report using the new external checker parser parser = SvgConform::ExternalCheckers::Svgcheck::Parser.new error_content = File.read(svgcheck_report_path) svgcheck_report = parser.parse(error_content, nil, filename: File.basename(@file)) # Generate SvgConform report using the correct validation file validator = SvgConform::Validator.new result = validator.validate_file(validation_file, profile: [:profile].to_sym) svg_conform_report = SvgConform::ConformanceReport.from_svg_conform_result( File.basename(@file), result, profile: [:profile].to_sym, ) # Compare the reports comparator = SvgConform::ReportComparator.new comparator.compare_reports(svg_conform_report, svgcheck_report, File.basename(@file)) rescue StandardError => e puts Paint["Error: #{e.message}", :red] exit 1 end end |