Subcommand for CSS validation.
This commit is contained in:
parent
149978b4c9
commit
dd750391be
@ -204,7 +204,7 @@ Feature: Command Line
|
|||||||
Given I am using the existing project in test/fixtures/stylesheets/compass
|
Given I am using the existing project in test/fixtures/stylesheets/compass
|
||||||
When I run: compass validate
|
When I run: compass validate
|
||||||
Then my css is validated
|
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
|
Scenario: Get stats for my project
|
||||||
Given I am using the existing project in test/fixtures/stylesheets/compass
|
Given I am using the existing project in test/fixtures/stylesheets/compass
|
||||||
|
@ -170,11 +170,11 @@ Then /^the following configuration properties are set in config\/compass\.rb:$/
|
|||||||
end
|
end
|
||||||
|
|
||||||
Then /^my css is validated$/ do
|
Then /^my css is validated$/ do
|
||||||
pending
|
@last_result.should =~ /Compass CSS Validator/
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I am informed that it is not, because IE6 hacks suck\.$/ do
|
Then /^I am informed that my css is valid.$/ do
|
||||||
pending
|
@last_result.should =~ /Your CSS files are valid\./
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I am told statistics for each file:$/ do |table|
|
Then /^I am told statistics for each file:$/ do |table|
|
||||||
|
@ -3,8 +3,26 @@ require 'compass/commands/update_project'
|
|||||||
|
|
||||||
module Compass
|
module Compass
|
||||||
module Commands
|
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
|
class ValidateProject < ProjectBase
|
||||||
|
|
||||||
|
register :validate
|
||||||
|
|
||||||
def initialize(working_path, options)
|
def initialize(working_path, options)
|
||||||
super
|
super
|
||||||
assert_project_directory_exists!
|
assert_project_directory_exists!
|
||||||
@ -16,6 +34,42 @@ module Compass
|
|||||||
Validator.new(project_css_subdirectory).validate()
|
Validator.new(project_css_subdirectory).validate()
|
||||||
end
|
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
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user