Class: Fontist::ValidateCLI
Instance Method Summary
collapse
#handle_class_options, included, #log_level
Instance Method Details
#cache ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/fontist/validate_cli.rb', line 60
def cache
handle_class_options(options)
cache_path = validation_cache_path
if !options[:force] && File.exist?(cache_path)
existing_cache = Validator.load_cache(cache_path)
if existing_cache && !existing_cache.stale?
age_hours = (Time.now.to_i - existing_cache.generated_at) / 3600.0
Fontist.ui.say("Validation cache exists and is fresh (#{age_hours.round(1)} hours old)")
Fontist.ui.say("Use --force to rebuild")
return CLI::STATUS_SUCCESS
end
end
start_time = Time.now
puts Paint["Building validation cache...", :cyan, :bright]
puts Paint["-" * 80, :cyan]
validator = Validator.new
validator.build_cache(cache_path, verbose: options[:verbose])
total_time = Time.now - start_time
puts
puts Paint["-" * 80, :cyan]
puts Paint["Cache file: ", :white] + Paint[cache_path, :cyan]
puts Paint["Total time: ",
:white] + Paint["#{total_time.round(2)}s", :green, :bright]
CLI::STATUS_SUCCESS
rescue Fontist::Errors::GeneralError => e
Fontist.ui.error(e.message)
CLI::STATUS_UNKNOWN_ERROR
end
|
#clear ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/fontist/validate_cli.rb', line 100
def clear
handle_class_options(options)
cache_path = validation_cache_path
if File.exist?(cache_path)
File.delete(cache_path)
Fontist.ui.success("Validation cache cleared: #{cache_path}")
else
Fontist.ui.say("Validation cache does not exist")
end
CLI::STATUS_SUCCESS
rescue Fontist::Errors::GeneralError => e
Fontist.ui.error(e.message)
CLI::STATUS_UNKNOWN_ERROR
end
|
#report ⇒ Object
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
|
# File 'lib/fontist/validate_cli.rb', line 19
def report
handle_class_options(options)
start_time = Time.now
puts Paint["Generating font validation report...", :cyan, :bright]
puts Paint["-" * 80, :cyan]
validator = Validator.new
validator.validate_all(parallel: options[:parallel],
verbose: options[:verbose])
report = validator.report
total_time = Time.now - start_time
case options[:format].downcase
when "json"
output_json_report(report, options[:output])
when "yaml"
output_yaml_report(report, options[:output])
when "text"
output_text_report(report, options[:output], total_time)
else
Fontist.ui.error("Unknown format: #{options[:format]}. Use 'text', 'yaml', or 'json'.")
return CLI::STATUS_UNKNOWN_ERROR
end
CLI::STATUS_SUCCESS
rescue Fontist::Errors::GeneralError => e
Fontist.ui.error(e.message)
CLI::STATUS_UNKNOWN_ERROR
end
|