ListFunctions 0.1 → 0.2

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.
Files changed (46) hide show
  1. data/lib/ListFunctions.rb +29 -29
  2. data/stylesheets/ListFunctions/_chunk.scss +32 -32
  3. data/stylesheets/ListFunctions/_count-values.scss +32 -32
  4. data/stylesheets/ListFunctions/_debug.scss +34 -34
  5. data/stylesheets/ListFunctions/_first.scss +12 -12
  6. data/stylesheets/ListFunctions/_insert-nth.scss +51 -51
  7. data/stylesheets/ListFunctions/_is-symmetrical.scss +22 -22
  8. data/stylesheets/ListFunctions/_last-index.scss +24 -24
  9. data/stylesheets/ListFunctions/_last.scss +12 -12
  10. data/stylesheets/ListFunctions/_loop.scss +20 -20
  11. data/stylesheets/ListFunctions/_prepend.scss +15 -15
  12. data/stylesheets/ListFunctions/_purge.scss +20 -20
  13. data/stylesheets/ListFunctions/_remove-duplicates.scss +29 -29
  14. data/stylesheets/ListFunctions/_remove-nth.scss +22 -22
  15. data/stylesheets/ListFunctions/_remove.scss +18 -18
  16. data/stylesheets/ListFunctions/_replace-nth.scss +49 -49
  17. data/stylesheets/ListFunctions/_replace.scss +31 -31
  18. data/stylesheets/ListFunctions/_reverse.scss +29 -29
  19. data/stylesheets/ListFunctions/_slice.scss +59 -59
  20. data/stylesheets/ListFunctions/_sort.scss +42 -0
  21. data/stylesheets/ListFunctions/_sum.scss +32 -32
  22. data/stylesheets/ListFunctions/_to-string.scss +28 -28
  23. data/stylesheets/_ListFunctions.scss +94 -90
  24. data/templates/project/sass/ListFunctions/_chunk.scss +32 -32
  25. data/templates/project/sass/ListFunctions/_count-values.scss +32 -32
  26. data/templates/project/sass/ListFunctions/_debug.scss +34 -34
  27. data/templates/project/sass/ListFunctions/_first.scss +12 -12
  28. data/templates/project/sass/ListFunctions/_insert-nth.scss +51 -51
  29. data/templates/project/sass/ListFunctions/_is-symmetrical.scss +22 -22
  30. data/templates/project/sass/ListFunctions/_last-index.scss +24 -24
  31. data/templates/project/sass/ListFunctions/_last.scss +12 -12
  32. data/templates/project/sass/ListFunctions/_loop.scss +20 -20
  33. data/templates/project/sass/ListFunctions/_prepend.scss +15 -15
  34. data/templates/project/sass/ListFunctions/_purge.scss +20 -20
  35. data/templates/project/sass/ListFunctions/_remove-duplicates.scss +29 -29
  36. data/templates/project/sass/ListFunctions/_remove-nth.scss +22 -22
  37. data/templates/project/sass/ListFunctions/_remove.scss +18 -18
  38. data/templates/project/sass/ListFunctions/_replace-nth.scss +49 -49
  39. data/templates/project/sass/ListFunctions/_replace.scss +31 -31
  40. data/templates/project/sass/ListFunctions/_reverse.scss +29 -29
  41. data/templates/project/sass/ListFunctions/_slice.scss +59 -59
  42. data/templates/project/sass/ListFunctions/_sum.scss +32 -32
  43. data/templates/project/sass/ListFunctions/_to-string.scss +28 -28
  44. data/templates/project/sass/_ListFunctions.scss +90 -90
  45. metadata +18 -11
  46. checksums.yaml +0 -7
@@ -1,60 +1,60 @@
1
- /**
2
- * Slices $list between $start and $end
3
- * -------------------------------------------------------------------------------
4
- * @example slice( (a, b, c, d), 2, 3 ) => b, c
5
- * @example slice( (a, b, c, d), 3, 2 ) => error
6
- * @example slice( (a, b, c, d), 3, 5 ) => error
7
- * @example slice( (a, b, c, d), -1, 3 ) => error
8
- * @example slice( (a, b, c, d), 0, 3 ) => error
9
- * @example slice( (a, b, c, d), 3, 3 ) => c
10
- * -------------------------------------------------------------------------------
11
- * @param $list [List] : list
12
- * @param $start [Number] : start index
13
- * @param $end [Number] : end index
14
- * -------------------------------------------------------------------------------
15
- * @raise [Error] if $start or $end aren't integers
16
- * @raise [Error] if $start is greater than $end
17
- * @raise [Error] if $start or $end is strictly lesser than 1
18
- * @raise [Error] if $start is strictly greater than length of $list
19
- * @raise [Error] if $end is strictly greater than length of $list
20
- * -------------------------------------------------------------------------------
21
- * @return [List] | false
22
- */
23
- @function slice($list, $start: 1, $end: length($list)) {
24
- $result: false;
25
-
26
- @if type-of($start) != number or type-of($end) != number {
27
- @warn "Either $start or $end are not a number for `slice`.";
28
- @return $result;
29
- }
30
-
31
- @else if $start > $end {
32
- @warn "The start index has to be lesser than or equals to the end index for `slice`.";
33
- @return $result;
34
- }
35
-
36
- @else if $start < 1 or $end < 1 {
37
- @warn "List indexes must be non-zero integers for `slice`.";
38
- @return $result;
39
- }
40
-
41
- @else if $start > length($list) {
42
- @warn "List index is #{$start} but list is only #{length($list)} item long for `slice`.";
43
- @return $result;
44
- }
45
-
46
- @else if $end > length($list) {
47
- @warn "List index is #{$end} but list is only #{length($list)} item long for `slice`.";
48
- @return $result;
49
- }
50
-
51
- @else {
52
- $result: ();
53
-
54
- @for $i from $start through $end {
55
- $result: append($result, nth($list, $i));
56
- }
57
- }
58
-
59
- @return $result;
1
+ /**
2
+ * Slices $list between $start and $end
3
+ * -------------------------------------------------------------------------------
4
+ * @example slice( (a, b, c, d), 2, 3 ) => b, c
5
+ * @example slice( (a, b, c, d), 3, 2 ) => error
6
+ * @example slice( (a, b, c, d), 3, 5 ) => error
7
+ * @example slice( (a, b, c, d), -1, 3 ) => error
8
+ * @example slice( (a, b, c, d), 0, 3 ) => error
9
+ * @example slice( (a, b, c, d), 3, 3 ) => c
10
+ * -------------------------------------------------------------------------------
11
+ * @param $list [List] : list
12
+ * @param $start [Number] : start index
13
+ * @param $end [Number] : end index
14
+ * -------------------------------------------------------------------------------
15
+ * @raise [Error] if $start or $end aren't integers
16
+ * @raise [Error] if $start is greater than $end
17
+ * @raise [Error] if $start or $end is strictly lesser than 1
18
+ * @raise [Error] if $start is strictly greater than length of $list
19
+ * @raise [Error] if $end is strictly greater than length of $list
20
+ * -------------------------------------------------------------------------------
21
+ * @return [List] | false
22
+ */
23
+ @function slice($list, $start: 1, $end: length($list)) {
24
+ $result: false;
25
+
26
+ @if type-of($start) != number or type-of($end) != number {
27
+ @warn "Either $start or $end are not a number for `slice`.";
28
+ @return $result;
29
+ }
30
+
31
+ @else if $start > $end {
32
+ @warn "The start index has to be lesser than or equals to the end index for `slice`.";
33
+ @return $result;
34
+ }
35
+
36
+ @else if $start < 1 or $end < 1 {
37
+ @warn "List indexes must be non-zero integers for `slice`.";
38
+ @return $result;
39
+ }
40
+
41
+ @else if $start > length($list) {
42
+ @warn "List index is #{$start} but list is only #{length($list)} item long for `slice`.";
43
+ @return $result;
44
+ }
45
+
46
+ @else if $end > length($list) {
47
+ @warn "List index is #{$end} but list is only #{length($list)} item long for `slice`.";
48
+ @return $result;
49
+ }
50
+
51
+ @else {
52
+ $result: ();
53
+
54
+ @for $i from $start through $end {
55
+ $result: append($result, nth($list, $i));
56
+ }
57
+ }
58
+
59
+ @return $result;
60
60
  }
@@ -1,32 +1,32 @@
1
- /**
2
- * Sum up all unitless values in $list
3
- * -------------------------------------------------------------------------------
4
- * @example sum( (1 2 3 4 5) ) => 15
5
- * @example sum( (1 a 2 b 3) ) => 6
6
- * @example sum( (10px 3em 5%) ) => 0
7
- * @example sum( (10px 3em 5%, true) ) => 18
8
- * -------------------------------------------------------------------------------
9
- * @param $list [List] : list
10
- * @param $force [Boolean] : enable / disable parseInt
11
- * -------------------------------------------------------------------------------
12
- * @return [Number]
13
- */
14
- @function sum($list, $force: false) {
15
- $result: 0;
16
-
17
- @each $item in $list {
18
- @if type-of($item) == number {
19
-
20
- @if $force and unit($item) {
21
- $item: $item / ($item * 0 + 1);
22
- }
23
-
24
- @if unitless($item) {
25
- $result: $result + $item;
26
- }
27
-
28
- }
29
- }
30
-
31
- @return $result;
32
- }
1
+ /**
2
+ * Sum up all unitless values in $list
3
+ * -------------------------------------------------------------------------------
4
+ * @example sum( (1 2 3 4 5) ) => 15
5
+ * @example sum( (1 a 2 b 3) ) => 6
6
+ * @example sum( (10px 3em 5%) ) => 0
7
+ * @example sum( (10px 3em 5%, true) ) => 18
8
+ * -------------------------------------------------------------------------------
9
+ * @param $list [List] : list
10
+ * @param $force [Boolean] : enable / disable parseInt
11
+ * -------------------------------------------------------------------------------
12
+ * @return [Number]
13
+ */
14
+ @function sum($list, $force: false) {
15
+ $result: 0;
16
+
17
+ @each $item in $list {
18
+ @if type-of($item) == number {
19
+
20
+ @if $force and unit($item) {
21
+ $item: $item / ($item * 0 + 1);
22
+ }
23
+
24
+ @if unitless($item) {
25
+ $result: $result + $item;
26
+ }
27
+
28
+ }
29
+ }
30
+
31
+ @return $result;
32
+ }
@@ -1,29 +1,29 @@
1
- /**
2
- * Joins all elements of $list with $glue
3
- * -------------------------------------------------------------------------------
4
- * @example to-string( (a, b, c) ) => abc
5
- * @example to-string( (a, b, c), '-' ) => a-b-c
6
- * @example to-string( (a, b c, d) ) => abcd
7
- * -------------------------------------------------------------------------------
8
- * @param $list [List] : list
9
- * @param $glue [String] : value to use as a join string
10
- * @param $is-nested [Boolean] : strictly internal boolean for recursivity
11
- * -------------------------------------------------------------------------------
12
- * @return [String]
13
- */
14
- @function to-string($list, $glue: '', $is-nested: false) {
15
- $result: null;
16
-
17
- @each $item in $list {
18
- @if length($item) > 1 {
19
- $result: $result#{to-string($item, $glue, true)};
20
- }
21
-
22
- @else {
23
- $condition: index($list, item) != length($list) or $is-nested;
24
- $result: if($condition, $result#{$item}#{$glue}, $result#{$item});
25
- }
26
- }
27
-
28
- @return $result;
1
+ /**
2
+ * Joins all elements of $list with $glue
3
+ * -------------------------------------------------------------------------------
4
+ * @example to-string( (a, b, c) ) => abc
5
+ * @example to-string( (a, b, c), '-' ) => a-b-c
6
+ * @example to-string( (a, b c, d) ) => abcd
7
+ * -------------------------------------------------------------------------------
8
+ * @param $list [List] : list
9
+ * @param $glue [String] : value to use as a join string
10
+ * @param $is-nested [Boolean] : strictly internal boolean for recursivity
11
+ * -------------------------------------------------------------------------------
12
+ * @return [String]
13
+ */
14
+ @function to-string($list, $glue: '', $is-nested: false) {
15
+ $result: null;
16
+
17
+ @each $item in $list {
18
+ @if length($item) > 1 {
19
+ $result: $result#{to-string($item, $glue, true)};
20
+ }
21
+
22
+ @else {
23
+ $condition: index($list, item) != length($list) or $is-nested;
24
+ $result: if($condition, $result#{$item}#{$glue}, $result#{$item});
25
+ }
26
+ }
27
+
28
+ @return $result;
29
29
  }
@@ -1,90 +1,90 @@
1
- /* ------------------------------------------------------------------------------- *
2
- * A couple of advanced Sass list functions
3
- * ------------------------------------------------------------------------------- *
4
- *
5
- * chunk($list, $size)
6
- * Chunk $list into $size large lists
7
- *
8
- * count-values($list)
9
- * Count the number of occurrences of each value of $list
10
- *
11
- * debug($list)
12
- * Returns $list as a string
13
- *
14
- * first($list)
15
- * Return first element of $list
16
- *
17
- * insert-nth($list, $index, $value)
18
- * Add $value at $index in $list
19
- *
20
- * is-symmetrical($list)
21
- * Check if $list is symmetrical
22
- *
23
- * last($list)
24
- * Return last element of $list
25
- *
26
- * last-index($list, $value)
27
- * Return last index of $value in $list
28
- *
29
- * loop($list, $value: 1)
30
- * Shift indexes from $list of $value
31
- *
32
- * prepend($list, $value)
33
- * Add $value as first index of $list
34
- *
35
- * purge($list)
36
- * Remove all false and null values from $list
37
- *
38
- * remove($list, $value, $recursive: false)
39
- * Remove value(s) $value from $list
40
- *
41
- * remove-duplicates($list, $recursive: false)
42
- * Remove duplicate values from $list
43
- *
44
- * remove-nth($list, $index)
45
- * Remove value from $list at index $index
46
- *
47
- * replace($list, $old-value, $new-value, $recursive: false)
48
- * Replace $old-value by $new-value in $list
49
- *
50
- * replace-nth($list, $index, $value)
51
- * Replace value at $index from $list by $value
52
- *
53
- * reverse($list, $recursive: false)
54
- * Reverse the order of $list
55
- *
56
- * slice($list, $start: 1, $end: length($list))
57
- * Slice $list between $start and $end
58
- *
59
- * sum($list, $force: false)
60
- * Sum up all unitless values in $list
61
- *
62
- * to-string($list, $glue: '', $is-nested: false)
63
- * Join all elements of $list with $glue
64
- *
65
- * ------------------------------------------------------------------------------- *
66
- * CodePen (SCSS): http://codepen.io/HugoGiraudel/pen/loAgq
67
- * CodePen (Sass): http://codepen.io/HugoGiraudel/pen/BskrE
68
- * Repository: https://github.com/Team-Sass/Sass-ListFunctions/
69
- * ------------------------------------------------------------------------------- */
70
-
71
- @import "ListFunctions/chunk";
72
- @import "ListFunctions/count-values";
73
- @import "ListFunctions/debug";
74
- @import "ListFunctions/first";
75
- @import "ListFunctions/insert-nth";
76
- @import "ListFunctions/is-symmetrical";
77
- @import "ListFunctions/last";
78
- @import "ListFunctions/last-index";
79
- @import "ListFunctions/loop";
80
- @import "ListFunctions/prepend";
81
- @import "ListFunctions/purge";
82
- @import "ListFunctions/remove";
83
- @import "ListFunctions/remove-duplicates";
84
- @import "ListFunctions/remove-nth";
85
- @import "ListFunctions/replace";
86
- @import "ListFunctions/replace-nth";
87
- @import "ListFunctions/reverse";
88
- @import "ListFunctions/slice";
89
- @import "ListFunctions/sum";
90
- @import "ListFunctions/to-string";
1
+ /* ------------------------------------------------------------------------------- *
2
+ * A couple of advanced Sass list functions
3
+ * ------------------------------------------------------------------------------- *
4
+ *
5
+ * chunk($list, $size)
6
+ * Chunk $list into $size large lists
7
+ *
8
+ * count-values($list)
9
+ * Count the number of occurrences of each value of $list
10
+ *
11
+ * debug($list)
12
+ * Returns $list as a string
13
+ *
14
+ * first($list)
15
+ * Return first element of $list
16
+ *
17
+ * insert-nth($list, $index, $value)
18
+ * Add $value at $index in $list
19
+ *
20
+ * is-symmetrical($list)
21
+ * Check if $list is symmetrical
22
+ *
23
+ * last($list)
24
+ * Return last element of $list
25
+ *
26
+ * last-index($list, $value)
27
+ * Return last index of $value in $list
28
+ *
29
+ * loop($list, $value: 1)
30
+ * Shift indexes from $list of $value
31
+ *
32
+ * prepend($list, $value)
33
+ * Add $value as first index of $list
34
+ *
35
+ * purge($list)
36
+ * Remove all false and null values from $list
37
+ *
38
+ * remove($list, $value, $recursive: false)
39
+ * Remove value(s) $value from $list
40
+ *
41
+ * remove-duplicates($list, $recursive: false)
42
+ * Remove duplicate values from $list
43
+ *
44
+ * remove-nth($list, $index)
45
+ * Remove value from $list at index $index
46
+ *
47
+ * replace($list, $old-value, $new-value, $recursive: false)
48
+ * Replace $old-value by $new-value in $list
49
+ *
50
+ * replace-nth($list, $index, $value)
51
+ * Replace value at $index from $list by $value
52
+ *
53
+ * reverse($list, $recursive: false)
54
+ * Reverse the order of $list
55
+ *
56
+ * slice($list, $start: 1, $end: length($list))
57
+ * Slice $list between $start and $end
58
+ *
59
+ * sum($list, $force: false)
60
+ * Sum up all unitless values in $list
61
+ *
62
+ * to-string($list, $glue: '', $is-nested: false)
63
+ * Join all elements of $list with $glue
64
+ *
65
+ * ------------------------------------------------------------------------------- *
66
+ * CodePen (SCSS): http://codepen.io/HugoGiraudel/pen/loAgq
67
+ * CodePen (Sass): http://codepen.io/HugoGiraudel/pen/BskrE
68
+ * Repository: https://github.com/Team-Sass/Sass-ListFunctions/
69
+ * ------------------------------------------------------------------------------- */
70
+
71
+ @import "ListFunctions/chunk";
72
+ @import "ListFunctions/count-values";
73
+ @import "ListFunctions/debug";
74
+ @import "ListFunctions/first";
75
+ @import "ListFunctions/insert-nth";
76
+ @import "ListFunctions/is-symmetrical";
77
+ @import "ListFunctions/last";
78
+ @import "ListFunctions/last-index";
79
+ @import "ListFunctions/loop";
80
+ @import "ListFunctions/prepend";
81
+ @import "ListFunctions/purge";
82
+ @import "ListFunctions/remove";
83
+ @import "ListFunctions/remove-duplicates";
84
+ @import "ListFunctions/remove-nth";
85
+ @import "ListFunctions/replace";
86
+ @import "ListFunctions/replace-nth";
87
+ @import "ListFunctions/reverse";
88
+ @import "ListFunctions/slice";
89
+ @import "ListFunctions/sum";
90
+ @import "ListFunctions/to-string";
metadata CHANGED
@@ -1,41 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ListFunctions
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Hugo Giraudel
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-10-06 00:00:00.000000000 Z
12
+ date: 2013-10-16 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: sass
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: 3.2.0
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: 3.2.0
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: compass
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: 0.12.1
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: 0.12.1
41
46
  description: Advanced Sass list functions
@@ -64,6 +69,7 @@ files:
64
69
  - stylesheets/ListFunctions/_replace.scss
65
70
  - stylesheets/ListFunctions/_reverse.scss
66
71
  - stylesheets/ListFunctions/_slice.scss
72
+ - stylesheets/ListFunctions/_sort.scss
67
73
  - stylesheets/ListFunctions/_sum.scss
68
74
  - stylesheets/ListFunctions/_to-string.scss
69
75
  - stylesheets/_ListFunctions.scss
@@ -91,25 +97,26 @@ files:
91
97
  - templates/project/sass/_ListFunctions.scss
92
98
  homepage: http://hugogiraudel.com/
93
99
  licenses: []
94
- metadata: {}
95
100
  post_install_message:
96
101
  rdoc_options: []
97
102
  require_paths:
98
103
  - lib
99
104
  required_ruby_version: !ruby/object:Gem::Requirement
105
+ none: false
100
106
  requirements:
101
- - - '>='
107
+ - - ! '>='
102
108
  - !ruby/object:Gem::Version
103
109
  version: '0'
104
110
  required_rubygems_version: !ruby/object:Gem::Requirement
111
+ none: false
105
112
  requirements:
106
- - - '>='
113
+ - - ! '>='
107
114
  - !ruby/object:Gem::Version
108
115
  version: 1.3.6
109
116
  requirements: []
110
117
  rubyforge_project: ListFunctions
111
- rubygems_version: 2.0.3
118
+ rubygems_version: 1.8.24
112
119
  signing_key:
113
- specification_version: 4
120
+ specification_version: 3
114
121
  summary: Advanced Sass list functions
115
122
  test_files: []