Subcommand for CSS validation.

This commit is contained in:
Chris Eppstein 2009-10-26 09:25:52 -07:00
parent 149978b4c9
commit dd750391be
3 changed files with 60 additions and 6 deletions

View File

@ -204,7 +204,7 @@ Feature: Command Line
Given I am using the existing project in test/fixtures/stylesheets/compass
When I run: compass validate
Then my css is validated
And I am informed that it is not, because IE6 hacks suck.
And I am informed that my css is valid.
Scenario: Get stats for my project
Given I am using the existing project in test/fixtures/stylesheets/compass

View File

@ -170,11 +170,11 @@ Then /^the following configuration properties are set in config\/compass\.rb:$/
end
Then /^my css is validated$/ do
pending
@last_result.should =~ /Compass CSS Validator/
end
Then /^I am informed that it is not, because IE6 hacks suck\.$/ do
pending
Then /^I am informed that my css is valid.$/ do
@last_result.should =~ /Your CSS files are valid\./
end
Then /^I am told statistics for each file:$/ do |table|

View File

@ -3,8 +3,26 @@ require 'compass/commands/update_project'
module Compass
module Commands
module ValidationOptionsParser
def set_options(opts)
opts.banner = %Q{
Usage: compass validate [path/to/project] [options]
Description:
Compile project at the path specified or the current
directory if not specified and then validate the
generated CSS.
Options:
}.strip.split("\n").map{|l| l.gsub(/^ {0,10}/,'')}.join("\n")
super
end
end
class ValidateProject < ProjectBase
register :validate
def initialize(working_path, options)
super
assert_project_directory_exists!
@ -16,6 +34,42 @@ module Compass
Validator.new(project_css_subdirectory).validate()
end
class << self
def option_parser(arguments)
parser = Compass::Exec::CommandOptionParser.new(arguments)
parser.extend(Compass::Exec::GlobalOptionsParser)
parser.extend(Compass::Exec::ProjectOptionsParser)
parser.extend(ValidationOptionsParser)
end
def usage
option_parser([]).to_s
end
def description(command)
"Validate your generated css."
end
def parse!(arguments)
parser = option_parser(arguments)
parser.parse!
parse_arguments!(parser, arguments)
parser.options
end
def parse_arguments!(parser, arguments)
if arguments.size == 1
parser.options[:project_name] = arguments.shift
elsif arguments.size == 0
# default to the current directory.
else
raise Compass::Error, "Too many arguments were specified."
end
end
end
end
end
end
end