SassyLists 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +2 -1
- data/lib/SassyLists.rb +2 -2
- data/stylesheets/SassyLists/_chunk.scss +8 -1
- data/stylesheets/SassyLists/_contain.scss +1 -1
- data/stylesheets/SassyLists/_debug.scss +4 -4
- data/stylesheets/SassyLists/_insert-nth.scss +11 -15
- data/stylesheets/SassyLists/_replace-nth.scss +10 -14
- data/stylesheets/SassyLists/_slice.scss +13 -17
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
* `0.4.
|
3
|
+
* `0.4.6`: fixing an issue when passing an empty list to `chunk()` and improved code quality
|
4
|
+
* `0.4.5`: making `sort()` able to return in descending order
|
4
5
|
* `0.4.4`: fixing a typo in `purge()`
|
5
6
|
* `0.4.3`: improving `insert-nth()`, `prepend()`, `replace-nth()` and `replace()` to prevent from adding empty lists
|
6
7
|
* `0.4.2`: improving `insert-nth()` and cleaning some indentation issues
|
data/lib/SassyLists.rb
CHANGED
@@ -5,8 +5,8 @@ Compass::Frameworks.register('SassyLists', :path => extension_path)
|
|
5
5
|
# Version is a number. If a version contains alphas, it will be created as a prerelease version
|
6
6
|
# Date is in the form of YYYY-MM-DD
|
7
7
|
module SassyLists
|
8
|
-
VERSION = "0.4.
|
9
|
-
DATE = "2013-12-
|
8
|
+
VERSION = "0.4.6"
|
9
|
+
DATE = "2013-12-07"
|
10
10
|
end
|
11
11
|
|
12
12
|
module Sass::Script::Functions
|
@@ -8,9 +8,16 @@
|
|
8
8
|
// @param $list [List] : list
|
9
9
|
// @param $size [Number] : length of lists
|
10
10
|
// -------------------------------------------------------------------------------
|
11
|
-
// @
|
11
|
+
// @raise [Error] if $list is empty
|
12
|
+
// -------------------------------------------------------------------------------
|
13
|
+
// @return [List] | false
|
12
14
|
|
13
15
|
@function chunk($list, $size) {
|
16
|
+
@if $list == () {
|
17
|
+
@warn "Trying to chunk empty list in `chunk`.";
|
18
|
+
@return false;
|
19
|
+
}
|
20
|
+
|
14
21
|
@if $size >= length($list) {
|
15
22
|
@return $list;
|
16
23
|
}
|
@@ -12,10 +12,6 @@
|
|
12
12
|
// @return [String]
|
13
13
|
|
14
14
|
@function debug($list, $pre: false, $level: 1) {
|
15
|
-
$tab: " ";
|
16
|
-
$indent: "";
|
17
|
-
$break: if($pre, "\A ", "");
|
18
|
-
|
19
15
|
@if length($list) == 0 {
|
20
16
|
@return "( )";
|
21
17
|
}
|
@@ -24,6 +20,10 @@
|
|
24
20
|
@return if($pre, "(" + type-of($list) + ") ", "") + $list;
|
25
21
|
}
|
26
22
|
|
23
|
+
$tab: " ";
|
24
|
+
$indent: "";
|
25
|
+
$break: if($pre, "\A ", "");
|
26
|
+
|
27
27
|
@for $i from 1 to $level {
|
28
28
|
$indent: $indent + $tab;
|
29
29
|
}
|
@@ -18,34 +18,30 @@
|
|
18
18
|
// @return [List] | false
|
19
19
|
|
20
20
|
@function insert-nth($list, $index, $value) {
|
21
|
-
$result: false;
|
22
|
-
|
23
21
|
@if type-of($index) != number {
|
24
22
|
@warn "List index #{$index} is not a number for `insert-nth`.";
|
25
|
-
@return
|
23
|
+
@return false;
|
26
24
|
}
|
27
25
|
|
28
|
-
@
|
26
|
+
@if $index < 1 {
|
29
27
|
@warn "List index #{$index} must be a non-zero integer for `insert-nth`";
|
30
|
-
@return
|
28
|
+
@return false;
|
31
29
|
}
|
32
30
|
|
33
|
-
@
|
31
|
+
@if $index > length($list) {
|
34
32
|
@return append($list, $value);
|
35
33
|
}
|
36
34
|
|
37
|
-
|
38
|
-
$result: ();
|
35
|
+
$result: ();
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
}
|
37
|
+
@for $i from 1 through length($list) {
|
38
|
+
@if $i == $index {
|
39
|
+
@if $value and $value != "" and $value != () {
|
40
|
+
$result: append($result, $value);
|
45
41
|
}
|
46
|
-
|
47
|
-
$result: append($result, nth($list, $i));
|
48
42
|
}
|
43
|
+
|
44
|
+
$result: append($result, nth($list, $i));
|
49
45
|
}
|
50
46
|
|
51
47
|
@return $result;
|
@@ -19,31 +19,27 @@
|
|
19
19
|
// @return [List] | false
|
20
20
|
|
21
21
|
@function replace-nth($list, $index, $value) {
|
22
|
-
$result: false;
|
23
|
-
|
24
22
|
@if type-of($index) != number {
|
25
23
|
@warn "List index #{$index} is not a number for `replace-nth`/`remove-nth`.";
|
26
|
-
@return
|
24
|
+
@return false;
|
27
25
|
}
|
28
26
|
|
29
|
-
@
|
27
|
+
@if $index == 0 {
|
30
28
|
@warn "List index 0 must be a non-zero integer for `replace-nth`/`remove-nth`.";
|
31
|
-
@return
|
29
|
+
@return false;
|
32
30
|
}
|
33
31
|
|
34
|
-
@
|
32
|
+
@if abs($index) > length($list) {
|
35
33
|
@warn "List index is #{$index} but list is only #{length($list)} item long for `replace-nth`/`remove-nth`.";
|
36
|
-
@return
|
34
|
+
@return false;
|
37
35
|
}
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
$index: if($index < 0, length($list) + $index + 1, $index);
|
37
|
+
$result: ();
|
38
|
+
$index: if($index < 0, length($list) + $index + 1, $index);
|
42
39
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
}
|
40
|
+
@for $i from 1 through length($list) {
|
41
|
+
@if $value and $value != "" and $value != () {
|
42
|
+
$result: append($result, if($i == $index, $value, nth($list, $i)));
|
47
43
|
}
|
48
44
|
}
|
49
45
|
|
@@ -22,39 +22,35 @@
|
|
22
22
|
// @return [List] | false
|
23
23
|
|
24
24
|
@function slice($list, $start: 1, $end: length($list)) {
|
25
|
-
$result: false;
|
26
|
-
|
27
25
|
@if type-of($start) != number or type-of($end) != number {
|
28
26
|
@warn "List indexes #{$start} and #{$end} must be numbers for `slice`.";
|
29
|
-
@return
|
27
|
+
@return false;
|
30
28
|
}
|
31
29
|
|
32
|
-
@
|
30
|
+
@if $start > $end {
|
33
31
|
@warn "Start index is #{$start} but has to be lesser than or equals to the end index (#{$end}) for `slice`.";
|
34
|
-
@return
|
32
|
+
@return false;
|
35
33
|
}
|
36
34
|
|
37
|
-
@
|
35
|
+
@if $start < 1 or $end < 1 {
|
38
36
|
@warn "List indexes must be non-zero integers for `slice`.";
|
39
|
-
@return
|
37
|
+
@return false;
|
40
38
|
}
|
41
39
|
|
42
|
-
@
|
40
|
+
@if $start > length($list) {
|
43
41
|
@warn "Start index is #{$start} but list is only #{length($list)} items long for `slice`.";
|
44
|
-
@return
|
42
|
+
@return false;
|
45
43
|
}
|
46
44
|
|
47
|
-
@
|
45
|
+
@if $end > length($list) {
|
48
46
|
@warn "End index is #{$end} but list is only #{length($list)} items long for `slice`.";
|
49
|
-
@return
|
47
|
+
@return false;
|
50
48
|
}
|
51
49
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
$result: append($result, nth($list, $i));
|
57
|
-
}
|
50
|
+
$result: ();
|
51
|
+
|
52
|
+
@for $i from $start through $end {
|
53
|
+
$result: append($result, nth($list, $i));
|
58
54
|
}
|
59
55
|
|
60
56
|
@return $result;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: SassyLists
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sass
|