Sha256: f2f0d6acf6e2d8f180965f5093930df001969482ada50e2a188514b5c61801b0

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

module Blueprint
  # Validates generated CSS against the W3 using Java
  class Validator
    attr_reader :error_count
    
    def initialize
      @error_count = 0
    end

    # Validates all three CSS files
    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
    
    private
    
    def output_header
      puts "\n\n"
      puts "  ************************************************************"
      puts "  **"
      puts "  **   Blueprint CSS Validator"
      puts "  **   Validates output CSS files"
      puts "  **"
      puts "  ************************************************************"
    end

    def output_footer
      puts "\n\n"
      puts "  ************************************************************"
      puts "  **"
      puts "  **   Done!"
      puts "  **   Your CSS files are#{" not" if error_count > 0} valid.#{"  You had #{error_count} error(s) within your files" if error_count > 0}"
      puts "  **"
      puts "  ************************************************************"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blueprintr-0.1.0 lib/blueprint-css/lib/blueprint/validator.rb