Permalink
Browse files

Merge remote branch 'origin/master'

  • Loading branch information...
nex3 committed Jun 21, 2011
2 parents 69827c0 + 61b2162 commit 09ee024a1c4dd9bea496a5e7d851ff8e5524a58c
View
@@ -5,6 +5,7 @@
/test/rails
/.sass-cache
/.haml
+/.sass
/site
*.rbc
/.sass
View
@@ -1 +1 @@
-3.1.0
+3.2.0.alpha.0
View
@@ -1 +1 @@
-Brainy Betty
+Bleeding Edge
View
@@ -3,7 +3,23 @@
* Table of contents
{:toc}
-## 3.1.0 (Unreleased)
+## 3.1.2
+
+* Fix some issues that were breaking Sass when running within Rubinius.
+* Fix some issues that were affecting Rails 3.1 integration.
+* New function `zip` allows several lists to be combined into one
+ list of lists. For example:
+ `zip(1px 1px 3px, solid dashed solid, red green blue)` becomes
+ `1px solid red, 1px dashed green, 3px solid blue`
+* New function `index` returns the list index of a value
+ within a list. For example: `index(1px solid red, solid)`
+ returns `2`. When the value is not found `false` is returned.
+
+## 3.1.1
+
+* Make sure `Sass::Plugin` is loaded at the correct time in Rails 3.
+
+## 3.1.0
* Add an {Sass::Script::Functions#invert `invert` function} that takes the inverse of colors.
View
@@ -65,6 +65,7 @@ def self.compile_file(filename, *args)
end
end
+require 'sass/logger'
require 'sass/util'
require 'sass/engine'
@@ -49,6 +49,8 @@ def _retrieve(key, version, sha)
# @param obj [Object] The object to cache.
def store(key, sha, root)
_store(key, Sass::VERSION, sha, Marshal.dump(root))
+ rescue TypeError, LoadError => e
+ Sass::Util.sass_warn "Warning. Error encountered while saving cache #{path_to(key)}: #{e}"
end
# Retrieve a {Sass::Tree::RootNode}.
@@ -59,7 +61,7 @@ def store(key, sha, root)
def retrieve(key, sha)
contents = _retrieve(key, Sass::VERSION, sha)
Marshal.load(contents) if contents
- rescue EOFError, TypeError, ArgumentError => e
+ rescue EOFError, TypeError, ArgumentError, LoadError => e
Sass::Util.sass_warn "Warning. Error encountered while reading cache #{path_to(key)}: #{e}"
end
View
@@ -326,7 +326,7 @@ def _to_tree
if @options[:cache] && key && sha
begin
old_options = root.options
- root.options = {:importer => root.options[:importer]}
+ root.options = {}
@options[:cache_store].store(key, sha, root)
ensure
root.options = old_options
@@ -581,15 +581,9 @@ def parse_property(name, parsed_name, value, prop, line)
if value.strip.empty?
expr = Sass::Script::String.new("")
else
- important = false
- if value =~ Sass::SCSS::RX::IMPORTANT
- important = true
- value = value.gsub(Sass::SCSS::RX::IMPORTANT,"")
- end
expr = parse_script(value, :offset => line.offset + line.text.index(value))
-
end
- Tree::PropNode.new(parse_interp(name), expr, important, prop)
+ Tree::PropNode.new(parse_interp(name), expr, prop)
end
def parse_variable(line)
@@ -13,7 +13,7 @@ class Filesystem < Base
# @param root [String] The root path.
# This importer will import files relative to this path.
def initialize(root)
- @root = root
+ @root = File.expand_path(root)
end
# @see Base#find_relative
@@ -45,14 +45,21 @@ def to_s
@root
end
+ def hash
+ @root.hash
+ end
+
+ def eql?(other)
+ root.eql?(other.root)
+ end
+
protected
# If a full uri is passed, this removes the root from it
# otherwise returns the name unchanged
def remove_root(name)
- root = @root.end_with?('/') ? @root : @root + '/'
- if name.index(root) == 0
- name[root.length..-1]
+ if name.index(@root + "/") == 0
+ name[(@root.length + 1)..-1]
else
name
end
@@ -77,6 +84,7 @@ def extensions
# The first element of each pair is a filename to look for;
# the second element is the syntax that file would be in (`:sass` or `:scss`).
def possible_files(name)
+ name = escape_glob_characters(name)
dirname, basename, extname = split(name)
sorted_exts = extensions.sort
syntax = extensions[extname]
@@ -85,6 +93,11 @@ def possible_files(name)
sorted_exts.map {|ext, syn| ["#{dirname}/{_,}#{basename}.#{ext}", syn]}
end
+ def escape_glob_characters(name)
+ name.gsub(/[\*\[\]\{\}\?]/) do |char|
+ "\\#{char}"
+ end
+ end
REDUNDANT_DIRECTORY = %r{#{Regexp.escape(File::SEPARATOR)}\.#{Regexp.escape(File::SEPARATOR)}}
# Given a base directory and an `@import`ed name,
@@ -116,14 +129,6 @@ def split(name)
[dirname, basename, extension]
end
- def hash
- @root.hash
- end
-
- def eql?(other)
- root.eql?(other.root)
- end
-
private
def _find(dir, name, options)
View
@@ -225,7 +225,7 @@ def to_sass_tree
class Property
def to_sass_tree
return if hide_in_sass
- Sass::Tree::PropNode.new([self], @value.to_sass_tree, false, :new)
+ Sass::Tree::PropNode.new([self], @value.to_sass_tree, :new)
end
end
View
@@ -0,0 +1,15 @@
+module Sass::Logger
+
+end
+
+require "sass/logger/log_level"
+require "sass/logger/base"
+
+module Sass
+
+ class << self
+ attr_accessor :logger
+ end
+
+ self.logger = Sass::Logger::Base.new
+end
View
@@ -0,0 +1,32 @@
+require 'sass/logger/log_level'
+
+class Sass::Logger::Base
+
+ include Sass::Logger::LogLevel
+
+ attr_accessor :log_level
+ attr_accessor :disabled
+
+ log_level :trace
+ log_level :debug
+ log_level :info
+ log_level :warn
+ log_level :error
+
+ def initialize(log_level = :debug)
+ self.log_level = log_level
+ end
+
+ def logging_level?(level)
+ !disabled && self.class.log_level?(level, log_level)
+ end
+
+ def log(level, message)
+ self._log(level, message) if logging_level?(level)
+ end
+
+ def _log(level, message)
+ Kernel::warn(message)
+ end
+
+end
@@ -0,0 +1,50 @@
+module Sass
+ module Logger
+ module LogLevel
+
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ module ClassMethods
+ def inherited(subclass)
+ subclass.log_levels = subclass.superclass.log_levels.dup
+ end
+
+ def log_levels
+ @log_levels ||= {}
+ end
+
+ def log_levels=(levels)
+ @log_levels = levels
+ end
+
+ def log_level?(level, min_level)
+ log_levels[level] >= log_levels[min_level]
+ end
+
+ def log_level(name, options = {})
+ if options[:prepend]
+ level = log_levels.values.min
+ level = level.nil? ? 0 : level - 1
+ else
+ level = log_levels.values.max
+ level = level.nil? ? 0 : level + 1
+ end
+ # (require 'ruby-debug'; debugger)
+ log_levels.update(name => level)
+ define_logger(name)
+ end
+
+ def define_logger(name, options = {})
+ class_eval %Q{
+ def #{name}(message)
+ #{options.fetch(:to, :log)}(#{name.inspect}, message)
+ end
+ }
+ end
+ end
+
+ end
+ end
+end
View
@@ -2,7 +2,7 @@
if defined?(ActiveSupport) && Sass::Util.has?(:public_method, ActiveSupport, :on_load) &&
!Sass::Util.ap_geq?('3.1.0.beta')
require 'sass/plugin/configuration'
- ActiveSupport.on_load(:before_initialize) do
+ ActiveSupport.on_load(:before_configuration) do
require 'sass'
require 'sass/plugin'
end
@@ -1299,6 +1299,49 @@ def append(list, val, separator = Sass::Script::String.new("auto"))
declare :append, [:list, :val]
declare :append, [:list, :val, :separator]
+ # Combines several lists into a single comma separated list
+ # space separated lists.
+ #
+ # The length of the resulting list is the length of the
+ # shortest list.
+ #
+ # @example
+ # zip(1px 1px 3px, solid dashed solid, red green blue)
+ # => 1px solid red, 1px dashed green, 3px solid blue
+ def zip(*lists)
+ length = nil
+ values = []
+ lists.each do |list|
+ assert_type list, :List
+ values << list.value.dup
+ length = length.nil? ? list.value.length : [length, list.value.length].min
+ end
+ values.each do |value|
+ value.slice!(length)
+ end
+ new_list_value = values.first.zip(*values[1..-1])
+ List.new(new_list_value.map{|list| List.new(list, :space)}, :comma)
+ end
+ declare :zip, [], :var_args => true
+
+
+ # Returns the position of the given value within the given
+ # list. If not found, returns false.
+ #
+ # @example
+ # index(1px solid red, solid) => 2
+ # index(1px solid red, dashed) => false
+ def index(list, value)
+ assert_type list, :List
+ index = list.value.index {|e| e.eq(value).to_bool }
+ if index
+ Number.new(index + 1)
+ else
+ Bool.new(false)
+ end
+ end
+ declare :index, [:list, :value]
+
# Returns one of two values based on the truth value of the first argument.
#
# @example
View
@@ -231,7 +231,7 @@ def token
variable || string(:double, false) || string(:single, false) || number ||
color || bool || string(:uri, false) || raw(UNICODERANGE) ||
- special_fun || ident_op || ident || op
+ special_fun || special_val || ident_op || ident || op
end
def variable
@@ -302,6 +302,11 @@ def special_fun
str1.size + str2.size]
end
+ def special_val
+ return unless scan(/!important/i)
+ [:string, Script::String.new("!important")]
+ end
+
def ident_op
return unless op = scan(REGULAR_EXPRESSIONS[:ident_op])
[OPERATORS[op]]
View
@@ -638,11 +638,9 @@ def declaration
tok!(/:/)
space, value = value!
ss
- important = tok(IMPORTANT)
- ss
require_block = tok?(/\{/)
- node = node(Sass::Tree::PropNode.new(name.flatten.compact, value, !!important, :new))
+ node = node(Sass::Tree::PropNode.new(name.flatten.compact, value, :new))
return node unless require_block
nested_properties! node, space
View
@@ -119,7 +119,7 @@ def self.quote(str, flags = 0)
# We could use it for 1.9 only, but I don't want to introduce a cross-version
# behavior difference.
# In any case, almost all CSS idents will be matched by this.
- STATIC_VALUE = /(-?#{NMSTART}|#{STRING_NOINTERP}|\s(?!%)|#[a-f0-9]|[,%]|#{NUM})+(?=[;}])/i
+ STATIC_VALUE = /(-?#{NMSTART}|#{STRING_NOINTERP}|\s(?!%)|#[a-f0-9]|[,%]|#{NUM}|\!important)+(?=[;}])/i
STATIC_SELECTOR = /(#{NMCHAR}|\s|[,>+*]|[:#.]#{NMSTART})+(?=[{])/i
end
Oops, something went wrong.

0 comments on commit 09ee024

Please sign in to comment.