lib/headhunter/css_validator.rb in headhunter-0.1.3 vs lib/headhunter/css_validator.rb in headhunter-0.1.4
- old
+ new
@@ -22,16 +22,20 @@
end
class CssValidator
USE_LOCAL_VALIDATOR = true
- def initialize(stylesheets)
+ def initialize(stylesheets = [])
@profile = 'css3' # TODO: Option for profile css1 and css21
@stylesheets = stylesheets
@messages_per_stylesheet = {}
end
+ def add_stylesheet(stylesheet)
+ @stylesheets << stylesheet
+ end
+
def process!
@stylesheets.each do |stylesheet|
css = fetch(stylesheet)
css = ' ' if css.empty? # The validator returns a 500 error if it receives an empty string
@@ -41,20 +45,20 @@
end
end
end
def report
- log.puts "Validated #{@stylesheets.size} stylesheets.".yellow
- log.puts "#{x_stylesheets_be(@stylesheets.size - @messages_per_stylesheet.size)} valid.".green if @messages_per_stylesheet.size < @stylesheets.size
- log.puts "#{x_stylesheets_be(@messages_per_stylesheet.size)} invalid.".red if @messages_per_stylesheet.size > 0
+ puts "Validated #{@stylesheets.size} stylesheets.".yellow
+ puts "#{x_stylesheets_be(@stylesheets.size - @messages_per_stylesheet.size)} valid.".green if @messages_per_stylesheet.size < @stylesheets.size
+ puts "#{x_stylesheets_be(@messages_per_stylesheet.size)} invalid.".red if @messages_per_stylesheet.size > 0
@messages_per_stylesheet.each_pair do |stylesheet, messages|
- log.puts " #{extract_filename(stylesheet)}:".red
+ puts " #{extract_filename(stylesheet)}:".red
- messages.each { |message| log.puts " - #{message}".red }
+ messages.each { |message| puts " - #{message}".red }
end
- log.puts
+ puts
end
private
# Converts a path like public/assets/application-d205d6f344d8623ca0323cb6f6bd7ca1.css to application.css