sass 3.2.0.alpha.6 → 3.2.0.alpha.7
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/REVISION +1 -1
- data/VERSION +1 -1
- data/lib/sass/script/functions.rb +43 -0
- data/test/sass/functions_test.rb +13 -0
- metadata +2 -2
data/REVISION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
743da172ee789518d2e99eecb0fdf7f12fea1ee3
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.2.0.alpha.
|
1
|
+
3.2.0.alpha.7
|
@@ -1299,6 +1299,49 @@ module Sass::Script
|
|
1299
1299
|
declare :append, [:list, :val]
|
1300
1300
|
declare :append, [:list, :val, :separator]
|
1301
1301
|
|
1302
|
+
# Combines several lists into a single comma separated list
|
1303
|
+
# space separated lists.
|
1304
|
+
#
|
1305
|
+
# The length of the resulting list is the length of the
|
1306
|
+
# shortest list.
|
1307
|
+
#
|
1308
|
+
# @example
|
1309
|
+
# zip(1px 1px 3px, solid dashed solid, red green blue)
|
1310
|
+
# => 1px solid red, 1px dashed green, 3px solid blue
|
1311
|
+
def zip(*lists)
|
1312
|
+
length = nil
|
1313
|
+
values = []
|
1314
|
+
lists.each do |list|
|
1315
|
+
assert_type list, :List
|
1316
|
+
values << list.value.dup
|
1317
|
+
length = length.nil? ? list.value.length : [length, list.value.length].min
|
1318
|
+
end
|
1319
|
+
values.each do |value|
|
1320
|
+
value.slice!(length)
|
1321
|
+
end
|
1322
|
+
new_list_value = values.first.zip(*values[1..-1])
|
1323
|
+
List.new(new_list_value.map{|list| List.new(list, :space)}, :comma)
|
1324
|
+
end
|
1325
|
+
declare :zip, [], :var_args => true
|
1326
|
+
|
1327
|
+
|
1328
|
+
# Returns the position of the given value within the given
|
1329
|
+
# list. If not found, returns false.
|
1330
|
+
#
|
1331
|
+
# @example
|
1332
|
+
# index(1px solid red, solid) => 2
|
1333
|
+
# index(1px solid red, dashed) => false
|
1334
|
+
def index(list, value)
|
1335
|
+
assert_type list, :List
|
1336
|
+
index = list.value.index {|e| e.eq(value).to_bool }
|
1337
|
+
if index
|
1338
|
+
Number.new(index + 1)
|
1339
|
+
else
|
1340
|
+
Bool.new(false)
|
1341
|
+
end
|
1342
|
+
end
|
1343
|
+
declare :index, [:list, :value]
|
1344
|
+
|
1302
1345
|
# Returns one of two values based on the truth value of the first argument.
|
1303
1346
|
#
|
1304
1347
|
# @example
|
data/test/sass/functions_test.rb
CHANGED
@@ -965,6 +965,19 @@ MSG
|
|
965
965
|
assert_error_message("Separator name must be space, comma, or auto for `append'", "append(1, 2, baboon)")
|
966
966
|
end
|
967
967
|
|
968
|
+
def test_zip
|
969
|
+
assert_equal("1 3 5, 2 4 6", evaluate("zip(1 2, 3 4, 5 6)"))
|
970
|
+
assert_equal("1 4 7, 2 5 8", evaluate("zip(1 2 3, 4 5 6, 7 8)"))
|
971
|
+
end
|
972
|
+
|
973
|
+
def test_index
|
974
|
+
assert_equal("1", evaluate("index(1px solid blue, 1px)"))
|
975
|
+
assert_equal("2", evaluate("index(1px solid blue, solid)"))
|
976
|
+
assert_equal("3", evaluate("index(1px solid blue, #00f)"))
|
977
|
+
assert_equal("false", evaluate("index(1px solid blue, 1em)"))
|
978
|
+
assert_equal("false", evaluate("index(1px solid blue, notfound)"))
|
979
|
+
end
|
980
|
+
|
968
981
|
def test_if
|
969
982
|
assert_equal("1px", evaluate("if(true, 1px, 2px)"))
|
970
983
|
assert_equal("2px", evaluate("if(false, 1px, 2px)"))
|
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.2.0.alpha.
|
4
|
+
version: 3.2.0.alpha.7
|
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: 2011-05-
|
14
|
+
date: 2011-05-31 00:00:00 -04:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|