SassyLists 0.3.5 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Changelog
2
2
 
3
+ * `0.4.0`: added `intersection()`
3
4
  * `0.3.5`: improving `debug()`, `to-string()` and `chunk()`
4
5
  * `0.3.4`: fixing a minor issue in `insert-nth()`, `replace-nth()` and `prepend()`
5
6
  * `0.3.3`: removed dependence to `purge()` from all functions; fixed an issue with `sort()`; fixed an issue with error messages
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.5"
9
- DATE = "2013-11-09"
8
+ VERSION = "0.4.0"
9
+ DATE = "2013-11-11"
10
10
  end
11
11
 
12
12
  module Sass::Script::Functions
@@ -15,8 +15,8 @@
15
15
  @return $list;
16
16
  }
17
17
 
18
- $index : 1;
19
- $result : ();
18
+ $index: 1;
19
+ $result: ();
20
20
 
21
21
  @for $i from 1 through ceil(length($list) / $size) {
22
22
  $tmp: ();
@@ -12,20 +12,20 @@
12
12
  // @return [List]
13
13
 
14
14
  @function count-values($list) {
15
- $keys : ();
16
- $counts : ();
15
+ $keys: ();
16
+ $counts: ();
17
17
 
18
18
  @each $item in $list {
19
19
  $index: index($keys, $item);
20
20
 
21
21
  @if not $index {
22
- $keys : append($keys, $item);
23
- $counts : append($counts, 1);
22
+ $keys: append($keys, $item);
23
+ $counts: append($counts, 1);
24
24
  }
25
25
 
26
26
  @else {
27
- $count : nth($counts, $index) + 1;
28
- $counts : replace-nth($counts, $index, $count);
27
+ $count: nth($counts, $index) + 1;
28
+ $counts: replace-nth($counts, $index, $count);
29
29
  }
30
30
  }
31
31
 
@@ -12,9 +12,9 @@
12
12
  // @return [String]
13
13
 
14
14
  @function debug($list, $pre: false, $level: 1) {
15
- $tab : " ";
16
- $indent : "";
17
- $break : if($pre, "\A ", "");
15
+ $tab: " ";
16
+ $indent: "";
17
+ $break: if($pre, "\A ", "");
18
18
 
19
19
  @if length($list) == 0 {
20
20
  @return "( )";
@@ -25,7 +25,7 @@
25
25
  }
26
26
 
27
27
  @for $i from 1 to $level {
28
- $indent : $indent + $tab;
28
+ $indent: $indent + $tab;
29
29
  }
30
30
 
31
31
  $result: "[" + $break;
@@ -0,0 +1,29 @@
1
+ // Returns a list of shared value from $lists minus duplicates
2
+ // -------------------------------------------------------------------------------
3
+ // @documentation http://sassylists.com/documentation/#intersection
4
+ // -------------------------------------------------------------------------------
5
+ // @dependence `count-values()`
6
+ // @dependence `flatten()`
7
+ // -------------------------------------------------------------------------------
8
+ // @example intersection(a b c, a c d, e d f) => a c d
9
+ // -------------------------------------------------------------------------------
10
+ // @param $lists [ArgList] : lists
11
+ // -------------------------------------------------------------------------------
12
+ // @return [List]
13
+
14
+ @function intersection($lists...) {
15
+ @if length($lists) == 1 {
16
+ @return $lists;
17
+ }
18
+
19
+ $list: count-values(flatten($lists));
20
+ $result: ();
21
+
22
+ @each $item in $list {
23
+ @if nth($item, 2) == length($lists) {
24
+ $result: append($result, nth($item, 1));
25
+ }
26
+ }
27
+
28
+ @return $result;
29
+ }
@@ -13,6 +13,7 @@
13
13
  @import "SassyLists/first";
14
14
  @import "SassyLists/flatten";
15
15
  @import "SassyLists/insert-nth";
16
+ @import "SassyLists/intersection";
16
17
  @import "SassyLists/is-symmetrical";
17
18
  @import "SassyLists/last";
18
19
  @import "SassyLists/last-index";
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.5
4
+ version: 0.4.0
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-09 00:00:00.000000000 Z
12
+ date: 2013-11-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sass
@@ -59,6 +59,7 @@ files:
59
59
  - stylesheets/SassyLists/_first.scss
60
60
  - stylesheets/SassyLists/_flatten.scss
61
61
  - stylesheets/SassyLists/_insert-nth.scss
62
+ - stylesheets/SassyLists/_intersection.scss
62
63
  - stylesheets/SassyLists/_is-symmetrical.scss
63
64
  - stylesheets/SassyLists/_last-index.scss
64
65
  - stylesheets/SassyLists/_last.scss