sass 3.1.0.alpha.4 → 3.1.0.alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/EDGE_GEM_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/sass/script/color.rb +2 -1
- data/lib/sass/script/literal.rb +1 -1
- data/lib/sass/script/number.rb +12 -9
- data/lib/sass/tree/rule_node.rb +1 -1
- data/lib/sass/util.rb +14 -1
- data/test/sass/script_test.rb +12 -1
- metadata +2 -2
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.0.alpha.
|
1
|
+
3.1.0.alpha.5
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.0.alpha.
|
1
|
+
3.1.0.alpha.5
|
data/lib/sass/script/color.rb
CHANGED
data/lib/sass/script/literal.rb
CHANGED
@@ -117,7 +117,7 @@ MSG
|
|
117
117
|
# @return [Script::String] A string containing both literals
|
118
118
|
# separated by `", "`
|
119
119
|
def comma(other)
|
120
|
-
Sass::Script::String.new("#{self.to_s}
|
120
|
+
Sass::Script::String.new("#{self.to_s},#{' ' unless options[:style] == :compressed}#{other.to_s}")
|
121
121
|
end
|
122
122
|
|
123
123
|
# The SassScript `=` operation
|
data/lib/sass/script/number.rb
CHANGED
@@ -248,15 +248,7 @@ module Sass::Script
|
|
248
248
|
#
|
249
249
|
# @return [String] The representation
|
250
250
|
def inspect(opts = {})
|
251
|
-
value
|
252
|
-
if self.value.is_a?(Float) && (self.value.infinite? || self.value.nan?)
|
253
|
-
self.value
|
254
|
-
elsif int?
|
255
|
-
self.value.to_i
|
256
|
-
else
|
257
|
-
(self.value * PRECISION).round / PRECISION
|
258
|
-
end
|
259
|
-
"#{value}#{unit_str}"
|
251
|
+
"#{self.class.round(self.value)}#{unit_str}"
|
260
252
|
end
|
261
253
|
alias_method :to_sass, :inspect
|
262
254
|
|
@@ -334,6 +326,17 @@ module Sass::Script
|
|
334
326
|
|
335
327
|
private
|
336
328
|
|
329
|
+
# @private
|
330
|
+
def self.round(num)
|
331
|
+
if num.is_a?(Float) && (num.infinite? || num.nan?)
|
332
|
+
num
|
333
|
+
elsif num % 1 == 0.0
|
334
|
+
num.to_i
|
335
|
+
else
|
336
|
+
(num * PRECISION).round / PRECISION
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
337
340
|
def operate(other, operation)
|
338
341
|
this = self
|
339
342
|
if [:+, :-, :<=, :<, :>, :>=].include?(operation)
|
data/lib/sass/tree/rule_node.rb
CHANGED
@@ -134,7 +134,7 @@ module Sass::Tree
|
|
134
134
|
per_rule_indent, total_indent = [:nested, :expanded].include?(style) ? [rule_indent, ''] : ['', rule_indent]
|
135
135
|
|
136
136
|
total_rule = total_indent + resolved_rules.members.
|
137
|
-
map {|seq| seq.to_a.join.gsub(
|
137
|
+
map {|seq| seq.to_a.join.gsub(/([^,])\n/m, style == :compressed ? '\1 ' : "\\1\n")}.
|
138
138
|
join(rule_separator).split("\n").map do |line|
|
139
139
|
per_rule_indent + line.strip
|
140
140
|
end.join(line_separator)
|
data/lib/sass/util.rb
CHANGED
@@ -33,7 +33,7 @@ module Sass
|
|
33
33
|
# @param arr [Array<(Object, Object)>] An array of pairs
|
34
34
|
# @return [Hash] A hash
|
35
35
|
def to_hash(arr)
|
36
|
-
arr.compact
|
36
|
+
Hash[arr.compact]
|
37
37
|
end
|
38
38
|
|
39
39
|
# Maps the keys in a hash according to a block.
|
@@ -623,6 +623,19 @@ MSG
|
|
623
623
|
set1.to_a.uniq.sort_by {|e| e.hash}.eql?(set2.to_a.uniq.sort_by {|e| e.hash})
|
624
624
|
end
|
625
625
|
|
626
|
+
# Like `Object#inspect`, but preserves non-ASCII characters rather than escaping them under Ruby 1.9.2.
|
627
|
+
# This is necessary so that the precompiled Haml template can be `#encode`d into `@options[:encoding]`
|
628
|
+
# before being evaluated.
|
629
|
+
#
|
630
|
+
# @param obj {Object}
|
631
|
+
# @return {String}
|
632
|
+
def inspect(obj)
|
633
|
+
return obj.inspect unless version_geq(::RUBY_VERSION, "1.9.2")
|
634
|
+
return ':' + inspect(obj.to_s) if obj.is_a?(Symbol)
|
635
|
+
return obj.inspect unless obj.is_a?(String)
|
636
|
+
'"' + obj.gsub(/[\x00-\x7F]+/) {|s| s.inspect[1...-1]} + '"'
|
637
|
+
end
|
638
|
+
|
626
639
|
## Static Method Stuff
|
627
640
|
|
628
641
|
# The context in which the ERB for \{#def\_static\_method} will be run.
|
data/test/sass/script_test.rb
CHANGED
@@ -79,9 +79,13 @@ class SassScriptTest < Test::Unit::TestCase
|
|
79
79
|
assert_equal "rgba(100, 100, 100, 0.75)", resolve("rgba(50, 50, 50, 0.75) * 2")
|
80
80
|
end
|
81
81
|
|
82
|
+
def test_rgba_rounding
|
83
|
+
assert_equal "rgba(10, 1, 0, 0.123)", resolve("rgba(10.0, 1.23456789, 0.0, 0.1234567)")
|
84
|
+
end
|
85
|
+
|
82
86
|
def test_compressed_colors
|
83
87
|
assert_equal "#123456", resolve("#123456", :style => :compressed)
|
84
|
-
assert_equal "rgba(1,
|
88
|
+
assert_equal "rgba(1,2,3,0.5)", resolve("rgba(1, 2, 3, 0.5)", :style => :compressed)
|
85
89
|
assert_equal "#123", resolve("#112233", :style => :compressed)
|
86
90
|
assert_equal "#000", resolve("black", :style => :compressed)
|
87
91
|
assert_equal "red", resolve("#f00", :style => :compressed)
|
@@ -91,6 +95,12 @@ class SassScriptTest < Test::Unit::TestCase
|
|
91
95
|
assert_equal "This color is #fff", resolve('"This color is #{ white }"', :style => :compressed)
|
92
96
|
end
|
93
97
|
|
98
|
+
def test_compressed_comma
|
99
|
+
# assert_equal "foo,bar,baz", resolve("foo, bar, baz", :style => :compressed)
|
100
|
+
# assert_equal "foo,#baf,baz", resolve("foo, #baf, baz", :style => :compressed)
|
101
|
+
assert_equal "foo,#baf,red", resolve("foo, #baf, #f00", :style => :compressed)
|
102
|
+
end
|
103
|
+
|
94
104
|
def test_implicit_strings
|
95
105
|
assert_equal Sass::Script::String.new("foo"), eval("foo")
|
96
106
|
assert_equal Sass::Script::String.new("foo bar"), eval("foo bar")
|
@@ -432,6 +442,7 @@ SASS
|
|
432
442
|
|
433
443
|
def eval(str, opts = {}, environment = env)
|
434
444
|
munge_filename opts
|
445
|
+
environment.options = opts
|
435
446
|
Sass::Script.parse(str, opts.delete(:line) || 1,
|
436
447
|
opts.delete(:offset) || 0, opts).perform(environment)
|
437
448
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.0.alpha.
|
4
|
+
version: 3.1.0.alpha.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Weizenbaum
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2010-09-
|
14
|
+
date: 2010-09-29 00:00:00 -04:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|