Class: SvgConform::Compatibility::FileProcessor
- Inherits:
-
Object
- Object
- SvgConform::Compatibility::FileProcessor
- Defined in:
- lib/svg_conform/compatibility/file_processor.rb
Overview
Handles file system operations and validation for compatibility analysis
Instance Method Summary collapse
- #discover_files ⇒ Object
- #file_exists?(filename) ⇒ Boolean
-
#initialize(context) ⇒ FileProcessor
constructor
A new instance of FileProcessor.
- #input_file_path(filename) ⇒ Object
- #parse_svgcheck_outputs(filename) ⇒ Object
- #read_file_content(filename) ⇒ Object
- #read_svgcheck_repaired_content(filename) ⇒ Object
- #svg_file?(filename) ⇒ Boolean
- #svgcheck_repaired_file_exists?(filename) ⇒ Boolean
- #svgcheck_repaired_file_path(filename) ⇒ Object
- #validate_environment ⇒ Object
- #xml_file?(filename) ⇒ Boolean
Constructor Details
#initialize(context) ⇒ FileProcessor
Returns a new instance of FileProcessor.
9 10 11 |
# File 'lib/svg_conform/compatibility/file_processor.rb', line 9 def initialize(context) @context = context end |
Instance Method Details
#discover_files ⇒ Object
21 22 23 24 25 |
# File 'lib/svg_conform/compatibility/file_processor.rb', line 21 def discover_files return [@context.file] if @context.single_file_analysis? discover_batch_files end |
#file_exists?(filename) ⇒ Boolean
41 42 43 |
# File 'lib/svg_conform/compatibility/file_processor.rb', line 41 def file_exists?(filename) File.exist?(File.join(@context.inputs_dir, filename)) end |
#input_file_path(filename) ⇒ Object
45 46 47 |
# File 'lib/svg_conform/compatibility/file_processor.rb', line 45 def input_file_path(filename) File.join(@context.inputs_dir, filename) end |
#parse_svgcheck_outputs(filename) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/svg_conform/compatibility/file_processor.rb', line 27 def parse_svgcheck_outputs(filename) # Use the new external checker report generator report_generator = SvgConform::ExternalCheckers::Svgcheck::ReportGenerator.new output_file = File.join(@context.outputs_dir, "#{filename}.out") error_file = File.join(@context.outputs_dir, "#{filename}.err") code_file = File.join(@context.outputs_dir, "#{filename}.code") report_generator.generate_from_files(filename, output_file: output_file, error_file: error_file, code_file: code_file) end |
#read_file_content(filename) ⇒ Object
57 58 59 |
# File 'lib/svg_conform/compatibility/file_processor.rb', line 57 def read_file_content(filename) File.read(input_file_path(filename)) end |
#read_svgcheck_repaired_content(filename) ⇒ Object
69 70 71 |
# File 'lib/svg_conform/compatibility/file_processor.rb', line 69 def read_svgcheck_repaired_content(filename) File.read(svgcheck_repaired_file_path(filename)) end |
#svg_file?(filename) ⇒ Boolean
53 54 55 |
# File 'lib/svg_conform/compatibility/file_processor.rb', line 53 def svg_file?(filename) filename.end_with?(".svg") end |
#svgcheck_repaired_file_exists?(filename) ⇒ Boolean
65 66 67 |
# File 'lib/svg_conform/compatibility/file_processor.rb', line 65 def svgcheck_repaired_file_exists?(filename) File.exist?(svgcheck_repaired_file_path(filename)) end |
#svgcheck_repaired_file_path(filename) ⇒ Object
61 62 63 |
# File 'lib/svg_conform/compatibility/file_processor.rb', line 61 def svgcheck_repaired_file_path(filename) File.join(@context.outputs_dir, "#{filename}.file") end |
#validate_environment ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/svg_conform/compatibility/file_processor.rb', line 13 def validate_environment if @context.single_file_analysis? validate_single_file else validate_batch_environment end end |
#xml_file?(filename) ⇒ Boolean
49 50 51 |
# File 'lib/svg_conform/compatibility/file_processor.rb', line 49 def xml_file?(filename) filename.end_with?(".xml") end |