SassyLists 0.3.0 → 0.3.1

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.3.1`: added aliases and cleaned `to-string()`
3
4
  * `0.3.0`: adding `contains()`, `flatten()`, `union()`
4
5
  * `0.2.4`: improving `debug()`
5
6
  * `0.2.3`: fixing important issues with comments
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.3.0"
9
- DATE = "2013-11-04"
8
+ VERSION = "0.3.1"
9
+ DATE = "2013-11-05"
10
10
  end
11
11
 
12
12
  module Sass::Script::Functions
@@ -1,15 +1,22 @@
1
1
  // Returns whether $list contains $value
2
2
  // -------------------------------------------------------------------------------
3
- // @documentation http://sassylists.com/documentation/#contains
3
+ // @documentation http://sassylists.com/documentation/#contain
4
4
  // -------------------------------------------------------------------------------
5
- // @example chunk(a b c, a) => true
6
- // @example chunk(a b c, z) => false
5
+ // @alias `include()`
6
+ // -------------------------------------------------------------------------------
7
+ // @example contain(a b c, a) => true
8
+ // @example contain(a b c, z) => false
7
9
  // -------------------------------------------------------------------------------
8
10
  // @param $list [List] : list
9
11
  // @param $value [Literal] : value to look for
10
12
  // -------------------------------------------------------------------------------
11
13
  // @return [Boolean]
12
14
 
13
- @function contains($list, $value) {
15
+ @function contain($list, $value) {
14
16
  @return not not index($list, $value)
15
17
  }
18
+
19
+ // Alias
20
+ @function include($list, $value) {
21
+ @return contain($list, $value);
22
+ }
@@ -2,6 +2,8 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation.html#flatten
4
4
  // -------------------------------------------------------------------------------
5
+ // @alias `unfold()`
6
+ // -------------------------------------------------------------------------------
5
7
  // @example flatten(a b (c d (e f))) => a b c d e f
6
8
  // -------------------------------------------------------------------------------
7
9
  // @param $list [List] : list
@@ -24,4 +26,9 @@
24
26
  }
25
27
 
26
28
  @return $result;
29
+ }
30
+
31
+ // Alias
32
+ @function unfold($list) {
33
+ @return flatten($list);
27
34
  }
@@ -2,6 +2,8 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation/#is-symmetrical
4
4
  // -------------------------------------------------------------------------------
5
+ // @alias `unfold()`
6
+ // -------------------------------------------------------------------------------
5
7
  // @dependence `reverse()`
6
8
  // -------------------------------------------------------------------------------
7
9
  // @example is-symmetrical(a b c d e) => false
@@ -15,3 +17,8 @@
15
17
  @function is-symmetrical($list) {
16
18
  @return reverse($list) == reverse(reverse($list));
17
19
  }
20
+
21
+ // Alias
22
+ @function is-mirror($list) {
23
+ @return is-symmetrical($list);
24
+ }
@@ -2,6 +2,8 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation/#loop
4
4
  // -------------------------------------------------------------------------------
5
+ // @alias `shift-indexes()`
6
+ // -------------------------------------------------------------------------------
5
7
  // @example loop(a b c d e) => e, a, b, c, d
6
8
  // @example loop(a b c d e, 2) => d, e, a, b, c
7
9
  // @example loop(a b c d e, -2) => c, d, e, a, b
@@ -19,4 +21,9 @@
19
21
  }
20
22
 
21
23
  @return $result;
24
+ }
25
+
26
+ // Alias
27
+ @function shift-indexes($list, $value: 1) {
28
+ @return loop($list, $value);
22
29
  }
@@ -2,8 +2,11 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation.html#purge
4
4
  // -------------------------------------------------------------------------------
5
+ // @alias `compact()`
6
+ // @alias `clean()`
7
+ // -------------------------------------------------------------------------------
5
8
  // @example purge(a null b false c) => a, b, c
6
- // @example purge(a b c) => a, b, c
9
+ // @example purge(a b c '') => a, b, c
7
10
  // -------------------------------------------------------------------------------
8
11
  // @param $list [List] : list
9
12
  // -------------------------------------------------------------------------------
@@ -13,10 +16,19 @@
13
16
  $result: ();
14
17
 
15
18
  @each $item in $list {
16
- @if $item != null and $item != false and $item != "" {
19
+ @if $item and $item != "" {
17
20
  $result: append($result, $item);
18
21
  }
19
22
  }
20
23
 
21
24
  @return $result;
25
+ }
26
+
27
+ // Aliases
28
+ @function compact($list) {
29
+ @return purge($list);
30
+ }
31
+
32
+ @function clean($list) {
33
+ @return purge($list);
22
34
  }
@@ -2,7 +2,10 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation.html#random-value
4
4
  // -------------------------------------------------------------------------------
5
- // @dependence `rand` (Ruby)
5
+ // @alias `roll()`
6
+ // @alias `luck()`
7
+ // -------------------------------------------------------------------------------
8
+ // @dependence `rand()` (Ruby)
6
9
  // -------------------------------------------------------------------------------
7
10
  // @example random-value(a b c d e) => c
8
11
  // -------------------------------------------------------------------------------
@@ -13,3 +16,12 @@
13
16
  @function random-value($list) {
14
17
  @return nth($list, random(length($list)) + 1);
15
18
  }
19
+
20
+ // Aliases
21
+ @function roll($list) {
22
+ @return random-value($list);
23
+ }
24
+
25
+ @function luck($list) {
26
+ @return random-value($list);
27
+ }
@@ -2,6 +2,8 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation/#remove-duplicates
4
4
  // -------------------------------------------------------------------------------
5
+ // @alias `unique()`
6
+ // -------------------------------------------------------------------------------
5
7
  // @example remove-duplicates(a b a c b d c e) => a, b, c, d, e
6
8
  // @example remove-duplicates(a b (c c c), true) => a, b, c
7
9
  // -------------------------------------------------------------------------------
@@ -26,4 +28,9 @@
26
28
  }
27
29
 
28
30
  @return $result;
31
+ }
32
+
33
+ // Alias
34
+ @function unique($list, $recursive: false) {
35
+ @return remove-duplicates($list, $recursive);
29
36
  }
@@ -2,6 +2,8 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation/#remove-nth
4
4
  // -------------------------------------------------------------------------------
5
+ // @alias `without-nth()`
6
+ // -------------------------------------------------------------------------------
5
7
  // @dependence `replace-nth()`
6
8
  // -------------------------------------------------------------------------------
7
9
  // @example remove-nth(a b c, 2) => a, c
@@ -21,4 +23,9 @@
21
23
 
22
24
  @function remove-nth($list, $index) {
23
25
  @return replace-nth($list, $index, "");
26
+ }
27
+
28
+ // Alias
29
+ @function without-nth($list, $index) {
30
+ @return remove-nth($list, $index);
24
31
  }
@@ -2,6 +2,8 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation/#remove
4
4
  // -------------------------------------------------------------------------------
5
+ // @alias `without()`
6
+ // -------------------------------------------------------------------------------
5
7
  // @dependence `replace()`
6
8
  // -------------------------------------------------------------------------------
7
9
  // @example remove(a b c, b) => a, c
@@ -17,4 +19,9 @@
17
19
 
18
20
  @function remove($list, $value, $recursive: false) {
19
21
  @return replace($list, $value, "", $recursive);
22
+ }
23
+
24
+ // Alias
25
+ @function without($list, $value, $recursive: false) {
26
+ @return remove($list, $value, $recursive);
20
27
  }
@@ -2,6 +2,8 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation/#reverse
4
4
  // -------------------------------------------------------------------------------
5
+ // @alias `mirror()`
6
+ // -------------------------------------------------------------------------------
5
7
  // @example reverse(a b c) => c, b, a
6
8
  // @example reverse(a b (c a)) => c a, b, a
7
9
  // @example reverse(a b (c a), true) => a c, b, a
@@ -27,4 +29,9 @@
27
29
  }
28
30
 
29
31
  @return $result;
32
+ }
33
+
34
+ // Alias
35
+ @function mirror($list, $recursive: false) {
36
+ @return reverse($list, $recursive);
30
37
  }
@@ -2,6 +2,8 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation/#sort
4
4
  // -------------------------------------------------------------------------------
5
+ // @alias `order()`
6
+ // -------------------------------------------------------------------------------
5
7
  // @dependence `last()`
6
8
  // @dependence `insert-nth()`
7
9
  // -------------------------------------------------------------------------------
@@ -60,3 +62,8 @@
60
62
 
61
63
  @return $result;
62
64
  }
65
+
66
+ // Alias
67
+ @function order($list, $force: false) {
68
+ @return sort($list, $force);
69
+ }
@@ -2,6 +2,8 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation/#to-string
4
4
  // -------------------------------------------------------------------------------
5
+ // @alias `stringify()`
6
+ // -------------------------------------------------------------------------------
5
7
  // @example to-string(a b c) => abc
6
8
  // @example to-string(a (b c) d) => abcd
7
9
  // @example to-string(a b c, '-') => a-b-c
@@ -13,18 +15,23 @@
13
15
  // @return [String]
14
16
 
15
17
  @function to-string($list, $glue: '', $root: true) {
16
- $result: null;
18
+ $result: '';
17
19
 
18
20
  @each $item in $list {
19
21
  @if length($item) > 1 {
20
- $result: $result#{to-string($item, $glue, false)};
22
+ $result: $result + to-string($item, $glue, false);
21
23
  }
22
24
 
23
25
  @else {
24
26
  $condition: index($list, $item) != length($list) or not $root;
25
- $result: if($condition, $result#{$item}#{$glue}, $result#{$item});
27
+ $result: if($condition, $result + $item + $glue, $result + $item);
26
28
  }
27
29
  }
28
30
 
29
31
  @return quote($result);
32
+ }
33
+
34
+ // Alias
35
+ @function stringify($list, $glue: '', $root: true) {
36
+ @return to-string($list, $glue, $root);
30
37
  }
@@ -2,6 +2,8 @@
2
2
  // -------------------------------------------------------------------------------
3
3
  // @documentation http://sassylists.com/documentation/#union
4
4
  // -------------------------------------------------------------------------------
5
+ // @alias `merge()`
6
+ // -------------------------------------------------------------------------------
5
7
  // @dependence `flatten()`
6
8
  // @dependence `remove-duplicates()`
7
9
  // -------------------------------------------------------------------------------
@@ -13,4 +15,9 @@
13
15
 
14
16
  @function union($lists...) {
15
17
  @return remove-duplicates(flatten($lists));
18
+ }
19
+
20
+ // Alias
21
+ @function merge($lists...) {
22
+ @return union($lists...);
16
23
  }
@@ -7,7 +7,7 @@
7
7
  // -------------------------------------------------------------------------------
8
8
 
9
9
  @import "SassyLists/chunk";
10
- @import "SassyLists/contains";
10
+ @import "SassyLists/contain";
11
11
  @import "SassyLists/count-values";
12
12
  @import "SassyLists/debug";
13
13
  @import "SassyLists/first";
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.3.0
4
+ version: 0.3.1
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-11-04 00:00:00.000000000 Z
12
+ date: 2013-11-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sass
@@ -53,7 +53,7 @@ files:
53
53
  - CHANGELOG.md
54
54
  - lib/SassyLists.rb
55
55
  - stylesheets/SassyLists/_chunk.scss
56
- - stylesheets/SassyLists/_contains.scss
56
+ - stylesheets/SassyLists/_contain.scss
57
57
  - stylesheets/SassyLists/_count-values.scss
58
58
  - stylesheets/SassyLists/_debug.scss
59
59
  - stylesheets/SassyLists/_first.scss