This commit is contained in:
Scott Davis 2011-04-23 10:19:40 -04:00
commit 613753e06a
9 changed files with 147 additions and 77 deletions

View File

@ -9,7 +9,7 @@ PATH
specs: specs:
compass (0.11.beta.7.fec367d) compass (0.11.beta.7.fec367d)
chunky_png (~> 1.1.0) chunky_png (~> 1.1.0)
fssm (~> 0.2) fssm (>= 0.2.7)
sass (>= 3.1.0.alpha.249) sass (>= 3.1.0.alpha.249)
GEM GEM
@ -65,7 +65,7 @@ GEM
erubis (2.6.6) erubis (2.6.6)
abstract (>= 1.0.0) abstract (>= 1.0.0)
eventmachine (0.12.10) eventmachine (0.12.10)
fssm (0.2.6.1) fssm (0.2.7)
gherkin (2.2.9) gherkin (2.2.9)
json (~> 1.4.6) json (~> 1.4.6)
term-ansicolor (~> 1.0.5) term-ansicolor (~> 1.0.5)

View File

@ -17,7 +17,7 @@ Gem::Specification.new do |gemspec|
gemspec.add_dependency 'sass', '>= 3.1.0.alpha.249' gemspec.add_dependency 'sass', '>= 3.1.0.alpha.249'
gemspec.add_dependency 'chunky_png', '~> 1.1.0' gemspec.add_dependency 'chunky_png', '~> 1.1.0'
gemspec.add_dependency 'fssm', '~> 0.2' gemspec.add_dependency 'fssm', '>= 0.2.7'
gemspec.files = %w(README.markdown LICENSE.markdown VERSION.yml Rakefile) gemspec.files = %w(README.markdown LICENSE.markdown VERSION.yml Rakefile)
gemspec.files += Dir.glob("bin/*") gemspec.files += Dir.glob("bin/*")

View File

@ -9,7 +9,6 @@ gem 'serve', "1.0.0"
gem 'nokogiri' gem 'nokogiri'
gem 'coderay' gem 'coderay'
gem 'sass', ">= 3.1.0.alpha.249" gem 'sass', ">= 3.1.0.alpha.249"
gem 'fssm', '0.1.2'
gem 'haml', ">= 3.1.0.alpha.36" gem 'haml', ">= 3.1.0.alpha.36"
gem 'rake' gem 'rake'
gem 'compass', :path => ".." gem 'compass', :path => ".."
@ -18,4 +17,5 @@ gem 'css-slideshow', "0.2.0"
gem 'json' gem 'json'
gem 'css_parser', "1.0.1" gem 'css_parser', "1.0.1"
gem 'ruby-prof' gem 'ruby-prof'
gem 'rb-fsevent'

View File

@ -8,8 +8,9 @@ GIT
PATH PATH
remote: .. remote: ..
specs: specs:
compass (0.11.beta.6.7c5f831) compass (0.11.beta.7.f4ac295)
chunky_png (~> 1.1.0) chunky_png (~> 1.1.0)
fssm (>= 0.2.7)
sass (>= 3.1.0.alpha.249) sass (>= 3.1.0.alpha.249)
GEM GEM
@ -24,7 +25,7 @@ GEM
css-slideshow (0.2.0) css-slideshow (0.2.0)
compass (>= 0.10.0.rc3) compass (>= 0.10.0.rc3)
css_parser (1.0.1) css_parser (1.0.1)
fssm (0.1.2) fssm (0.2.7)
haml (3.1.0.alpha.147) haml (3.1.0.alpha.147)
i18n (0.4.2) i18n (0.4.2)
json (1.5.1) json (1.5.1)
@ -32,6 +33,7 @@ GEM
nokogiri (1.4.4) nokogiri (1.4.4)
rack (1.2.2) rack (1.2.2)
rake (0.8.7) rake (0.8.7)
rb-fsevent (0.4.0)
rdiscount (1.6.8) rdiscount (1.6.8)
ruby-prof (0.9.2) ruby-prof (0.9.2)
sass (3.1.0.alpha.252) sass (3.1.0.alpha.252)
@ -52,7 +54,6 @@ DEPENDENCIES
compass-susy-plugin (>= 0.7.0.pre8) compass-susy-plugin (>= 0.7.0.pre8)
css-slideshow (= 0.2.0) css-slideshow (= 0.2.0)
css_parser (= 1.0.1) css_parser (= 1.0.1)
fssm (= 0.1.2)
haml (>= 3.1.0.alpha.36) haml (>= 3.1.0.alpha.36)
json json
mime-types mime-types
@ -60,6 +61,7 @@ DEPENDENCIES
nokogiri nokogiri
rack rack
rake rake
rb-fsevent
rdiscount rdiscount
ruby-prof ruby-prof
sass (>= 3.1.0.alpha.249) sass (>= 3.1.0.alpha.249)

View File

@ -49,17 +49,20 @@ module Compass
end end
def new_compiler_instance(additional_options = {}) def new_compiler_instance(additional_options = {})
compiler_opts = Compass.sass_engine_options @compiler_opts ||= begin
compiler_opts.merge!(:force => options[:force], compiler_opts = Compass.sass_engine_options
:sass_files => explicit_sass_files, compiler_opts.merge!(:force => options[:force],
:dry_run => options[:dry_run]) :sass_files => explicit_sass_files,
compiler_opts[:quiet] = options[:quiet] if options[:quiet] :dry_run => options[:dry_run])
compiler_opts[:time] = options[:time] if options[:time] compiler_opts[:quiet] = options[:quiet] if options[:quiet]
compiler_opts.merge!(additional_options) compiler_opts[:time] = options[:time] if options[:time]
compiler_opts
end
Compass::Compiler.new(working_path, Compass::Compiler.new(working_path,
Compass.configuration.sass_path, Compass.configuration.sass_path,
Compass.configuration.css_path, Compass.configuration.css_path,
compiler_opts) @compiler_opts.merge(additional_options))
end end
def explicit_sass_files def explicit_sass_files

View File

@ -24,23 +24,62 @@ module Compass
end end
end end
module MemoryDebugger
def report_on_instances(type, options = {})
@@runs ||= 0
@@runs += 1
@@object_id_tracker ||= {}
@@object_id_tracker[type] ||= []
GC.start
sleep options.fetch(:gc_pause, 1)
count = ObjectSpace.each_object(type) do |obj|
if @@runs > 2
if options.fetch(:verbose, true) && !@@object_id_tracker[type].include?(obj.object_id)
begin
puts obj.inspect
rescue
end
puts "#{obj.class.name}:#{obj.object_id}"
end
end
@@object_id_tracker[type] << obj.object_id
end
puts "#{type}: #{count} instances."
end
end
class WatchProject < UpdateProject class WatchProject < UpdateProject
register :watch register :watch
attr_accessor :last_update_time, :last_sass_files attr_accessor :last_update_time, :last_sass_files
include MemoryDebugger
def perform def perform
Signal.trap("INT") do Signal.trap("INT") do
puts "" puts ""
exit 0 exit 0
end end
unless Compass.sass_engine_options[:cache_store]
@memory_cache = Sass::CacheStores::Memory.new
Compass.configuration.sass_options ||= {}
Sass::CacheStores::Chain.new(
@memory_cache,
Sass::CacheStores::Filesystem.new(
Compass.sass_engine_options[:cache_location] ||
Sass::Engine::DEFAULT_OPTIONS[:cache_location]
)
)
end
check_for_sass_files!(new_compiler_instance) check_for_sass_files!(new_compiler_instance)
recompile recompile
require 'fssm' require 'fssm'
if options[:poll] if options[:poll]
require "fssm/backends/polling" require "fssm/backends/polling"
# have to silence the ruby warning about chaning a constant. # have to silence the ruby warning about chaning a constant.
@ -98,11 +137,13 @@ module Compass
end end
def recompile(base = nil, relative = nil) def recompile(base = nil, relative = nil)
@memory_cache.reset! if @memory_cache
compiler = new_compiler_instance(:quiet => true) compiler = new_compiler_instance(:quiet => true)
if file = compiler.out_of_date? if file = compiler.out_of_date?
begin begin
puts ">>> Change detected to: #{file}" puts ">>> Change detected to: #{relative}"
compiler.run compiler.run
# report_on_instances(Sass::Importers::Base, :verbose => false)
rescue StandardError => e rescue StandardError => e
::Compass::Exec::Helpers.report_error(e, options) ::Compass::Exec::Helpers.report_error(e, options)
end end

View File

@ -12,7 +12,8 @@ module Compass
self.options = options self.options = options
self.options[:cache_location] ||= determine_cache_location self.options[:cache_location] ||= determine_cache_location
Compass.configure_sass_plugin! Compass.configure_sass_plugin!
self.importer = Sass::Importers::Filesystem.new(from)
self.options[:importer] = self.importer = Sass::Importers::Filesystem.new(from)
self.staleness_checker = Sass::Plugin::StalenessChecker.new(options) self.staleness_checker = Sass::Plugin::StalenessChecker.new(options)
end end

View File

@ -33,82 +33,109 @@ module Compass::SassExtensions::Functions::GradientSupport
end end
end end
class RadialGradient < Sass::Script::Literal module Gradient
attr_accessor :position_or_angle, :shape_and_size, :color_stops
def children def self.included(base)
[color_stops, position_or_angle, shape_and_size].compact base.extend ClassMethods
end end
def initialize(position_or_angle, shape_and_size, color_stops)
unless color_stops.value.size >= 2 module ClassMethods
raise Sass::SyntaxError, "At least two color stops are required for a radial-gradient" def standardized_prefix(prefix)
class_eval %Q{
def to_#{prefix}(options = self.options)
Sass::Script::String.new("-#{prefix}-\#{to_s(options)}")
end
}
end end
self.position_or_angle = position_or_angle
self.shape_and_size = shape_and_size
self.color_stops = color_stops
end end
def inspect def inspect
to_s to_s
end end
def supports?(aspect)
GRADIENT_ASPECTS.include?(aspect)
end
def has_aspect?
true
end
def angle?(value)
value.is_a?(Sass::Script::Number) && value.numerator_units.size == 1 && value.numerator_units.first == "deg" && value.denominator_units.empty?
end
end
class RadialGradient < Sass::Script::Literal
include Gradient
attr_accessor :position, :shape_and_size, :color_stops
def children
[color_stops, position, shape_and_size].compact
end
def initialize(position, shape_and_size, color_stops)
unless color_stops.value.size >= 2
raise Sass::SyntaxError, "At least two color stops are required for a radial-gradient"
end
if angle?(position)
raise Sass::SyntaxError, "CSS no longer allows angles in radial-gradients."
end
self.position = position
self.shape_and_size = shape_and_size
self.color_stops = color_stops
end
def to_s(options = self.options) def to_s(options = self.options)
s = "radial-gradient(" s = "radial-gradient("
s << position_or_angle.to_s(options) << ", " if position_or_angle s << position.to_s(options) << ", " if position
s << shape_and_size.to_s(options) << ", " if shape_and_size s << shape_and_size.to_s(options) << ", " if shape_and_size
s << color_stops.to_s(options) s << color_stops.to_s(options)
s << ")" s << ")"
end end
def supports?(aspect)
if aspect == "svg" standardized_prefix :webkit
if position_or_angle.nil? || is_position(position_or_angle).to_bool || is_position_list(position_or_angle).to_bool standardized_prefix :moz
true standardized_prefix :o
else
Compass::Util.compass_warn("Warning: Angle-based gradients are not yet supported in SVG. Found: #{position_or_angle}")
false
end
else
GRADIENT_ASPECTS.include?(aspect)
end
end
def has_aspect?
true
end
def to_webkit(options = self.options)
Sass::Script::String.new("-webkit-#{to_s(options)}")
end
def to_owg(options = self.options) def to_owg(options = self.options)
args = [ args = [
grad_point(position_or_angle || _center_position), grad_point(position || _center_position),
Sass::Script::String.new("0"), Sass::Script::String.new("0"),
grad_point(position_or_angle || _center_position), grad_point(position || _center_position),
grad_end_position(color_stops, Sass::Script::Bool.new(true)), grad_end_position(color_stops, Sass::Script::Bool.new(true)),
grad_color_stops(color_stops) grad_color_stops(color_stops)
] ]
args.each {|a| a.options = options} args.each {|a| a.options = options}
Sass::Script::String.new("-webkit-gradient(radial, #{args.join(', ')})") Sass::Script::String.new("-webkit-gradient(radial, #{args.join(', ')})")
end end
def to_moz(options = self.options)
Sass::Script::String.new("-moz-#{to_s(options)}")
end
def to_o(options = self.options)
Sass::Script::String.new("-o-#{to_s(options)}")
end
def to_svg(options = self.options) def to_svg(options = self.options)
# XXX Add shape support if possible # XXX Add shape support if possible
radial_svg_gradient(color_stops, position_or_angle || _center_position) radial_svg_gradient(color_stops, position || _center_position)
end end
def to_pie(options = self.options) def to_pie(options = self.options)
Compass::Logger.new.record(:warning, "PIE does not support radial-gradient.") Compass::Logger.new.record(:warning, "PIE does not support radial-gradient.")
Sass::Script::String.new("-pie-radial-gradient(unsupported)") Sass::Script::String.new("-pie-radial-gradient(unsupported)")
end end
def to_css2(options = self.options) def to_css2(options = self.options)
Sass::Script::String.new("") Sass::Script::String.new("")
end end
end end
class LinearGradient < Sass::Script::Literal class LinearGradient < Sass::Script::Literal
include Gradient
attr_accessor :color_stops, :position_or_angle attr_accessor :color_stops, :position_or_angle
def children def children
[color_stops, position_or_angle].compact [color_stops, position_or_angle].compact
end end
def initialize(position_or_angle, color_stops) def initialize(position_or_angle, color_stops)
unless color_stops.value.size >= 2 unless color_stops.value.size >= 2
raise Sass::SyntaxError, "At least two color stops are required for a linear-gradient" raise Sass::SyntaxError, "At least two color stops are required for a linear-gradient"
@ -116,24 +143,18 @@ module Compass::SassExtensions::Functions::GradientSupport
self.position_or_angle = position_or_angle self.position_or_angle = position_or_angle
self.color_stops = color_stops self.color_stops = color_stops
end end
def inspect
to_s
end
def to_s(options = self.options) def to_s(options = self.options)
s = "linear-gradient(" s = "linear-gradient("
s << position_or_angle.to_s(options) << ", " if position_or_angle s << position_or_angle.to_s(options) << ", " if position_or_angle
s << color_stops.to_s(options) s << color_stops.to_s(options)
s << ")" s << ")"
end end
def supports?(aspect)
GRADIENT_ASPECTS.include?(aspect) standardized_prefix :webkit
end standardized_prefix :moz
def has_aspect? standardized_prefix :o
true
end
def to_webkit(options = self.options)
Sass::Script::String.new("-webkit-#{to_s(options)}")
end
# Output the original webkit gradient syntax # Output the original webkit gradient syntax
def to_owg(options = self.options) def to_owg(options = self.options)
args = [] args = []
@ -143,20 +164,17 @@ module Compass::SassExtensions::Functions::GradientSupport
args.each{|a| a.options = options} args.each{|a| a.options = options}
Sass::Script::String.new("-webkit-gradient(linear, #{args.join(', ')})") Sass::Script::String.new("-webkit-gradient(linear, #{args.join(', ')})")
end end
def to_moz(options = self.options)
Sass::Script::String.new("-moz-#{to_s(options)}")
end
def to_o(options = self.options)
Sass::Script::String.new("-o-#{to_s(options)}")
end
def to_svg(options = self.options) def to_svg(options = self.options)
linear_svg_gradient(color_stops, position_or_angle || Sass::Script::String.new("top")) linear_svg_gradient(color_stops, position_or_angle || Sass::Script::String.new("top"))
end end
def to_pie(options = self.options) def to_pie(options = self.options)
# PIE just uses the standard rep, but the property is prefixed so # PIE just uses the standard rep, but the property is prefixed so
# the presence of this attribute helps flag when to render a special rule. # the presence of this attribute helps flag when to render a special rule.
Sass::Script::String.new to_s(options) Sass::Script::String.new to_s(options)
end end
def to_css2(options = self.options) def to_css2(options = self.options)
Sass::Script::String.new("") Sass::Script::String.new("")
end end
@ -437,10 +455,6 @@ module Compass::SassExtensions::Functions::GradientSupport
end end
end end
def angle?
position_or_angle.is_a?(Sass::Script::Number) && position_or_angle.numerator_units == ["deg"] && position_or_angle.denominator_units.empty?
end
def linear_svg(color_stops, x1, y1, x2, y2) def linear_svg(color_stops, x1, y1, x2, y2)
transform = '' transform = ''
if angle? if angle?

View File

@ -49,5 +49,14 @@ module Compass
def to_s def to_s
"" ""
end end
def hash
self.class.name.hash
end
def eql?(other)
other.class == self.class
end
end end
end end