Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'sass-only'

* sass-only:
  Fix some numeric rounding issues in ruby 1.9.2
  fix 1.9.2 issue in the staleness checker.
  fix some test running issues in 1.9.2
  • Loading branch information...
commit 9819c420487624dcc1d0a0725fa7cc97a25abec0 2 parents 29062a8 + 29cf7a6
@chriseppstein authored
View
1  Rakefile
@@ -12,6 +12,7 @@ require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << 'lib'
+ t.libs << 'test'
test_files = FileList[scope('test/**/*_test.rb')]
test_files.exclude(scope('test/rails/*'))
test_files.exclude(scope('test/plugins/*'))
View
5 lib/sass/plugin/staleness_checker.rb
@@ -90,7 +90,10 @@ def dependencies_stale?(uri, importer, css_mtime)
return true
end
end
- timestamps[css_mtime] = dependencies(uri, importer).any?(&dependency_updated?(css_mtime))
+ checker = dependency_updated?(css_mtime)
+ timestamps[css_mtime] = dependencies(uri, importer).any? do |dep|
+ checker.call(*dep)
+ end
rescue Sass::SyntaxError
# If there's an error finding dependencies, default to recompiling.
true
View
2  lib/sass/script/color.rb
@@ -401,7 +401,7 @@ def smallest
end
def rgba_str
- "rgba(#{rgb.join(', ')}, #{alpha % 1 == 0.0 ? alpha.to_i : alpha})"
+ "rgba(#{rgb.join(', ')}, #{Sass::Util.tolerate(alpha)})"
end
def hex_str
View
8 lib/sass/script/number.rb
@@ -35,12 +35,6 @@ class Number < Literal
# @return [Boolean, nil]
attr_accessor :original
- # The precision with which numbers will be printed to CSS files.
- # For example, if this is `1000.0`,
- # `3.1415926` will be printed as `3.142`.
- # @api public
- PRECISION = 1000.0
-
# @param value [Numeric] The value of the number
# @param numerator_units [Array<String>] See \{#numerator\_units}
# @param denominator_units [Array<String>] See \{#denominator\_units}
@@ -254,7 +248,7 @@ def inspect(opts = {})
elsif int?
self.value.to_i
else
- (self.value * PRECISION).round / PRECISION
+ Sass::Util.tolerate(self.value)
end
"#{value}#{unit_str}"
end
View
14 lib/sass/util.rb
@@ -623,6 +623,20 @@ def set_eql?(set1, set2)
set1.to_a.uniq.sort_by {|e| e.hash}.eql?(set2.to_a.uniq.sort_by {|e| e.hash})
end
+ # The precision with which numbers will be printed to CSS files.
+ # For example, if this is `1000.0`,
+ # `3.1415926` will be printed as `3.142`.
+ # @api public
+ PRECISION = 1000.0
+
+ # Round to the nearest decimal point digit
+ # @param number - the number to tolerate
+ # @param precision - a multiple of 10
+ def tolerate(number, precision = PRECISION)
+ n = (number * precision).round / precision.to_f
+ n % 1 == 0 ? n.to_i : n
+ end
+
## Static Method Stuff
# The context in which the ERB for \{#def\_static\_method} will be run.
View
2  test/sass/functions_test.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
require 'test/unit'
-require File.dirname(__FILE__) + '/../test_helper'
+require 'test_helper'
require 'sass/script'
module Sass::Script::Functions::UserFunctions
Please sign in to comment.
Something went wrong with that request. Please try again.