Class: Compass::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/compass/validator.rb

Overview

Validates generated CSS against the W3 using Java

Constant Summary collapse

VALIDATOR_FILE =
File.join(File.dirname(__FILE__), 'validate', 'css-validator.jar')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeValidator

Returns a new instance of Validator.



10
11
12
# File 'lib/compass/validator.rb', line 10

def initialize
  @error_count = 0
end

Instance Attribute Details

#error_countObject (readonly)

Returns the value of attribute error_count.



8
9
10
# File 'lib/compass/validator.rb', line 8

def error_count
  @error_count
end

Instance Method Details

#validateObject

Validates all three CSS files



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/compass/validator.rb', line 15

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

  Dir.new(Compass::Constants::BLUEPRINT_ROOT_PATH).each do |file_name|
    puts "#{file_name}"
    if file_name =~ /\.css$/
      css_file = File.join(Compass::Constants::BLUEPRINT_ROOT_PATH, file_name)
      @error_count += 1 if !validate_css_file(java_path, css_file)
    end
  end

  output_footer
end