SassyLists 0.4.7 → 0.4.8

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.8`: adding `shuffle()`
3
4
  * `0.4.7`: dramatically improving `sort()` performances and removing all its dependencies
4
5
  * `0.4.6`: fixing an issue when passing an empty list to `chunk()` and improved code quality
5
6
  * `0.4.5`: making `sort()` able to return in descending order
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.7"
9
- DATE = "2013-12-30"
8
+ VERSION = "0.4.8"
9
+ DATE = "2014-01-08"
10
10
  end
11
11
 
12
12
  module Sass::Script::Functions
@@ -0,0 +1,27 @@
1
+ // Shuffle function using Fisher-Yates method
2
+ // -------------------------------------------------------------------------------
3
+ // @documentation http://sassylists.com/documentation/#shuffle
4
+ // -------------------------------------------------------------------------------
5
+ // @alias `randomize()`
6
+ // -------------------------------------------------------------------------------
7
+ // @example shuffle(a b c d e) => b d c e a
8
+ // -------------------------------------------------------------------------------
9
+ // @param $list [List] : list
10
+ // -------------------------------------------------------------------------------
11
+ // @return [List]
12
+
13
+ @function shuffle($list) {
14
+ @for $i from -1 * length($list) through -1 {
15
+ $i: abs($i);
16
+ $j: random(length($list) - 1) + 1;
17
+ $tmp: nth($list, $i);
18
+ $list: set-nth($list, $i, nth($list, $j));
19
+ $list: set-nth($list, $j, $tmp);
20
+ }
21
+ @return $list;
22
+ }
23
+
24
+ // Alias
25
+ @function randomize($list) {
26
+ @return shuffle($list);
27
+ }
@@ -43,13 +43,7 @@
43
43
  }
44
44
  }
45
45
 
46
- $less: sort($less);
47
- $large: sort($large);
48
-
49
- $result: join($less, $equal);
50
- $result: join($result, $large);
51
-
52
- @return $result;
46
+ @return join(join(sort($less), $equal), sort($large));
53
47
  }
54
48
 
55
49
  @return $list;
@@ -58,4 +52,4 @@
58
52
  // Alias
59
53
  @function order($list) {
60
54
  @return sort($list);
61
- }
55
+ }
@@ -27,8 +27,9 @@
27
27
  @import "SassyLists/replace";
28
28
  @import "SassyLists/replace-nth";
29
29
  @import "SassyLists/reverse";
30
+ @import "SassyLists/shuffle";
30
31
  @import "SassyLists/slice";
31
32
  @import "SassyLists/sort";
32
33
  @import "SassyLists/sum";
33
34
  @import "SassyLists/to-string";
34
- @import "SassyLists/union";
35
+ @import "SassyLists/union";
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.7
4
+ version: 0.4.8
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-30 00:00:00.000000000 Z
12
+ date: 2014-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sass
@@ -73,6 +73,7 @@ files:
73
73
  - stylesheets/SassyLists/_replace-nth.scss
74
74
  - stylesheets/SassyLists/_replace.scss
75
75
  - stylesheets/SassyLists/_reverse.scss
76
+ - stylesheets/SassyLists/_shuffle.scss
76
77
  - stylesheets/SassyLists/_slice.scss
77
78
  - stylesheets/SassyLists/_sort.scss
78
79
  - stylesheets/SassyLists/_sum.scss