SassyStrings 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/CHANGELOG.md +1 -0
  2. data/README.md +4 -4
  3. data/lib/SassyStrings.rb +2 -2
  4. data/stylesheets/private/_all.scss +2 -2
  5. data/stylesheets/private/_char-at.scss +7 -15
  6. data/stylesheets/private/_levenshtein.scss +63 -84
  7. data/stylesheets/private/_str-count.scss +15 -23
  8. data/stylesheets/private/_str-ends-with.scss +6 -14
  9. data/stylesheets/private/_str-explode.scss +28 -35
  10. data/stylesheets/private/_str-implode.scss +10 -18
  11. data/stylesheets/private/_str-last-index.scss +6 -14
  12. data/stylesheets/private/_str-lcfirst.scss +5 -13
  13. data/stylesheets/private/_str-pad.scss +10 -19
  14. data/stylesheets/private/_str-printf.scss +9 -18
  15. data/stylesheets/private/_str-repeat.scss +6 -14
  16. data/stylesheets/private/_str-replace.scss +11 -29
  17. data/stylesheets/private/_str-reverse.scss +7 -15
  18. data/stylesheets/private/_str-rot.scss +9 -18
  19. data/stylesheets/private/_str-shuffle.scss +17 -31
  20. data/stylesheets/private/_str-starts-with.scss +5 -13
  21. data/stylesheets/private/_str-trim.scss +5 -13
  22. data/stylesheets/private/_str-ucfirst.scss +5 -13
  23. data/stylesheets/private/_str-word-count.scss +6 -14
  24. data/stylesheets/private/_stringify.scss +13 -22
  25. data/stylesheets/public/_all.scss +3 -2
  26. data/stylesheets/public/_char-at.scss +12 -28
  27. data/stylesheets/public/_levenshtein.scss +3 -18
  28. data/stylesheets/public/_str-count.scss +8 -23
  29. data/stylesheets/public/_str-ends-with.scss +2 -17
  30. data/stylesheets/public/_str-explode.scss +3 -18
  31. data/stylesheets/public/_str-implode.scss +5 -17
  32. data/stylesheets/public/_str-last-index.scss +3 -18
  33. data/stylesheets/public/_str-lcfirst.scss +2 -15
  34. data/stylesheets/public/_str-pad.scss +8 -22
  35. data/stylesheets/public/_str-printf.scss +2 -16
  36. data/stylesheets/public/_str-repeat.scss +3 -18
  37. data/stylesheets/public/_str-replace.scss +7 -30
  38. data/stylesheets/public/_str-reverse.scss +2 -15
  39. data/stylesheets/public/_str-rot.scss +3 -18
  40. data/stylesheets/public/_str-shuffle.scss +6 -17
  41. data/stylesheets/public/_str-starts-with.scss +2 -17
  42. data/stylesheets/public/_str-trim.scss +2 -15
  43. data/stylesheets/public/_str-ucfirst.scss +2 -15
  44. data/stylesheets/public/_str-word-count.scss +6 -19
  45. data/stylesheets/public/_stringify.scss +2 -14
  46. metadata +45 -39
  47. checksums.yaml +0 -7
@@ -1,15 +1,7 @@
1
- /*
2
- * Lower case first character of $string
3
- * ---
4
- * @access private
5
- * ---
6
- * @since 1.2.0
7
- * ---
8
- * @param {string} $string - string to lower the first character
9
- * ---
10
- * @return {string}
11
- */
12
-
1
+ /// Lower case first character of `$string`.
2
+ /// @since 1.2.0
3
+ /// @param {String} $string - string to lower the first character
4
+ /// @return {String}
13
5
  @function _ss-str-lcfirst($string) {
14
6
  @return to-lower-case(str-slice($string, 1, 1)) + str-slice($string, 2);
15
- }
7
+ }
@@ -1,20 +1,11 @@
1
- /*
2
- * Pad $string from $direction with $pad to reach $length characters
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.2.0
7
- * ---
8
- * @param {string} $string - string to pad
9
- * @param {number} $length - number of characters to go for in returned string
10
- * @param {string} $pad - string to use to pad $string
11
- * @param {string} $direction - direction left or right for padding
12
- * ---
13
- * @return {string}
14
- */
15
-
1
+ /// Pad `$string` from `$direction` with `$pad` to reach `$length` characters.
2
+ /// @since 1.2.0
3
+ /// @param {String} $string - string to pad
4
+ /// @param {Number} $length - number of characters to go for in returned string
5
+ /// @param {String} $pad (" ") - string to use to pad `$string`
6
+ /// @param {String} $direction (left) - direction left or right for padding
7
+ /// @return {String}
16
8
  @function _ss-str-pad($string, $length, $pad: " ", $direction: left) {
17
- $direction: if(index(left right, $direction), $direction, left);
18
9
  $new-string: $string;
19
10
  $index: 1;
20
11
 
@@ -22,15 +13,15 @@
22
13
  @while str-length($new-string) < $length {
23
14
  $remains: $length - str-length($new-string);
24
15
  $pad: if($remains < str-length($pad), str-slice($pad, 1, $remains), $pad);
16
+
25
17
  @if $direction == left {
26
18
  $new-string: str-insert($new-string, $pad, $index);
27
19
  $index: $index + str-length($pad);
28
- }
29
- @else {
20
+ } @else {
30
21
  $new-string: $new-string + $pad;
31
22
  }
32
23
  }
33
24
  }
34
25
 
35
26
  @return $new-string;
36
- }
27
+ }
@@ -1,26 +1,17 @@
1
- /*
2
- * Replace occurrences of %s in $string by $elements
3
- * ---
4
- * @access private
5
- * ---
6
- * @since 1.2.0
7
- * ---
8
- * @param {string} $string - string to check
9
- * @param {arglist} $elements - strings to use for replacements in %s
10
- * ---
11
- * @return {string}
12
- */
13
-
1
+ /// Replace occurrences of `%s` in `$string` by `$elements`.
2
+ /// @since 1.2.0
3
+ /// @param {String} $string - string to check
4
+ /// @param {Arglist} $elements - strings to use for replacements in `%s`
5
+ /// @return {String}
14
6
  @function _ss-str-printf($string, $elements...) {
15
- $breaker: '%s';
7
+ $breaker: "%s";
16
8
  $result: $string;
17
9
 
18
- @for $i from 1 through length($elements) {
10
+ @each $element in $elements {
19
11
  $index: str-index($result, $breaker);
20
12
  @if $index {
21
- $result: str-slice($result, 1, $index - 1) + _ss-stringify(nth($elements, $i)) + str-slice($result, $index + str-length($breaker));
22
- }
23
- @else {
13
+ $result: str-slice($result, 1, $index - 1) + _ss-stringify($element) + str-slice($result, $index + str-length($breaker));
14
+ } @else {
24
15
  @return $result;
25
16
  }
26
17
  }
@@ -1,16 +1,8 @@
1
- /*
2
- * Repeat $string $times times
3
- * ---
4
- * @access private
5
- * ---
6
- * @since 1.2.0
7
- * ---
8
- * @param {string} $string - string to repeat
9
- * @param {number} $times - number of times to repeat $string
10
- * ---
11
- * @return {string|false}
12
- */
13
-
1
+ /// Repeat `$string` `$times` times.
2
+ /// @since 1.2.0
3
+ /// @param {String} $string - string to repeat
4
+ /// @param {Number} $times - number of times to repeat $string
5
+ /// @return {String}
14
6
  @function _ss-str-repeat($string, $times) {
15
7
  $result: "";
16
8
 
@@ -19,4 +11,4 @@
19
11
  }
20
12
 
21
13
  @return $result;
22
- }
14
+ }
@@ -1,33 +1,15 @@
1
- /*
2
- * Replace $old occurrences by $new in $string respecting $case-sensitive
3
- * ---
4
- * @access private
5
- * ---
6
- * @since 1.2.0
7
- * ---
8
- * @param {string} $string - string
9
- * @param {string} $old - old substring to replace by $new
10
- * @param {string} $new - new substring to replace $old
11
- * @param {bool} $case-sensitive - case-sensitivity
12
- * ---
13
- * @return {string}
14
- */
15
-
16
- @function _ss-str-replace($string, $old, $new: '', $case-sensitive: true) {
17
- $index: if(not $case-sensitive, str-index(to-lower-case($string), to-lower-case($old)), str-index($string, $old));
18
-
19
- @if $index and $new != $old {
20
- $result: if($index != 1, quote(str-slice($string, 1, $index - 1)), '');
21
-
22
- @for $i from $index through str-length($string) {
23
- @if $i < $index or $i >= $index + str-length($old) {
24
- $result: $result + str-slice($string, $i, $i);
25
- }
26
- }
27
-
28
- @return quote(_ss-str-replace(str-insert($result, $new, $index), $old, $new, $case-sensitive));
1
+ /// Replace `$search` with `$replace` in `$string`.
2
+ /// @since 1.2.0
3
+ /// @param {String} $string - Initial string
4
+ /// @param {String} $search - Substring to replace
5
+ /// @param {String} $replace ("") - New value
6
+ /// @return {String} - Updated string
7
+ @function _ss-str-replace($string, $search, $replace: "") {
8
+ $index: str-index($string, $search);
9
+
10
+ @if $index {
11
+ @return str-slice($string, 1, $index - 1) + $replace + _ss-str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
29
12
  }
30
13
 
31
14
  @return $string;
32
15
  }
33
-
@@ -1,21 +1,13 @@
1
- /*
2
- * Reverse $string
3
- * ---
4
- * @access private
5
- * ---
6
- * @since 1.2.0
7
- * ---
8
- * @param {string} $string - string to reverse
9
- * ---
10
- * @return {string}
11
- */
12
-
1
+ /// Reverse `$string`.
2
+ /// @since 1.2.0
3
+ /// @param {String} $string - string to reverse
4
+ /// @return {String}
13
5
  @function _ss-str-reverse($string) {
14
6
  $result: "";
15
7
 
16
- @for $i from str-length($string) * -1 through -1 {
17
- $result: $result + str-slice($string, abs($i), abs($i));
8
+ @for $i from str-length($string) through 1 {
9
+ $result: $result + str-slice($string, $i, $i);
18
10
  }
19
11
 
20
12
  @return $result;
21
- }
13
+ }
@@ -1,28 +1,19 @@
1
- /*
2
- * Rotate all characters from the alphabet in $string by $rot positions
3
- * ---
4
- * @access private
5
- * ---
6
- * @since 1.2.0
7
- * ---
8
- * @param {string} $string - string to rotate
9
- * @param {number} $rot - number of positions to switch in alphabet
10
- * ---
11
- * @return {string}
12
- */
13
-
1
+ /// Rotate all characters from the alphabet in `$string` by `$rot` positions.
2
+ /// @since 1.2.0
3
+ /// @param {String} $string - string to rotate
4
+ /// @param {Number} $rot (13) - number of positions to switch in alphabet
5
+ /// @return {String}
14
6
  @function _ss-str-rot($string, $rot: 13) {
15
7
  $alphabet: a b c d e f g h i j k l m n o p q r s t u v w x y z;
16
8
  $result: "";
17
- $rot: if(type-of($rot) == "number", floor($rot), 13);
18
9
 
19
10
  @for $i from 1 through str-length($string) {
20
11
  $char: str-slice($string, $i, $i);
21
12
  $index: index($alphabet, to-lower-case($char));
22
13
  $is-caps: $index and (index($alphabet, to-lower-case($char)) != index($alphabet, $char));
23
- $new-char: if($index,
24
- if($index + $rot > length($alphabet),
25
- nth($alphabet, $index + $rot - length($alphabet)),
14
+ $new-char: if($index,
15
+ if($index + $rot > length($alphabet),
16
+ nth($alphabet, $index + $rot - length($alphabet)),
26
17
  nth($alphabet, $index + $rot)
27
18
  ),
28
19
  $char
@@ -36,4 +27,4 @@
36
27
  }
37
28
 
38
29
  @return $result;
39
- }
30
+ }
@@ -1,36 +1,22 @@
1
- /*
2
- * Shuffle characters from $string
3
- * ---
4
- * @access private
5
- * ---
6
- * @since 1.2.0
7
- * ---
8
- * @param {string} $string - string to shuffle
9
- * ---
10
- * @return {string}
11
- */
12
-
1
+ /// Shuffle characters from `$string`.
2
+ /// @since 1.2.0
3
+ /// @param {String} $string - string to shuffle
4
+ /// @return {String}
13
5
  @function _ss-str-shuffle($string) {
14
- @return str-implode(_ss-shuffle(str-explode($string)));
6
+ @return str-implode(_ss-shuffle(str-explode($string)));
15
7
  }
16
8
 
17
- /*
18
- * Shuffle a list
19
- * ---
20
- * @access private
21
- * ---
22
- * @param {list} $list - shuffle a list
23
- * ---
24
- * @return {list}
25
- */
26
-
9
+ /// Shuffle a list
10
+ /// @access private
11
+ /// @param {List} $list - shuffle a list
12
+ /// @return {List}
27
13
  @function _ss-shuffle($list) {
28
- @for $i from -1 * length($list) through -1 {
29
- $i: abs($i);
30
- $j: random(length($list) - 1) + 1;
31
- $tmp: nth($list, $i);
32
- $list: set-nth($list, $i, nth($list, $j));
33
- $list: set-nth($list, $j, $tmp);
34
- }
35
- @return $list;
14
+ @for $i from length($list) through 1 {
15
+ $j: random(length($list) - 1) + 1;
16
+ $tmp: nth($list, $i);
17
+ $list: set-nth($list, $i, nth($list, $j));
18
+ $list: set-nth($list, $j, $tmp);
19
+ }
20
+
21
+ @return $list;
36
22
  }
@@ -1,16 +1,8 @@
1
- /*
2
- * Check whether $string stars with $needle
3
- * ---
4
- * @access private
5
- * ---
6
- * @since 1.2.0
7
- * ---
8
- * @param {string} $string - string to check
9
- * @param {string} $needle - substring to check
10
- * ---
11
- * @return {bool}
12
- */
13
-
1
+ /// Check whether `$string` stars with `$needle`.
2
+ /// @since 1.2.0
3
+ /// @param {String} $string - string to check
4
+ /// @param {String} $needle - substring to check
5
+ /// @return {Bool}
14
6
  @function _ss-str-starts-with($string, $needle) {
15
7
  @return str-slice($string, 1, str-length($needle)) == $needle;
16
8
  }
@@ -1,15 +1,7 @@
1
- /*
2
- * Remove all trailing and leading whitespaces from $string
3
- * ---
4
- * @access private
5
- * ---
6
- * @since 1.2.0
7
- * ---
8
- * @param {string} $string - string
9
- * ---
10
- * @return {string}
11
- */
12
-
1
+ /// Remove all trailing and leading whitespaces from `$string`.
2
+ /// @since 1.2.0
3
+ /// @param {String} $string - string
4
+ /// @return {String}
13
5
  @function _ss-str-trim($string) {
14
6
  $start: 1;
15
7
  $end: str-length($string);
@@ -28,4 +20,4 @@
28
20
  }
29
21
 
30
22
  @return str-slice($string, $start, $end);
31
- }
23
+ }
@@ -1,15 +1,7 @@
1
- /*
2
- * Capitalize first letter from $string
3
- * ---
4
- * @access private
5
- * ---
6
- * @since 1.2.0
7
- * ---
8
- * @param {string} $string - string for capitalization
9
- * ---
10
- * @return {string}
11
- */
12
-
1
+ /// Capitalize first letter from `$string`.
2
+ /// @since 1.2.0
3
+ /// @param {String} $string - string for capitalization
4
+ /// @return {String}
13
5
  @function _ss-str-ucfirst($string) {
14
6
  @return to-upper-case(str-slice($string, 1, 1)) + str-slice($string, 2);
15
- }
7
+ }
@@ -1,17 +1,9 @@
1
- /*
2
- * Count number of words in $string
3
- * ---
4
- * @access private
5
- * ---
6
- * @since 1.2.0
7
- * ---
8
- * @param {string} $string - string to check
9
- * ---
10
- * @return {string|false}
11
- */
12
-
1
+ /// Count number of words in `$string`.
2
+ /// @since 1.2.0
3
+ /// @param {String} $string - string to check
4
+ /// @return {String}
13
5
  @function _ss-str-word-count($string) {
14
- @if $string == '' {
6
+ @if $string == "" {
15
7
  @return 0;
16
8
  }
17
9
 
@@ -28,4 +20,4 @@
28
20
  }
29
21
 
30
22
  @return length(append($words, $string));
31
- }
23
+ }
@@ -1,26 +1,17 @@
1
- /*
2
- * Cast anything to string
3
- * ---
4
- * @access private
5
- * ---
6
- * @since 1.2.0
7
- * ---
8
- * @param {literal} $literal: number to cast to string
9
- * ---
10
- * @return {string}
11
- */
12
-
1
+ /// Cast `$literal` to string.
2
+ /// @since 1.2.0
3
+ /// @param {*} `$literal` - number to cast to string
4
+ /// @return {String}
13
5
  @function _ss-stringify($literal) {
14
- $result: "";
6
+ $result: "";
15
7
 
16
- @if length($literal) == 1 {
17
- $result: $literal + unquote("");
18
- } @else {
19
- @each $item in $literal {
20
- $result: $result + stringify($item);
21
- }
8
+ @if length($literal) == 1 {
9
+ $result: $literal + unquote("");
10
+ } @else {
11
+ @each $item in $literal {
12
+ $result: $result + stringify($item);
22
13
  }
14
+ }
23
15
 
24
- @return quote($result);
25
-
26
- }
16
+ @return quote($result);
17
+ }
@@ -1,6 +1,7 @@
1
1
  //* ----------------------------------------------------- */
2
- // Public files for use in your project
2
+ // Public files for use in your project
3
3
  //* ----------------------------------------------------- */
4
+
4
5
  @import "char-at";
5
6
  @import "levenshtein";
6
7
  @import "str-count";
@@ -20,4 +21,4 @@
20
21
  @import "str-trim";
21
22
  @import "str-ucfirst";
22
23
  @import "str-word-count";
23
- @import "stringify";
24
+ @import "stringify";