Line | |
---|
1 | module Blueprint |
---|
2 | # Validates generated CSS against the W3 using Java |
---|
3 | class Validator |
---|
4 | attr_reader :error_count |
---|
5 | |
---|
6 | def initialize |
---|
7 | @error_count = 0 |
---|
8 | end |
---|
9 | |
---|
10 | # Validates all three CSS files |
---|
11 | def validate |
---|
12 | java_path = `which java`.rstrip |
---|
13 | raise "You do not have a Java installed, but it is required." if java_path.blank? |
---|
14 | |
---|
15 | output_header |
---|
16 | |
---|
17 | Blueprint::CSS_FILES.keys.each do |file_name| |
---|
18 | css_output_path = File.join(Blueprint::BLUEPRINT_ROOT_PATH, file_name) |
---|
19 | puts "\n\n Testing #{css_output_path}" |
---|
20 | puts " Output ============================================================\n\n" |
---|
21 | @error_count += 1 if !system("#{java_path} -jar '#{Blueprint::VALIDATOR_FILE}' -e '#{css_output_path}'") |
---|
22 | end |
---|
23 | |
---|
24 | output_footer |
---|
25 | end |
---|
26 | |
---|
27 | private |
---|
28 | |
---|
29 | def output_header |
---|
30 | puts "\n\n" |
---|
31 | puts " ************************************************************" |
---|
32 | puts " **" |
---|
33 | puts " ** Blueprint CSS Validator" |
---|
34 | puts " ** Validates output CSS files" |
---|
35 | puts " **" |
---|
36 | puts " ************************************************************" |
---|
37 | end |
---|
38 | |
---|
39 | def output_footer |
---|
40 | puts "\n\n" |
---|
41 | puts " ************************************************************" |
---|
42 | puts " **" |
---|
43 | puts " ** Done!" |
---|
44 | puts " ** Your CSS files are#{" not" if error_count > 0} valid.#{" You had #{error_count} error(s) within your files" if error_count > 0}" |
---|
45 | puts " **" |
---|
46 | puts " ************************************************************" |
---|
47 | end |
---|
48 | end |
---|
49 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.