SassyLists 0.1.3 → 0.1.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Changelog
2
2
 
3
+ * `0.1.4`: fixing an issue with `sort()`, `is-symmetrical()`
3
4
  * `0.1.3`: fixing an issue with `sort()`
4
5
  * `0.1.2`: improving `debug()`
5
6
  * `0.1.1`: initial commit
data/lib/SassyLists.rb CHANGED
@@ -17,8 +17,8 @@ Compass::Frameworks.register('SassyLists', :path => extension_path)
17
17
  # a prerelease version
18
18
  # Date is in the form of YYYY-MM-DD
19
19
  module SassyLists
20
- VERSION = "0.1.3"
21
- DATE = "2013-10-16"
20
+ VERSION = "0.1.4"
21
+ DATE = "2013-10-25"
22
22
  end
23
23
 
24
24
  # This is where any custom SassScript should be placed. The functions will be
@@ -3,9 +3,9 @@
3
3
  * -------------------------------------------------------------------------------
4
4
  * @dependence `replace-nth()`
5
5
  * -------------------------------------------------------------------------------
6
- * @example count-values( (a, b, c, d, e) ) => a 1, b 1, c 1, d 1, e 1
7
- * @example count-values( (a, b, c, a, d, b, a, e) ) => a 3, b 2, c 1, d 1, e 1
8
- * @example count-values( a ) => a 1
6
+ * @example count-values( (a, b, c, d, e) ) => a 1, b 1, c 1, d 1, e 1
7
+ * @example count-values( (a, b, c, a, d, b, a, e) ) => a 3, b 2, c 1, d 1, e 1
8
+ * @example count-values( a ) => a 1
9
9
  * -------------------------------------------------------------------------------
10
10
  * @param $list [List] : list
11
11
  * -------------------------------------------------------------------------------
@@ -30,4 +30,4 @@
30
30
  }
31
31
 
32
32
  @return zip($keys, $counts);
33
- }
33
+ }
@@ -6,38 +6,40 @@
6
6
  * @example debug( a ) => [ a ]
7
7
  * -------------------------------------------------------------------------------
8
8
  * @param $list [List] : list
9
- * @param $type [List] : enable/disable variables type
9
+ * @param $type [Boolean] : enable/disable variables type
10
10
  * @param $root [Boolean] : strictly internal boolean for recursivity
11
11
  * -------------------------------------------------------------------------------
12
12
  * @return [String]
13
13
  */
14
- @function debug($list, $type: false, $root: true) {
15
- $result: #{"[ \A "};
14
+ @function debug($list, $type: true, $root: true) {
15
+ @if length($list) == 1 {
16
+ @return if($type, quote("(#{type-of($list)}) #{$list}"), quote("#{$list}"));
17
+ }
18
+
19
+ $result : if($type, unquote("(list:#{length($list)})[ \A "), unquote("[ \A "));
20
+ $space : if($root, "", " ");
16
21
 
17
22
  @each $item in $list {
18
- $result: $result#{" "};
23
+ $result : unquote("#{$result} ");
19
24
 
20
25
  @if length($item) > 1 {
21
- $result: $result#{debug($item, $type, false)};
26
+ $result : unquote("#{$result}#{debug($item, $type, false)}");
22
27
  }
23
28
 
24
29
  @else {
25
- $space: if(not $root, " ", "");
26
- $result: if($type,
27
- $result#{$space}#{"("}#{type-of($item)}#{") "}#{$item},
28
- $result#{$space}#{$item}
30
+ $result : if($type,
31
+ unquote("#{$result}#{$space}(#{type-of($item)}) #{$item}"),
32
+ unquote("#{$result}#{$space}#{$item}")
29
33
  );
30
34
  }
31
35
 
32
36
  @if index($list, $item) != length($list) {
33
- $result: $result#{", \A "};
37
+ $result : unquote("#{$result}, \A ");
34
38
  }
35
39
 
36
40
  }
37
41
 
38
- $result: if($root,
39
- $result#{"\A"}#{" ]"},
40
- $result#{"\A"}#{" "}#{" ]"});
42
+ $result : unquote("#{$result}\A #{$space}]");
41
43
  @return quote($result);
42
44
  }
43
45
 
@@ -47,7 +49,7 @@
47
49
  * @param $list [List] : list
48
50
  * @param $type [List] : enable/disable variables type
49
51
  */
50
- @mixin debug($list, $type: false) {
52
+ @mixin debug($list, $type: true) {
51
53
  body:before {
52
54
  content: debug($list, $type) !important;
53
55
 
@@ -64,4 +66,4 @@
64
66
  text-shadow: 0 1px white !important;
65
67
  white-space: pre-wrap !important;
66
68
  }
67
- }
69
+ }
@@ -13,11 +13,5 @@
13
13
  * @return [Boolean]
14
14
  */
15
15
  @function is-symmetrical($list) {
16
- $result: ();
17
-
18
- @each $item in $list {
19
- $result: append($result, $item, space);
20
- }
21
-
22
- @return $result == reverse($result);
23
- }
16
+ @return reverse($list) == reverse(reverse($list));
17
+ }
@@ -10,34 +10,41 @@
10
10
  * -------------------------------------------------------------------------------
11
11
  * @param $list [List] : list
12
12
  * -------------------------------------------------------------------------------
13
+ * @raise [Warning] if not unitless number found
14
+ * -------------------------------------------------------------------------------
13
15
  * @return [List]
14
16
  */
15
- @function sort($list) {
17
+ @function sort($list, $force: false) {
16
18
  $result : nth($list, 1);
17
19
 
18
20
  @if length($list) > 1 {
19
21
  @for $i from 2 through length($list) {
20
22
  $item: nth($list, $i);
21
- @if type-of($item) == number and unitless($item) {
22
- @if $item > last($result) {
23
- $result: append($result, $item);
24
- }
25
- @else {
26
- $index: 0;
27
- @for $i from length($result)*-1 through -1 {
28
- $i: abs($i);
29
- @if $item <= nth($result, $i) {
30
- $index: $i;
23
+ @if type-of($item) == number {
24
+ @if unitless($item) and $force {
25
+ @if $item > last($result) {
26
+ $result: append($result, $item);
27
+ }
28
+ @else {
29
+ $index: 0;
30
+ @for $i from length($result)*-1 through -1 {
31
+ $i: abs($i);
32
+ @if $item <= nth($result, $i) {
33
+ $index: $i;
34
+ }
31
35
  }
36
+ $result: insert-nth($result, $index, $item);
32
37
  }
33
- $result: insert-nth($result, $index, $item);
34
38
  }
35
- }
39
+ @else {
40
+ @warn "Not unitless number found. Omitted.";
41
+ }
42
+ }
36
43
  @else {
37
- @warn "Not unitless number found. Omitted.";
44
+ @warn "Not integer value found. Omitted.";
38
45
  }
39
46
  }
40
47
  }
41
48
 
42
49
  @return $result;
43
- }
50
+ }
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.1.3
4
+ version: 0.1.4
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-10-16 00:00:00.000000000 Z
12
+ date: 2013-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sass