Validate your project's CSS files by running compass --validate.
This commit is contained in:
parent
a8b36a6441
commit
63de13debd
3
Manifest
3
Manifest
@ -55,7 +55,6 @@ examples/yui/sub_divisions.html.haml
|
||||
examples/yui/templates.html.haml
|
||||
examples/yui/test.jpg
|
||||
examples/yui/typography.html.haml
|
||||
frameworks/blueprint/lib/blueprint/constants.rb
|
||||
frameworks/blueprint/lib/blueprint/grid_builder.rb
|
||||
frameworks/blueprint/stylesheets/_blueprint.sass
|
||||
frameworks/blueprint/stylesheets/blueprint/_ie.sass
|
||||
@ -125,6 +124,7 @@ lib/compass/commands/list_frameworks.rb
|
||||
lib/compass/commands/print_version.rb
|
||||
lib/compass/commands/project_base.rb
|
||||
lib/compass/commands/update_project.rb
|
||||
lib/compass/commands/validate_project.rb
|
||||
lib/compass/commands/watch_project.rb
|
||||
lib/compass/commands/write_configuration.rb
|
||||
lib/compass/compiler.rb
|
||||
@ -149,7 +149,6 @@ lib/compass/validate/JIGSAW_COPYRIGHT
|
||||
lib/compass/validate/README.html
|
||||
lib/compass/validate/xerces.jar
|
||||
lib/compass/validate/XERCES_COPYING.txt
|
||||
lib/compass/validate.rb
|
||||
lib/compass/validator.rb
|
||||
lib/compass/version.rb
|
||||
lib/compass.rb
|
||||
|
@ -1,17 +0,0 @@
|
||||
require 'fileutils'
|
||||
module Blueprint
|
||||
module Constants
|
||||
# path to the root Blueprint directory
|
||||
ROOT_PATH = File.expand_path(File.join(File.dirname(__FILE__), "../../"))
|
||||
# path to where the Blueprint CSS files are stored
|
||||
BLUEPRINT_ROOT_PATH = File.join(ROOT_PATH, 'blueprint')
|
||||
# path to where the Blueprint CSS raw Sass files are stored
|
||||
SOURCE_PATH = File.join(ROOT_PATH, 'src')
|
||||
# path to where the Blueprint CSS generated test files are stored
|
||||
EXAMPLES_PATH = File.join(ROOT_PATH, 'examples')
|
||||
# path to the root of the Blueprint scripts
|
||||
LIB_PATH = File.join(ROOT_PATH, 'lib', 'blueprint')
|
||||
# path to validator jar file to validate generated CSS files
|
||||
VALIDATOR_FILE = File.join(LIB_PATH, 'validate', 'css-validator.jar')
|
||||
end
|
||||
end
|
21
lib/compass/commands/validate_project.rb
Normal file
21
lib/compass/commands/validate_project.rb
Normal file
@ -0,0 +1,21 @@
|
||||
require File.join(File.dirname(__FILE__), 'project_base')
|
||||
require File.join(File.dirname(__FILE__), 'update_project')
|
||||
require File.join(File.dirname(__FILE__), '..', 'validator')
|
||||
|
||||
module Compass
|
||||
module Commands
|
||||
class ValidateProject < ProjectBase
|
||||
|
||||
def initialize(working_path, options)
|
||||
super
|
||||
assert_project_directory_exists!
|
||||
end
|
||||
|
||||
def perform
|
||||
UpdateProject.new(working_path, options).perform
|
||||
Validator.new(project_css_subdirectory).validate()
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -158,6 +158,10 @@ END
|
||||
exit
|
||||
end
|
||||
|
||||
opts.on('--validate', :NONE, 'Validate your project\'s compiled css') do
|
||||
self.options[:command] = :validate_project
|
||||
end
|
||||
|
||||
opts.on_tail("-?", "-h", "--help", "Show this message") do
|
||||
puts opts
|
||||
exit
|
||||
|
@ -1,13 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require File.join(File.dirname(__FILE__), 'compass', 'validator')
|
||||
|
||||
# This script will validate the core Compass files.
|
||||
#
|
||||
# The files are not completely valid. This has to do
|
||||
# with a small number of CSS hacks needed to ensure
|
||||
# consistent rendering across browsers.
|
||||
#
|
||||
# To add your own CSS files for validation, see
|
||||
# /lib/compass/validator.rb
|
||||
|
||||
Compass::Validator.new.validate
|
@ -1,13 +1,14 @@
|
||||
require File.join(File.dirname(__FILE__), 'core_ext')
|
||||
require File.join(File.dirname(__FILE__), 'constants')
|
||||
|
||||
module Compass
|
||||
# Validates generated CSS against the W3 using Java
|
||||
class Validator
|
||||
VALIDATOR_FILE = File.join(File.dirname(__FILE__), 'validate', 'css-validator.jar')
|
||||
attr_reader :error_count
|
||||
attr_reader :css_directory
|
||||
|
||||
def initialize
|
||||
def initialize(css_directory)
|
||||
@css_directory = css_directory
|
||||
@error_count = 0
|
||||
end
|
||||
|
||||
@ -18,12 +19,8 @@ module Compass
|
||||
|
||||
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
|
||||
Dir.glob(File.join(css_directory, "**", "*.css")).each do |file_name|
|
||||
@error_count += 1 if !validate_css_file(java_path, file_name)
|
||||
end
|
||||
|
||||
output_footer
|
||||
@ -31,29 +28,29 @@ module Compass
|
||||
|
||||
private
|
||||
def validate_css_file(java_path, css_file)
|
||||
puts "\n\n Testing #{css_file}"
|
||||
puts " Output ============================================================\n\n"
|
||||
puts "\n\nTesting #{css_file}"
|
||||
puts "Output ============================================================\n\n"
|
||||
system("#{java_path} -jar '#{VALIDATOR_FILE}' -e '#{css_file}'")
|
||||
end
|
||||
|
||||
def output_header
|
||||
puts "\n\n"
|
||||
puts " ************************************************************"
|
||||
puts " **"
|
||||
puts " ** Compass CSS Validator"
|
||||
puts " ** Validates output CSS files"
|
||||
puts " **"
|
||||
puts " ************************************************************"
|
||||
puts "************************************************************"
|
||||
puts "**"
|
||||
puts "** Compass 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 " ************************************************************"
|
||||
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
|
Loading…
Reference in New Issue
Block a user