Merge branch 'master' of github.com:chriseppstein/compass

Conflicts:
	doc-src/content/CHANGELOG.markdown
This commit is contained in:
Brandon Mathis 2010-12-10 18:13:56 -06:00
commit de3fab45c3
25 changed files with 358 additions and 283 deletions

View File

@ -2,4 +2,4 @@
:major: 0
:minor: 11
:state: alpha
:build: 3
:build: 4

View File

@ -22,8 +22,7 @@ fallback_load_path(File.join(File.dirname(__FILE__), '..', 'lib')) do
end
runner = Proc.new do
command_line_class = Compass::Exec::Helpers.select_appropriate_command_line_ui(ARGV)
command_line_class.new(ARGV).run!
Compass::Exec::SubCommandUI.new(ARGV).run!
end
if ARGV.delete("--profile")

View File

@ -16,4 +16,6 @@ gem 'compass', :path => ".."
gem 'compass-susy-plugin', ">=0.7.0.pre8"
gem 'css-slideshow', "0.2.0"
gem 'json'
gem 'css_parser'
gem 'ruby-prof'

View File

@ -29,6 +29,7 @@ GEM
cri (1.0.1)
css-slideshow (0.2.0)
compass (>= 0.10.0.rc3)
css_parser (1.1.4)
fssm (0.1.2)
haml (3.1.0.alpha.36)
i18n (0.4.2)
@ -38,6 +39,7 @@ GEM
rack (1.2.1)
rake (0.8.7)
rdiscount (1.6.5)
ruby-prof (0.9.2)
serve (1.0.0)
activesupport (~> 3.0.1)
i18n (~> 0.4.1)
@ -54,6 +56,7 @@ DEPENDENCIES
compass!
compass-susy-plugin (>= 0.7.0.pre8)
css-slideshow (= 0.2.0)
css_parser
fssm (= 0.1.2)
haml (>= 3.1.0.alpha.36)
json
@ -63,6 +66,7 @@ DEPENDENCIES
rack
rake
rdiscount
ruby-prof
sass (>= 3.1.0.alpha.50)!
serve (= 1.0.0)
thor

View File

@ -14,12 +14,20 @@ The Documentation for the [latest stable release](http://compass-style.org/docs/
The Documentation for the [latest preview release](http://beta.compass-style.org/)
0.11.alpha.4 (future)
0.11.alpha.5 (future)
---------------------
* Added optional support for IE8 with $legacy-support-for-ie8 which defaults to true.
* Updated the opacity and filter-gradient mixins to make IE's hacky DirectX filters optional based on Compass's legacy support settings.
0.11.alpha.4 (12/08/2010)
-------------------------
* Add a `--time` option to the compile and watch commands. This will print out
the time spent compiling each sass file and a total at the end.
* Upgrade FSSM, the internal library that monitors the filesystem events for compass.
* Removed the command line options that were deprecated in v0.10.
0.11.alpha.3 (12/05/2010)
-------------------------

View File

@ -33,19 +33,20 @@ module Compass
options ||= self.options if self.respond_to?(:options)
skip_write = options[:dry_run]
contents = process_erb(contents, options[:erb]) if options[:erb]
extra = options[:extra] || ""
if File.exists?(file_name)
existing_contents = IO.read(file_name)
if existing_contents == contents
logger.record :identical, basename(file_name)
logger.record :identical, basename(file_name), extra
skip_write = true
elsif options[:force]
logger.record :overwrite, basename(file_name)
logger.record :overwrite, basename(file_name), extra
else
msg = "File #{basename(file_name)} already exists. Run with --force to force overwrite."
raise Compass::FilesystemConflict.new(msg)
end
else
logger.record :create, basename(file_name)
logger.record :create, basename(file_name), extra
end
if skip_write
FileUtils.touch file_name unless options[:dry_run]

View File

@ -3,7 +3,7 @@ end
require 'compass/commands/registry'
%w(base generate_grid_background help list_frameworks project_base
%w(base generate_grid_background default help list_frameworks project_base
update_project watch_project create_project imports installer_command
print_version project_stats stamp_pattern sprite validate_project
write_configuration interactive unpack_extension).each do |lib|

View File

@ -0,0 +1,50 @@
module Compass
module Commands
module DefaultOptionsParser
def set_options(opts)
opts.on("--trace") do
self.options[:trace] = true
end
opts.on("-?", "-h", "--help") do
self.options[:command] = Proc.new do
Help.new(working_path, options.merge(:help_command => "help"))
end
end
opts.on("-q", "--quiet") do
self.options[:quiet] = true
end
opts.on("-v", "--version") do
self.options[:command] = Proc.new do
PrintVersion.new(working_path, options)
end
end
super
end
end
class Default < Base
class << self
def option_parser(arguments)
parser = Compass::Exec::CommandOptionParser.new(arguments)
parser.extend(DefaultOptionsParser)
end
# def usage
# $stderr.puts caller.join("\n")
# "XXX"
# end
def parse!(arguments)
parser = option_parser(arguments)
parser.parse!
parser.options[:command] ||= Proc.new do
Help.new(working_path, options.merge(:help_command => "help"))
end
parser.options
end
end
def execute
instance_eval(&options[:command]).execute
end
end
end
end

View File

@ -9,6 +9,10 @@ Description:
build and maintain your stylesheets and makes it easy
for you to use stylesheet libraries provided by others.
Donating:
Compass is charityware. If you find it useful please make
a tax deductable donation: http://umdf.org/compass
To get help on a particular command please specify the command.
}

View File

@ -83,6 +83,8 @@ Options:
lines << "Compass #{::Compass.version[:string]}"
lines << "Copyright (c) 2008-#{Time.now.year} Chris Eppstein"
lines << "Released under the MIT License."
lines << "Compass is charityware."
lines << "Please make a tax deductable donation: http://umdf.org/compass"
puts lines.join("\n")
end
end

View File

@ -5,6 +5,7 @@ module Compass::Commands
@commands[name.to_sym] = command_class
end
def get(name)
return unless name
@commands ||= Hash.new
@commands[name.to_sym] || @commands[abbreviation_of(name)]
end
@ -13,6 +14,8 @@ module Compass::Commands
matching = @commands.keys.select{|k| k.to_s =~ re}
if matching.size == 1
matching.first
elsif name =~ /^-/
nil
else
raise Compass::Error, "Ambiguous abbreviation '#{name}'. Did you mean one of: #{matching.join(", ")}"
end

View File

@ -14,6 +14,9 @@ module Compass
Options:
}.split("\n").map{|l| l.gsub(/^ */,'')}.join("\n")
opts.on("--time", "Display compilation times.") do
self.options[:time] = true
end
super
end
end
@ -51,6 +54,7 @@ module Compass
:sass_files => explicit_sass_files,
:dry_run => options[:dry_run])
compiler_opts[:quiet] = options[:quiet] if options[:quiet]
compiler_opts[:time] = options[:time] if options[:time]
compiler_opts.merge!(additional_options)
Compass::Compiler.new(working_path,
Compass.configuration.sass_path,

View File

@ -76,6 +76,7 @@ module Compass
target_directories.each {|dir| directory dir}
# Compile each sass file.
result = timed do
sass_files.zip(css_files).each do |sass_filename, css_filename|
begin
compile_if_required sass_filename, css_filename
@ -84,21 +85,40 @@ module Compass
end
end
end
if options[:time]
puts "Compilation took #{(result.__duration * 1000).round / 1000.0}s"
end
end
def compile_if_required(sass_filename, css_filename)
if should_compile?(sass_filename, css_filename)
compile sass_filename, css_filename
compile sass_filename, css_filename, :time => options[:time]
else
logger.record :unchanged, basename(sass_filename) unless options[:quiet]
end
end
def timed
start_time = Time.now
res = yield
end_time = Time.now
res.instance_variable_set("@__duration", end_time - start_time)
def res.__duration
@__duration
end
res
end
# Compile one Sass file
def compile(sass_filename, css_filename)
def compile(sass_filename, css_filename, additional_options = {})
start_time = end_time = nil
css_content = logger.red do
timed do
engine(sass_filename, css_filename).render
end
write_file(css_filename, css_content, options.merge(:force => true))
end
duration = additional_options[:time] ? "(#{(css_content.__duration * 1000).round / 1000.0}s)" : ""
write_file(css_filename, css_content, options.merge(:force => true, :extra => duration))
end
def should_compile?(sass_filename, css_filename)

View File

@ -16,7 +16,7 @@ end
module Compass::Exec
end
%w(helpers switch_ui sub_command_ui
%w(helpers sub_command_ui
global_options_parser project_options_parser
command_option_parser).each do |lib|
require "compass/exec/#{lib}"

View File

@ -1,18 +1,6 @@
module Compass::Exec
module Helpers
extend self
def select_appropriate_command_line_ui(arguments)
if Compass::Commands.command_exists? arguments.first
SubCommandUI
else
unless arguments.include?("-h") || arguments.include?("--help")
Compass::Logger.new.red do
Compass::Util.compass_warn "WARNING: This interface is deprecated. Please use the new subcommand interface.\nSee `compass help` for more information.\n"
end
end
SwitchUI
end
end
def report_error(e, options)
$stderr.puts "#{e.class} on line #{get_line e} of #{get_file e}: #{e.message}"
if options[:trace]

View File

@ -30,6 +30,11 @@ module Compass::Exec
def perform!
$command = args.shift
command_class = Compass::Commands[$command]
unless command_class
args.unshift($command)
$command = "help"
command_class = Compass::Commands::Default
end
@options = if command_class.respond_to?("parse_#{$command}!")
command_class.send("parse_#{$command}!", args)
else
@ -38,7 +43,7 @@ module Compass::Exec
command_class.new(Dir.getwd, @options).execute
rescue OptionParser::ParseError => e
puts "Error: #{e.message}"
puts command_class.usage
puts command_class.usage if command_class.respond_to?(:usage)
end
end

View File

@ -70,7 +70,7 @@ module Compass::SassExtensions::Functions::Sprites
:repeat => repeat_for(sprite_name),
:spacing => spacing_for(sprite_name),
:position => position_for(sprite_name),
:digest => MD5.file(file).hexdigest
:digest => Digest::MD5.file(file).hexdigest
}
end
@images.each_with_index do |image, index|
@ -163,7 +163,8 @@ module Compass::SassExtensions::Functions::Sprites
def uniqueness_hash
@uniqueness_hash ||= begin
sum = MD5.md5(SPRITE_VERSION)
sum = Digest::MD5.new
sum << SPRITE_VERSION
sum << path
images.each do |image|
[:relative_file, :height, :width, :repeat, :spacing, :position, :digest].each do |attr|

View File

@ -5,8 +5,11 @@ module FSSM::Backends
end
def add_handler(handler, preload=true)
@notifier.watch(handler.path.to_s, :all_events) do |event|
handler.refresh(event.name)
@notifier.watch(handler.path.to_s, :recursive, :attrib, :modify, :create,
:delete, :delete_self, :moved_from, :moved_to, :move_self) do |event|
path = FSSM::Pathname.for(event.absolute_name)
path = path.dirname unless event.name == "" # Event on root directory
handler.refresh(path)
end
handler.refresh(nil, true) if preload

View File

@ -1,42 +1,183 @@
# The bundled ruby pathname library is a slow and hideous beast.
# There. I said it. This version is based on pathname3.
require 'fileutils'
require 'find'
module FSSM
class Pathname < String
SYMLOOP_MAX = 8
SEPARATOR = Regexp.quote(File::SEPARATOR)
if File::ALT_SEPARATOR
ALT_SEPARATOR = Regexp.quote(File::ALT_SEPARATOR)
SEPARATOR_PAT = Regexp.compile("[#{SEPARATOR}#{ALT_SEPARATOR}]")
else
SEPARATOR_PAT = Regexp.compile(SEPARATOR)
end
if RUBY_PLATFORM =~ /(:?mswin|mingw|bccwin)/
PREFIX_PAT = Regexp.compile("^([A-Za-z]:#{SEPARATOR_PAT})")
else
PREFIX_PAT = Regexp.compile("^(#{SEPARATOR_PAT})")
end
ROOT = '/'.freeze
DOT = '.'.freeze
DOT_DOT = '..'.freeze
class << self
def for(path)
path = path.is_a?(::FSSM::Pathname) ? path : new(path)
path.dememo
path
path.is_a?(::FSSM::Pathname) ? path : new("#{path}")
end
end
def initialize(path)
if path =~ %r{\0}
raise ArgumentError, "path cannot contain ASCII NULLs"
end
dememo
raise ArgumentError, "path cannot contain ASCII NULLs" if path =~ %r{\0}
super(path)
end
def <=>(other)
self.tr('/', "\0").to_s <=> other.to_str.tr('/', "\0")
rescue NoMethodError
nil
end
def ==(other)
left = self.cleanpath.tr('/', "\0").to_s
right = self.class.for(other).cleanpath.tr('/', "\0").to_s
left == right
rescue NoMethodError
false
end
def +(path)
dup << path
end
def <<(path)
replace( join(path).cleanpath! )
end
def absolute?
self[0, 1].to_s == ROOT
end
def ascend
parts = to_a
parts.length.downto(1) do |i|
yield self.class.join(parts[0, i])
end
end
def children
entries[2..-1]
end
def cleanpath!
parts = to_a
final = []
parts.each do |part|
case part
when DOT then
next
when DOT_DOT then
case final.last
when ROOT then
next
when DOT_DOT then
final.push(DOT_DOT)
when nil then
final.push(DOT_DOT)
else
final.pop
end
else
final.push(part)
end
end
replace(final.empty? ? DOT : self.class.join(*final))
end
def cleanpath
dup.cleanpath!
end
def descend
parts = to_a
1.upto(parts.length) { |i| yield self.class.join(parts[0, i]) }
end
def dot?
self == DOT
end
def dot_dot?
self == DOT_DOT
end
def each_filename(&blk)
to_a.each(&blk)
end
def mountpoint?
stat1 = self.lstat
stat2 = self.parent.lstat
stat1.dev != stat2.dev || stat1.ino == stat2.ino
rescue Errno::ENOENT
false
end
def parent
self + '..'
end
def realpath
path = self
SYMLOOP_MAX.times do
link = path.readlink
link = path.dirname + link if link.relative?
path = link
end
raise Errno::ELOOP, self
rescue Errno::EINVAL
path.expand_path
end
def relative?
!absolute?
end
def relative_path_from(base)
base = self.class.for(base)
raise ArgumentError, 'no relative path between a relative and absolute' if self.absolute? != base.absolute?
return self if base.dot?
return self.class.new(DOT) if self == base
base = base.cleanpath.to_a
dest = self.cleanpath.to_a
while !dest.empty? && !base.empty? && dest[0] == base[0]
base.shift
dest.shift
end
base.shift if base[0] == DOT
dest.shift if dest[0] == DOT
raise ArgumentError, "base directory may not contain '#{DOT_DOT}'" if base.include?(DOT_DOT)
path = base.fill(DOT_DOT) + dest
path = self.class.join(*path)
path = self.class.new(DOT) if path.empty?
path
end
def root?
!!(self =~ %r{^#{ROOT}+$})
end
def to_a
array = to_s.split(File::SEPARATOR)
array.delete('')
array.insert(0, ROOT) if absolute?
array
end
alias segments to_a
def to_path
self
end
@ -47,150 +188,6 @@ module FSSM
alias to_str to_s
def to_a
return @segments if @segments
set_prefix_and_names
@segments = @names.dup
@segments.delete('.')
@segments.unshift(@prefix) unless @prefix.empty?
@segments
end
alias segments to_a
def each_filename(&block)
to_a.each(&block)
end
def ascend
parts = to_a
parts.length.downto(1) do |i|
yield self.class.join(parts[0, i])
end
end
def descend
parts = to_a
1.upto(parts.length) do |i|
yield self.class.join(parts[0, i])
end
end
def root?
set_prefix_and_names
@names.empty? && !@prefix.empty?
end
def parent
self + '..'
end
def relative?
set_prefix_and_names
@prefix.empty?
end
def absolute?
!relative?
end
def +(path)
dup << path
end
def <<(path)
replace(join(path).cleanpath!)
end
def cleanpath!
parts = to_a
final = []
parts.each do |part|
case part
when '.' then
next
when '..' then
case final.last
when '..' then
final.push('..')
when nil then
final.push('..')
else
final.pop
end
else
final.push(part)
end
end
replace(final.empty? ? Dir.pwd : File.join(*final))
end
def cleanpath
dup.cleanpath!
end
def realpath
raise unless self.exist?
if File.symlink?(self)
file = self.dup
while true
file = File.join(File.dirname(file), File.readlink(file))
break unless File.symlink?(file)
end
self.class.new(file).clean
else
self.class.new(Dir.pwd) + self
end
end
def relative_path_from(base)
base = self.class.for(base)
if self.absolute? != base.absolute?
raise ArgumentError, 'no relative path between a relative and absolute'
end
if self.prefix != base.prefix
raise ArgumentError, "different prefix: #{@prefix.inspect} and #{base.prefix.inspect}"
end
base = base.cleanpath!.segments
dest = dup.cleanpath!.segments
while !dest.empty? && !base.empty? && dest[0] == base[0]
base.shift
dest.shift
end
base.shift if base[0] == '.'
dest.shift if dest[0] == '.'
if base.include?('..')
raise ArgumentError, "base directory may not contain '..'"
end
path = base.fill('..') + dest
path = self.class.join(*path)
path = self.class.new('.') if path.empty?
path
end
def replace(path)
if path =~ %r{\0}
raise ArgumentError, "path cannot contain ASCII NULLs"
end
dememo
super(path)
end
def unlink
Dir.unlink(self)
true
@ -198,68 +195,15 @@ module FSSM
File.unlink(self)
true
end
def prefix
set_prefix_and_names
@prefix
end
def names
set_prefix_and_names
@names
end
def dememo
@set = nil
@segments = nil
@prefix = nil
@names = nil
end
private
def set_prefix_and_names
return if @set
@names = []
if (match = PREFIX_PAT.match(self))
@prefix = match[0].to_s
@names += match.post_match.split(SEPARATOR_PAT)
else
@prefix = ''
@names += self.split(SEPARATOR_PAT)
end
@names.compact!
@names.delete('')
@set = true
end
end
class Pathname
class << self
def glob(pattern, flags=0)
dirs = Dir.glob(pattern, flags)
dirs.map! {|path| new(path)}
if block_given?
dirs.each {|dir| yield dir}
nil
else
dirs
end
def self.[](pattern)
Dir[pattern].map! {|d| FSSM::Pathname.new(d) }
end
def [](pattern)
Dir[pattern].map! {|path| new(path)}
end
def pwd
new(Dir.pwd)
end
def self.pwd
FSSM::Pathname.new(Dir.pwd)
end
def entries
@ -278,6 +222,24 @@ module FSSM
Dir.rmdir(self)
end
def self.glob(pattern, flags = 0)
dirs = Dir.glob(pattern, flags)
dirs.map! {|path| FSSM::Pathname.new(path) }
if block_given?
dirs.each {|dir| yield dir }
nil
else
dirs
end
end
def glob(pattern, flags = 0, &block)
patterns = [pattern].flatten
patterns.map! {|p| self.class.glob(self.to_s + p, flags, &block) }
patterns.flatten
end
def chdir
blk = lambda { yield self } if block_given?
Dir.chdir(self, &blk)
@ -372,8 +334,6 @@ module FSSM
def zero?
FileTest.zero?(self)
end
alias exist? exists?
end
class Pathname
@ -407,10 +367,10 @@ module FSSM
end
class Pathname
class << self
def join(*parts)
new(File.join(*parts.reject {|p| p.empty? }))
end
def self.join(*parts)
last_part = FSSM::Pathname.new(parts.last)
return last_part if last_part.absolute?
FSSM::Pathname.new(File.join(*parts.reject {|p| p.empty? }))
end
def basename
@ -478,6 +438,10 @@ module FSSM
File.size?(self)
end
def split
File.split(self).map {|part| FSSM::Pathname.new(part) }
end
def symlink(to)
File.symlink(self, to)
end
@ -525,4 +489,14 @@ module FSSM
end
end
class Pathname
class << self
alias getwd pwd
end
alias absolute expand_path
alias delete unlink
alias exist? exists?
alias fnmatch fnmatch?
end
end

View File

@ -39,11 +39,14 @@ module FSSM::Support
def rb_inotify?
found = begin
require 'rb-inotify'
INotify::Notifier.ancestors.include?(IO)
if defined?(INotify::VERSION)
version = INotify::VERSION
version[0] > 0 || version[1] >= 6
end
rescue LoadError
false
end
STDERR.puts("Warning: Unable to load rb-inotify >= 0.3.0. Inotify will be unavailable.") unless found
STDERR.puts("Warning: Unable to load rb-inotify >= 0.5.1. Inotify will be unavailable.") unless found
found
end

View File

@ -107,8 +107,7 @@ module Compass::CommandLineHelper
end
def execute(*arguments)
command_line_class = Compass::Exec::Helpers.select_appropriate_command_line_ui(arguments)
exit_code = command_line_class.new(arguments).run!
exit_code = Compass::Exec::SubCommandUI.new(arguments).run!
# fail "Command Failed with exit code: #{exit_code}" unless exit_code == 0
exit_code
end

View File

@ -20,7 +20,7 @@ class CommandLineTest < Test::Unit::TestCase
def test_basic_install
within_tmp_directory do
compass "--boring", "basic"
compass "create", "--boring", "basic"
assert File.exists?("basic/sass/screen.scss")
assert File.exists?("basic/stylesheets/screen.css")
assert_action_performed :directory, "basic/"
@ -33,7 +33,7 @@ class CommandLineTest < Test::Unit::TestCase
next if framework.name =~ /^_/
define_method "test_#{framework.name}_installation" do
within_tmp_directory do
compass *%W(--boring --framework #{framework.name} #{framework.name}_project)
compass *%W(create --boring --using #{framework.name} #{framework.name}_project)
assert File.exists?("#{framework.name}_project/sass/screen.scss"), "sass/screen.scss is missing. Found: #{Dir.glob("#{framework.name}_project/**/*").join(", ")}"
assert File.exists?("#{framework.name}_project/stylesheets/screen.css")
assert_action_performed :directory, "#{framework.name}_project/"
@ -45,13 +45,13 @@ class CommandLineTest < Test::Unit::TestCase
def test_basic_update
within_tmp_directory do
compass "--boring", "basic"
compass "create", "--boring", "basic"
Dir.chdir "basic" do
# basic update with timestamp caching
compass "--boring"
compass "compile", "--boring"
assert_action_performed :unchanged, "sass/screen.scss"
# basic update with force option set
compass "--force", "--boring"
compass "compile", "--force", "--boring"
assert_action_performed :identical, "stylesheets/screen.css"
end
end

View File

@ -47,7 +47,7 @@ class CompassTest < Test::Unit::TestCase
assert_no_errors css_file, 'compass'
end
each_sass_file do |sass_file|
assert_renders_correctly sass_file
assert_renders_correctly sass_file, :ignore_charset => true
end
end
end
@ -86,8 +86,12 @@ private
for name in arguments
actual_result_file = "#{tempfile_path(@current_project)}/#{name}.css"
expected_result_file = "#{result_path(@current_project)}/#{name}.css"
actual_lines = File.read(actual_result_file).split("\n")
expected_lines = ERB.new(File.read(expected_result_file)).result(binding).split("\n")
actual_lines = File.read(actual_result_file)
actual_lines.gsub!(/^@charset[^;]+;/,'') if options[:ignore_charset]
actual_lines = actual_lines.split("\n").reject{|l| l=~/\A\Z/}
expected_lines = ERB.new(File.read(expected_result_file)).result(binding)
expected_lines.gsub!(/^@charset[^;]+;/,'') if options[:ignore_charset]
expected_lines = expected_lines.split("\n").reject{|l| l=~/\A\Z/}
expected_lines.zip(actual_lines).each_with_index do |pair, line|
message = "template: #{name}\nline: #{line + 1}"
assert_equal(pair.first, pair.last, message)

View File

@ -4,6 +4,7 @@ module Compass
Dir.mkdir name
Dir.mkdir File.join(name, "config")
Dir.mkdir File.join(name, "config", "initializers")
Dir.mkdir File.join(name, "tmp")
end
# Generate a rails application without polluting our current set of requires

View File

@ -39,7 +39,7 @@ class RailsIntegrationTest < Test::Unit::TestCase
within_tmp_directory do
generate_rails_app_directories("compass_rails")
Dir.chdir "compass_rails" do
compass(*%w(--rails --trace --boring --sass-dir app/stylesheets --css-dir public/stylesheets/compiled .))
compass(*%w(init rails --trace --boring --sass-dir app/stylesheets --css-dir public/stylesheets/compiled .))
assert_action_performed :create, "./app/stylesheets/screen.scss"
assert_action_performed :create, "./config/initializers/compass.rb"
end