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,31 +1,15 @@
1
- /*
2
- * Return character from $string at $index
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.0.0
7
- * ---
8
- * @param {string} $string - string to check
9
- * @param {string} $index - index to inspect
10
- * ---
11
- * @return {string}
12
- */
13
-
14
1
  @function char-at($string, $index) {
15
- @if type-of($string) != "string" {
16
- @warn "`char-at` function expecting a string for $string; #{type-of($string)} given.";
17
- @return false;
18
- }
2
+ @if type-of($string) != "string" {
3
+ @error "`char-at` function expecting a string for $string; #{type-of($string)} given.";
4
+ }
5
+
6
+ @if type-of($index) != "number" {
7
+ @error "`char-at` function expecting a number for $index; #{type-of($index)} given.";
8
+ }
19
9
 
20
- @if type-of($index) != "number" {
21
- @warn "`char-at` function expecting a number for $index; #{type-of($index)} given.";
22
- @return false;
23
- }
10
+ @if $index < 1 or $index > str-length($string) {
11
+ @error "Out of bounds $index for `char-at`.";
12
+ }
24
13
 
25
- @if $index < 1 or $index > str-length($string) {
26
- @warn "Out of bounds $index for `char-at`.";
27
- @return false;
28
- }
29
-
30
- @return _ss-char-at($string, $index);
31
- }
14
+ @return _ss-char-at($string, $index);
15
+ }
@@ -1,26 +1,11 @@
1
- /*
2
- * Calculating Levenshtein distance between two strings
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.0.0
7
- * ---
8
- * @param {string} $a - first string
9
- * @param {string} $b - second string
10
- * ---
11
- * @return {number}
12
- */
13
-
14
1
  @function levenshtein($a, $b) {
15
2
  @if type-of($a) != "string" {
16
- @warn "`str-count` function expecting a string for $a; #{type-of($a)} given.";
17
- @return false;
3
+ @error "`str-count` function expecting a string for $a; #{type-of($a)} given.";
18
4
  }
19
5
 
20
6
  @if type-of($b) != "string" {
21
- @warn "`str-count` function expecting a string for $b; #{type-of($b)} given.";
22
- @return false;
7
+ @error "`str-count` function expecting a string for $b; #{type-of($b)} given.";
23
8
  }
24
9
 
25
10
  @return _ss-levenshtein($a, $b);
26
- }
11
+ }
@@ -1,26 +1,11 @@
1
- /*
2
- * Count the number of occurrences of $needle in $string
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.0.0
7
- * ---
8
- * @param {string} $string - string
9
- * @param {string} $needle - substring to count in $string
10
- * ---
11
- * @return {number|false}
12
- */
13
-
14
1
  @function str-count($string, $needle) {
15
- @if type-of($string) != "string" {
16
- @warn "`str-count` function expecting a string for $string; #{type-of($string)} given.";
17
- @return false;
18
- }
2
+ @if type-of($string) != "string" {
3
+ @error "`str-count` function expecting a string for $string; #{type-of($string)} given.";
4
+ }
19
5
 
20
- @if type-of($needle) != "string" {
21
- @warn "`str-count` function expecting a string for $needle; #{type-of($needle)} given.";
22
- @return false;
23
- }
6
+ @if type-of($needle) != "string" {
7
+ @error "`str-count` function expecting a string for $needle; #{type-of($needle)} given.";
8
+ }
24
9
 
25
- @return _ss-str-count($string, $needle);
26
- }
10
+ @return _ss-str-count($string, $needle);
11
+ }
@@ -1,25 +1,10 @@
1
- /*
2
- * Check whether $string ends with $needle
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.0.0
7
- * ---
8
- * @param {string} $string - string to check
9
- * @param {string} $needle - substring to check
10
- * ---
11
- * @return {bool}
12
- */
13
-
14
1
  @function str-ends-with($string, $needle) {
15
2
  @if type-of($string) != "string" {
16
- @warn "`str-starts-with` function expecting a string for $string; #{type-of($string)} given.";
17
- @return false;
3
+ @error "`str-starts-with` function expecting a string for $string; #{type-of($string)} given.";
18
4
  }
19
5
 
20
6
  @if type-of($needle) != "string" {
21
- @warn "`str-starts-with` function expecting a string for $needle; #{type-of($needle)} given.";
22
- @return false;
7
+ @error "`str-starts-with` function expecting a string for $needle; #{type-of($needle)} given.";
23
8
  }
24
9
 
25
10
  @return _ss-str-ends-with($string, $needle);
@@ -1,26 +1,11 @@
1
- /*
2
- * Split $string into several parts using $delimiter
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.0.0
7
- * ---
8
- * @param {string} $string - string to split
9
- * @param {string} $delimiter - string to use as a delimiter to split $string
10
- * ---
11
- * @return {list|false}
12
- */
13
-
14
1
  @function str-explode($string, $delimiter: '') {
15
2
  @if type-of($string) != "string" {
16
- @warn "`explode` function expecting a string; #{type-of($string)} given.";
17
- @return false;
3
+ @error "`explode` function expecting a string; #{type-of($string)} given.";
18
4
  }
19
5
 
20
6
  @if type-of($delimiter) != "string" {
21
- @warn "`explode` function expecting a string; #{type-of($delimiter)} given.";
22
- @return false;
7
+ @error "`explode` function expecting a string; #{type-of($delimiter)} given.";
23
8
  }
24
9
 
25
10
  @return _ss-str-explode($string, $delimiter);
26
- }
11
+ }
@@ -1,19 +1,7 @@
1
- /*
2
- * Implode $list into a string
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.0.0
7
- * ---
8
- * @param {list} $list - list to convert to string
9
- * ---
10
- * @return {string}
11
- */
12
-
13
1
  @function str-implode($list) {
14
- @if type-of($list) != list {
15
- @error '$list for str-implode must be a list';
16
- }
2
+ @if type-of($list) != "list" {
3
+ @error '$list for str-implode must be a list';
4
+ }
17
5
 
18
- @return _ss-str-implode($list);
19
- }
6
+ @return _ss-str-implode($list);
7
+ }
@@ -1,26 +1,11 @@
1
- /*
2
- * Return last index of $needle in $string
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.0.0
7
- * ---
8
- * @param {string} $string - string to search in
9
- * @param {string} $needle - substring to search for
10
- * ---
11
- * @return {number | null | false}
12
- */
13
-
14
1
  @function str-last-index($string, $needle) {
15
2
  @if type-of($string) != "string" {
16
- @warn "`str-last-index` function expecting a string for $string; #{type-of($string)} given.";
17
- @return false;
3
+ @error "`str-last-index` function expecting a string for $string; #{type-of($string)} given.";
18
4
  }
19
5
 
20
6
  @if type-of($needle) != "string" {
21
- @warn "`str-last-index` function expecting a string for $needle; #{type-of($needle)} given.";
22
- @return false;
7
+ @error "`str-last-index` function expecting a string for $needle; #{type-of($needle)} given.";
23
8
  }
24
9
 
25
10
  @return _ss-str-last-index($string, $needle);
26
- }
11
+ }
@@ -1,20 +1,7 @@
1
- /*
2
- * Lower case first character of $string
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.0.0
7
- * ---
8
- * @param {string} $string - string to lower the first character
9
- * ---
10
- * @return {string}
11
- */
12
-
13
1
  @function str-lcfirst($string) {
14
2
  @if type-of($string) != "string" {
15
- @warn "`str-lcfirst` function expecting a string for $string; #{type-of($string)} given.";
16
- @return false;
3
+ @error "`str-lcfirst` function expecting a string for $string; #{type-of($string)} given.";
17
4
  }
18
5
 
19
6
  @return _ss-str-lcfirst($string);
20
- }
7
+ }
@@ -1,33 +1,19 @@
1
- /*
2
- * Pad $string from $direction with $pad to reach $length characters
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.0.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|false}
14
- */
15
-
16
1
  @function str-pad($string, $length, $pad: " ", $direction: left) {
17
2
  @if type-of($string) != "string" {
18
- @warn "`str-pad` function expecting a string for $string; #{type-of($string)} given.";
19
- @return false;
3
+ @error "`str-pad` function expecting a string for $string; #{type-of($string)} given.";
20
4
  }
21
5
 
22
6
  @if type-of($pad) != "string" {
23
- @warn "`str-pad` function expecting a string for $pad; #{type-of($pad)} given.";
24
- @return false;
7
+ @error "`str-pad` function expecting a string for $pad; #{type-of($pad)} given.";
25
8
  }
26
9
 
27
10
  @if type-of($length) != "number" {
28
- @warn "`str-pad` function expecting a number for $length; #{type-of($length)} given.";
29
- @return false;
11
+ @error "`str-pad` function expecting a number for $length; #{type-of($length)} given.";
12
+ }
13
+
14
+ @if index(left right, $direction) == null {
15
+ @error "`str-pad` function expecting either `left` or `right` for $direction: #{$direction} given.";
30
16
  }
31
17
 
32
18
  @return _ss-str-pad($string, $length, $pad, $direction);
33
- }
19
+ }
@@ -1,21 +1,7 @@
1
- /*
2
- * Replace occurrences of %s in $string by $elements
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.0.0
7
- * ---
8
- * @param {string} $string - string to check
9
- * @param {arglist} $elements - strings to use for replacements in %s
10
- * ---
11
- * @return {string | false}
12
- */
13
-
14
1
  @function str-printf($string, $elements...) {
15
2
  @if type-of($string) != "string" {
16
- @warn "`str-printf` function expecting a string for $string; #{type-of($string)} given.";
17
- @return false;
3
+ @error "`str-printf` function expecting a string for $string; #{type-of($string)} given.";
18
4
  }
19
5
 
20
6
  @return _ss-str-printf($string, $elements...);
21
- }
7
+ }
@@ -1,26 +1,11 @@
1
- /*
2
- * Repeat $string $times times
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.0.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
-
14
1
  @function str-repeat($string, $times) {
15
2
  @if type-of($string) != "string" {
16
- @warn "`str-repeat` function expecting a string for $string; #{type-of($string)} given.";
17
- @return false;
3
+ @error "`str-repeat` function expecting a string for $string; #{type-of($string)} given.";
18
4
  }
19
5
 
20
6
  @if type-of($times) != "number" {
21
- @warn "`str-repeat` function expecting a number for $times; #{type-of($times)} given.";
22
- @return false;
7
+ @error "`str-repeat` function expecting a number for $times; #{type-of($times)} given.";
23
8
  }
24
9
 
25
10
  @return _ss-str-repeat($string, $times);
26
- }
11
+ }
@@ -1,39 +1,16 @@
1
- /*
2
- * Replace $old occurrences by $new in $string respecting $case-sensitive
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.0.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|false}
14
- */
15
-
16
- @function str-replace($string, $old, $new: '', $case-sensitive: true) {
1
+ @function str-replace($string, $search, $replace: '') {
17
2
  @if type-of($string) != "string" {
18
- @warn "`str-replace` function expecting a string for $string; #{type-of($string)} given.";
19
- @return false;
20
- }
21
-
22
- @if type-of($old) != "string" {
23
- @warn "`str-replace` function expecting a string for $old; #{type-of($old)} given.";
24
- @return false;
3
+ @error "`str-replace` function expecting a string for $string; #{type-of($string)} given.";
25
4
  }
26
5
 
27
- @if type-of($new) != "string" {
28
- @warn "`str-replace` function expecting a string for $new; #{type-of($new)} given.";
29
- @return false;
6
+ @if type-of($search) != "string" {
7
+ @error "`str-replace` function expecting a string for $search; #{type-of($search)} given.";
30
8
  }
31
9
 
32
- @if str-index($new, $old) {
33
- @warn "The string to be replaced is contained in the new string. Infinite recursion avoided.";
34
- @return $string;
10
+ @if type-of($replace) != "string" {
11
+ @error "`str-replace` function expecting a string for $replace; #{type-of($replace)} given.";
35
12
  }
36
13
 
37
- @return _ss-str-replace($string, $old, $new, $case-sensitive);
14
+ @return _ss-str-replace($string, $search, $replace);
38
15
  }
39
16
 
@@ -1,20 +1,7 @@
1
- /*
2
- * Reverse $string
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.0.0
7
- * ---
8
- * @param {string} $string - string to reverse
9
- * ---
10
- * @return {string|false}
11
- */
12
-
13
1
  @function str-reverse($string) {
14
2
  @if type-of($string) != "string" {
15
- @warn "`str-reverse` function expecting a string for $string; #{type-of($string)} given.";
16
- @return false;
3
+ @error "`str-reverse` function expecting a string for $string; #{type-of($string)} given.";
17
4
  }
18
5
 
19
6
  @return _ss-str-reverse($string);
20
- }
7
+ }
@@ -1,26 +1,11 @@
1
- /*
2
- * Rotate all characters from the alphabet in $string by $rot positions
3
- * ---
4
- * @access public
5
- * ---
6
- * @since 1.0.0
7
- * ---
8
- * @param {string} $string - string to rotate
9
- * @param {number} $rot - number of positions to switch in alphabet
10
- * ---
11
- * @return {string|false}
12
- */
13
-
14
1
  @function str-rot($string, $rot: 13) {
15
2
  @if type-of($string) != "string" {
16
- @warn "`str-rot` function expecting a string for $string; #{type-of($string)} given.";
17
- @return false;
3
+ @error "`str-rot` function expecting a string for $string; #{type-of($string)} given.";
18
4
  }
19
5
 
20
6
  @if type-of($rot) != "number" {
21
- @warn "`str-rot` function expecting a number for $rot; #{type-of($rot)} given.";
22
- @return false;
7
+ @error "`str-rot` function expecting a number for $rot; #{type-of($rot)} given.";
23
8
  }
24
9
 
25
10
  @return _ss-str-rot($string, $rot);
26
- }
11
+ }