Class: SvgConform::Commands::QualityCLI
- Inherits:
-
Thor
- Object
- Thor
- SvgConform::Commands::QualityCLI
- Defined in:
- lib/svg_conform/commands/quality.rb
Overview
Thor-based subcommands for quality analysis
Instance Method Summary collapse
Instance Method Details
#analyze(file_path) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/svg_conform/commands/quality.rb', line 92 def analyze(file_path) ensure_file_exists(file_path) config = load_config([:config]) analyzer = ImageQualityAnalyzer.new(config: config) report = analyzer.analyze(file_path, profile: [:profile].to_sym) output = case [:format] when "yaml" then report.to_yaml when "json" then report.to_json else report.render end puts output end |
#batch(directory) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/svg_conform/commands/quality.rb', line 121 def batch(directory) ensure_dir_exists(directory) config = load_config([:config]) analyzer = ImageQualityAnalyzer.new(config: config) puts "Analyzing SVG files in #{directory}..." if [:progress] batch_report = analyzer.analyze_batch( directory, pattern: [:pattern], profile: [:profile].to_sym, progress: [:progress], ) output = case [:format] when "yaml" then batch_report.to_yaml when "csv" then generate_csv_from_batch(batch_report) when "json" then batch_report.to_json else if [:summary_only] batch_report.render else lines = [] batch_report.reports.each do |report| lines << report.render lines << "" end lines << batch_report.render lines.join("\n") end end if [:output] File.write([:output], output) puts "\nReport written to #{[:output]}" else puts output end end |
#summary(path) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/svg_conform/commands/quality.rb', line 167 def summary(path) config = load_config([:config]) analyzer = ImageQualityAnalyzer.new(config: config) if File.directory?(path) batch_report = analyzer.analyze_batch( path, pattern: "**/*.svg", profile: [:profile].to_sym, progress: false, ) output = case [:format] when "yaml" then batch_report.to_yaml else batch_report.render end else report = analyzer.analyze(path, profile: [:profile].to_sym) output = case [:format] when "yaml" then report.to_yaml else report.render end end puts output end |