Class: SvgConform::ExternalCheckers::Svgcheck::OutputGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/svg_conform/external_checkers/svgcheck/output_generator.rb

Overview

Generates svgcheck outputs for comparison testing

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(svgcheck_exec: "python3", svgcheck_path: "svgcheck/svgcheck") ⇒ OutputGenerator

Returns a new instance of OutputGenerator.



13
14
15
16
17
# File 'lib/svg_conform/external_checkers/svgcheck/output_generator.rb', line 13

def initialize(svgcheck_exec: "python3",
svgcheck_path: "svgcheck/svgcheck")
  @svgcheck_exec = svgcheck_exec
  @svgcheck_path = svgcheck_path
end

Instance Attribute Details

#svgcheck_execObject (readonly)

Returns the value of attribute svgcheck_exec.



11
12
13
# File 'lib/svg_conform/external_checkers/svgcheck/output_generator.rb', line 11

def svgcheck_exec
  @svgcheck_exec
end

#svgcheck_pathObject (readonly)

Returns the value of attribute svgcheck_path.



11
12
13
# File 'lib/svg_conform/external_checkers/svgcheck/output_generator.rb', line 11

def svgcheck_path
  @svgcheck_path
end

Instance Method Details

#generate(input_file, mode: :both) ⇒ Object

Generate svgcheck outputs for a given input file



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/svg_conform/external_checkers/svgcheck/output_generator.rb', line 20

def generate(input_file, mode: :both)
  results = {}

  case mode
  when :check
    results[:check] = generate_mode_output(input_file, :check)
  when :repair
    results[:repair] = generate_mode_output(input_file, :repair)
  when :both
    results[:check] = generate_mode_output(input_file, :check)
    results[:repair] = generate_mode_output(input_file, :repair)
  else
    raise ArgumentError,
          "Invalid mode: #{mode}. Must be :check, :repair, or :both"
  end

  results
end