Merge commit 'chriseppstein/master'

This commit is contained in:
Nathan Weizenbaum 2009-06-29 00:53:24 -07:00
commit a6af0865bc
5 changed files with 40 additions and 10 deletions

View File

@ -114,7 +114,7 @@ Available options are:
or `:width = !main_width`.
By default, either syntax is valid.
{#cache-option} `cache`
{#cache-option} `:cache`
: Whether parsed Sass files should be cached,
allowing greater speed. Defaults to true.
@ -1032,7 +1032,7 @@ Although the default CSS style that Sass outputs is very nice,
and reflects the structure of the document in a similar way that Sass does,
sometimes it's good to have other formats available.
Sass allows you to choose between three different output styles
Sass allows you to choose between four different output styles
by setting the `:style` option.
In Rails, this is done by setting `Sass::Plugin.options[:style]`;
outside Rails, it's done by passing an options hash with `:style` set.

View File

@ -61,6 +61,21 @@ module Sass::Script
instance_methods.each { |m| undef_method m unless m.to_s =~ /^__/ }
# Creates a {Color} object from red, green, and blue values.
# @param red
# A number between 0 and 255 inclusive
# @param green
# A number between 0 and 255 inclusive
# @param blue
# A number between 0 and 255 inclusive
def rgb(red, green, blue)
[red.value, green.value, blue.value].each do |v|
raise ArgumentError.new("rgb color value of #{v} encountered. Must be between 0 and 255 inclusive.") if v <= 0 || v >= 255
end
Color.new([red.value, green.value, blue.value])
end
# Creates a {Color} object from hue, saturation, and lightness
# as per the CSS3 spec (http://www.w3.org/TR/css3-color/#hsl-color).
#

View File

@ -155,9 +155,19 @@ module Sass::Script
# @param other [Literal] The right-hand side of the operator
# @return [Boolean] Whether this number is equal to the other object
def eq(other)
Sass::Script::Bool.new(super.to_bool &&
self.numerator_units.sort == other.numerator_units.sort &&
self.denominator_units.sort == other.denominator_units.sort)
return Sass::Script::Bool.new(false) unless other.is_a?(Sass::Script::Number)
this = self
begin
if unitless?
this = this.coerce(other.numerator_units, other.denominator_units)
else
other = other.coerce(numerator_units, denominator_units)
end
rescue Sass::SyntaxError
return Sass::Script::Bool.new(false)
end
Sass::Script::Bool.new(this.value == other.value)
end
# The SassScript `>` operation.
@ -253,7 +263,7 @@ module Sass::Script
def operate(other, operation)
this = self
if [:+, :-].include?(operation)
if [:+, :-, :<=, :<, :>, :>=].include?(operation)
if unitless?
this = this.coerce(other.numerator_units, other.denominator_units)
else

View File

@ -28,14 +28,17 @@ module Sass::Tree
# @return [Array<Tree::Node>] The resulting static nodes
# @see Sass::Tree
def _perform(environment)
from = @from.perform(environment).to_i
to = @to.perform(environment).to_i
range = Range.new(from, to, @exclusive)
from = @from.perform(environment)
to = @to.perform(environment)
if to.respond_to?(:coerce)
to = to.send(:coerce, from.numerator_units, from.denominator_units)
end
range = Range.new(from.to_i, to.to_i, @exclusive)
children = []
environment = Sass::Environment.new(environment)
range.each do |i|
environment.set_local_var(@var, Sass::Script::Number.new(i))
environment.set_local_var(@var, Sass::Script::Number.new(i, from.numerator_units, from.denominator_units))
children += perform_children(environment)
end
children

View File

@ -76,8 +76,10 @@ class SassEngineTest < Test::Unit::TestCase
"@if false\n@else if " => "Invalid else directive '@else if': expected 'if <expr>'.",
"a\n !b = 12\nc\n d = !b" => 'Undefined variable: "!b".',
"=foo\n !b = 12\nc\n +foo\n d = !b" => 'Undefined variable: "!b".',
'@for !a from 1 to "2"' => '"2" is not an integer.',
'@for !a from 1 to "foo"' => '"foo" is not an integer.',
'@for !a from 1 to 1.232323' => '1.232 is not an integer.',
'@for !a from 1px to 3em' => "Incompatible units: 'em' and 'px'.",
'@if' => "Invalid if directive '@if': expected expression.",
'@while' => "Invalid while directive '@while': expected expression.",
'@debug' => "Invalid debug directive '@debug': expected expression.",