Class: Blueprint::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/template/css/blueprint/lib/blueprint/validator.rb

Overview

Validates generated CSS against the W3 using Java

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeValidator

Returns a new instance of Validator.



6
7
8
# File 'lib/template/css/blueprint/lib/blueprint/validator.rb', line 6

def initialize
  @error_count = 0
end

Instance Attribute Details

#error_countObject (readonly)

Returns the value of attribute error_count.



4
5
6
# File 'lib/template/css/blueprint/lib/blueprint/validator.rb', line 4

def error_count
  @error_count
end

Instance Method Details

#validateObject

Validates all three CSS files



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/template/css/blueprint/lib/blueprint/validator.rb', line 11

def validate
  java_path = `which java`.rstrip
  raise "You do not have a Java installed, but it is required." if java_path.blank?

  output_header

  Blueprint::CSS_FILES.keys.each do |file_name|
    css_output_path = File.join(Blueprint::BLUEPRINT_ROOT_PATH, file_name)
    puts "\n\n  Testing #{css_output_path}"
    puts "  Output ============================================================\n\n"
    @error_count += 1 if !system("#{java_path} -jar '#{Blueprint::VALIDATOR_FILE}' -e '#{css_output_path}'")
  end

  output_footer
end