SassyStrings 1.0.1 → 1.1.0

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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -0
  3. data/README.md +5 -0
  4. data/lib/SassyStrings.rb +2 -2
  5. data/stylesheets/_SassyStrings.scss +2 -20
  6. data/stylesheets/private/_all.scss +24 -0
  7. data/stylesheets/private/_char-at.scss +16 -0
  8. data/stylesheets/private/_levenshtein.scss +105 -0
  9. data/stylesheets/private/_str-count.scss +27 -0
  10. data/stylesheets/private/_str-ends-with.scss +16 -0
  11. data/stylesheets/private/_str-explode.scss +41 -0
  12. data/stylesheets/private/_str-implode.scss +21 -0
  13. data/stylesheets/private/_str-last-index.scss +27 -0
  14. data/stylesheets/private/_str-lcfirst.scss +15 -0
  15. data/stylesheets/private/_str-pad.scss +36 -0
  16. data/stylesheets/private/_str-printf.scss +29 -0
  17. data/stylesheets/private/_str-repeat.scss +22 -0
  18. data/stylesheets/private/_str-replace.scss +33 -0
  19. data/stylesheets/private/_str-reverse.scss +21 -0
  20. data/stylesheets/private/_str-rot.scss +39 -0
  21. data/stylesheets/private/_str-shuffle.scss +36 -0
  22. data/stylesheets/private/_str-starts-with.scss +16 -0
  23. data/stylesheets/private/_str-trim.scss +31 -0
  24. data/stylesheets/private/_str-ucfirst.scss +15 -0
  25. data/stylesheets/{functions → private}/_str-word-count.scss +5 -6
  26. data/stylesheets/private/_stringify.scss +26 -0
  27. data/stylesheets/public/_all.scss +23 -0
  28. data/stylesheets/public/_char-at.scss +31 -0
  29. data/stylesheets/public/_levenshtein.scss +26 -0
  30. data/stylesheets/public/_str-count.scss +26 -0
  31. data/stylesheets/public/_str-ends-with.scss +26 -0
  32. data/stylesheets/public/_str-explode.scss +26 -0
  33. data/stylesheets/public/_str-implode.scss +19 -0
  34. data/stylesheets/{functions → public}/_str-last-index.scss +5 -12
  35. data/stylesheets/public/_str-lcfirst.scss +20 -0
  36. data/stylesheets/public/_str-pad.scss +33 -0
  37. data/stylesheets/public/_str-printf.scss +21 -0
  38. data/stylesheets/public/_str-repeat.scss +26 -0
  39. data/stylesheets/public/_str-replace.scss +39 -0
  40. data/stylesheets/public/_str-reverse.scss +20 -0
  41. data/stylesheets/public/_str-rot.scss +26 -0
  42. data/stylesheets/public/_str-shuffle.scss +18 -0
  43. data/stylesheets/public/_str-starts-with.scss +26 -0
  44. data/stylesheets/public/_str-trim.scss +20 -0
  45. data/stylesheets/{functions → public}/_str-ucfirst.scss +6 -2
  46. data/stylesheets/public/_str-word-count.scss +20 -0
  47. data/stylesheets/public/_stringify.scss +15 -0
  48. metadata +44 -22
  49. data/stylesheets/functions/_char-at.scss +0 -25
  50. data/stylesheets/functions/_levenshtein.scss +0 -99
  51. data/stylesheets/functions/_str-count.scss +0 -31
  52. data/stylesheets/functions/_str-ends-with.scss +0 -20
  53. data/stylesheets/functions/_str-explode.scss +0 -45
  54. data/stylesheets/functions/_str-implode.scss +0 -15
  55. data/stylesheets/functions/_str-lcfirst.scss +0 -14
  56. data/stylesheets/functions/_str-pad.scss +0 -45
  57. data/stylesheets/functions/_str-printf.scss +0 -28
  58. data/stylesheets/functions/_str-repeat.scss +0 -26
  59. data/stylesheets/functions/_str-replace.scss +0 -47
  60. data/stylesheets/functions/_str-reverse.scss +0 -20
  61. data/stylesheets/functions/_str-rot.scss +0 -43
  62. data/stylesheets/functions/_str-shuffle.scss +0 -26
  63. data/stylesheets/functions/_str-starts-with.scss +0 -20
  64. data/stylesheets/functions/_str-trim.scss +0 -30
  65. data/stylesheets/functions/_stringify.scss +0 -21
@@ -0,0 +1,19 @@
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
+ @function str-implode($list) {
14
+ @if type-of($list) != list {
15
+ @error '$list for str-implode must be a list';
16
+ }
17
+
18
+ @return _ss-str-implode($list);
19
+ }
@@ -1,6 +1,10 @@
1
1
  /*
2
2
  * Return last index of $needle in $string
3
3
  * ---
4
+ * @access public
5
+ * ---
6
+ * @since 1.0.0
7
+ * ---
4
8
  * @param {string} $string - string to search in
5
9
  * @param {string} $needle - substring to search for
6
10
  * ---
@@ -18,16 +22,5 @@
18
22
  @return false;
19
23
  }
20
24
 
21
- $index: str-index($string, $needle);
22
- $result: $index;
23
-
24
- @if $index {
25
- @for $i from $index + str-length($needle) through str-length($string) {
26
- @if str-slice($string, $i, $i + str-length($needle) - 1) == $needle {
27
- $result: $i;
28
- }
29
- }
30
- }
31
-
32
- @return $result;
25
+ @return _ss-str-last-index($string, $needle);
33
26
  }
@@ -0,0 +1,20 @@
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
+ @function str-lcfirst($string) {
14
+ @if type-of($string) != "string" {
15
+ @warn "`str-lcfirst` function expecting a string for $string; #{type-of($string)} given.";
16
+ @return false;
17
+ }
18
+
19
+ @return _ss-str-lcfirst($string);
20
+ }
@@ -0,0 +1,33 @@
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
+ @function str-pad($string, $length, $pad: " ", $direction: left) {
17
+ @if type-of($string) != "string" {
18
+ @warn "`str-pad` function expecting a string for $string; #{type-of($string)} given.";
19
+ @return false;
20
+ }
21
+
22
+ @if type-of($pad) != "string" {
23
+ @warn "`str-pad` function expecting a string for $pad; #{type-of($pad)} given.";
24
+ @return false;
25
+ }
26
+
27
+ @if type-of($length) != "number" {
28
+ @warn "`str-pad` function expecting a number for $length; #{type-of($length)} given.";
29
+ @return false;
30
+ }
31
+
32
+ @return _ss-str-pad($string, $length, $pad, $direction);
33
+ }
@@ -0,0 +1,21 @@
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
+ @function str-printf($string, $elements...) {
15
+ @if type-of($string) != "string" {
16
+ @warn "`str-printf` function expecting a string for $string; #{type-of($string)} given.";
17
+ @return false;
18
+ }
19
+
20
+ @return _ss-str-printf($string, $elements...);
21
+ }
@@ -0,0 +1,26 @@
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
+ @function str-repeat($string, $times) {
15
+ @if type-of($string) != "string" {
16
+ @warn "`str-repeat` function expecting a string for $string; #{type-of($string)} given.";
17
+ @return false;
18
+ }
19
+
20
+ @if type-of($times) != "number" {
21
+ @warn "`str-repeat` function expecting a number for $times; #{type-of($times)} given.";
22
+ @return false;
23
+ }
24
+
25
+ @return _ss-str-repeat($string, $times);
26
+ }
@@ -0,0 +1,39 @@
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) {
17
+ @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;
25
+ }
26
+
27
+ @if type-of($new) != "string" {
28
+ @warn "`str-replace` function expecting a string for $new; #{type-of($new)} given.";
29
+ @return false;
30
+ }
31
+
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;
35
+ }
36
+
37
+ @return _ss-str-replace($string, $old, $new, $case-sensitive);
38
+ }
39
+
@@ -0,0 +1,20 @@
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
+ @function str-reverse($string) {
14
+ @if type-of($string) != "string" {
15
+ @warn "`str-reverse` function expecting a string for $string; #{type-of($string)} given.";
16
+ @return false;
17
+ }
18
+
19
+ @return _ss-str-reverse($string);
20
+ }
@@ -0,0 +1,26 @@
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
+ @function str-rot($string, $rot: 13) {
15
+ @if type-of($string) != "string" {
16
+ @warn "`str-rot` function expecting a string for $string; #{type-of($string)} given.";
17
+ @return false;
18
+ }
19
+
20
+ @if type-of($rot) != "number" {
21
+ @warn "`str-rot` function expecting a number for $rot; #{type-of($rot)} given.";
22
+ @return false;
23
+ }
24
+
25
+ @return _ss-str-rot($string, $rot);
26
+ }
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Shuffle characters from $string
3
+ * ---
4
+ * @access public
5
+ * ---
6
+ * @since 1.0.0
7
+ * ---
8
+ * @param {string} $string - string to shuffle
9
+ * ---
10
+ * @return {string}
11
+ */
12
+
13
+ @function str-shuffle($string) {
14
+ @if type-of($string) != string {
15
+ @error '$string of str-shuffle must be a string';
16
+ }
17
+ @return _ss-str-shuffle($string);
18
+ }
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Check whether $string stars 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|false}
12
+ */
13
+
14
+ @function str-starts-with($string, $needle) {
15
+ @if type-of($string) != "string" {
16
+ @warn "`str-starts-with` function expecting a string for $string; #{type-of($string)} given.";
17
+ @return false;
18
+ }
19
+
20
+ @if type-of($needle) != "string" {
21
+ @warn "`str-starts-with` function expecting a string for $needle; #{type-of($needle)} given.";
22
+ @return false;
23
+ }
24
+
25
+ @return _ss-str-starts-with($string, $needle);
26
+ }
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Remove all trailing and leading whitespaces from $string
3
+ * ---
4
+ * @access public
5
+ * ---
6
+ * @since 1.0.0
7
+ * ---
8
+ * @param {string} $string - string
9
+ * ---
10
+ * @return {string|false}
11
+ */
12
+
13
+ @function str-trim($string) {
14
+ @if type-of($string) != "string" {
15
+ @warn "`str-trim` function expecting a string for $string; #{type-of($string)} given.";
16
+ @return false;
17
+ }
18
+
19
+ @return _ss-str-trim($string);
20
+ }
@@ -1,7 +1,11 @@
1
1
  /*
2
2
  * Capitalize first letter from $string
3
3
  * ---
4
- * @param {string} $string - string for capitalization
4
+ * @access public
5
+ * ---
6
+ * @since 1.0.0
7
+ * ---
8
+ * @param {string} $string - string to capitalize first letter from
5
9
  * ---
6
10
  * @return {string | false}
7
11
  */
@@ -12,5 +16,5 @@
12
16
  @return false;
13
17
  }
14
18
 
15
- @return to-upper-case(str-slice($string, 1, 1)) + str-slice($string, 2);
19
+ @return _ss-str-ucfirst($string);
16
20
  }
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Count number of words in $string
3
+ * ---
4
+ * @access public
5
+ * ---
6
+ * @since 1.0.0
7
+ * ---
8
+ * @param {string} $string - string to check
9
+ * ---
10
+ * @return {string|false}
11
+ */
12
+
13
+ @function str-word-count($string) {
14
+ @if type-of($string) != "string" {
15
+ @warn "`str-word-count` function expecting a string for $string; #{type-of($string)} given.";
16
+ @return false;
17
+ }
18
+
19
+ @return _ss-str-word-count($string);
20
+ }
@@ -0,0 +1,15 @@
1
+ /*
2
+ * Cast anything to string
3
+ * ---
4
+ * @access public
5
+ * ---
6
+ * @since 1.0.0
7
+ * ---
8
+ * @param {literal} $literal: number to cast to string
9
+ * ---
10
+ * @return {string}
11
+ */
12
+
13
+ @function stringify($literal) {
14
+ @return _ss-stringify($literal);
15
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: SassyStrings
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hugo Giraudel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-16 00:00:00.000000000 Z
11
+ date: 2014-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass
@@ -49,26 +49,48 @@ files:
49
49
  - CHANGELOG.md
50
50
  - lib/SassyStrings.rb
51
51
  - stylesheets/_SassyStrings.scss
52
- - stylesheets/functions/_char-at.scss
53
- - stylesheets/functions/_levenshtein.scss
54
- - stylesheets/functions/_str-count.scss
55
- - stylesheets/functions/_str-ends-with.scss
56
- - stylesheets/functions/_str-explode.scss
57
- - stylesheets/functions/_str-implode.scss
58
- - stylesheets/functions/_str-last-index.scss
59
- - stylesheets/functions/_str-lcfirst.scss
60
- - stylesheets/functions/_str-pad.scss
61
- - stylesheets/functions/_str-printf.scss
62
- - stylesheets/functions/_str-repeat.scss
63
- - stylesheets/functions/_str-replace.scss
64
- - stylesheets/functions/_str-reverse.scss
65
- - stylesheets/functions/_str-rot.scss
66
- - stylesheets/functions/_str-shuffle.scss
67
- - stylesheets/functions/_str-starts-with.scss
68
- - stylesheets/functions/_str-trim.scss
69
- - stylesheets/functions/_str-ucfirst.scss
70
- - stylesheets/functions/_str-word-count.scss
71
- - stylesheets/functions/_stringify.scss
52
+ - stylesheets/private/_all.scss
53
+ - stylesheets/private/_char-at.scss
54
+ - stylesheets/private/_levenshtein.scss
55
+ - stylesheets/private/_str-count.scss
56
+ - stylesheets/private/_str-ends-with.scss
57
+ - stylesheets/private/_str-explode.scss
58
+ - stylesheets/private/_str-implode.scss
59
+ - stylesheets/private/_str-last-index.scss
60
+ - stylesheets/private/_str-lcfirst.scss
61
+ - stylesheets/private/_str-pad.scss
62
+ - stylesheets/private/_str-printf.scss
63
+ - stylesheets/private/_str-repeat.scss
64
+ - stylesheets/private/_str-replace.scss
65
+ - stylesheets/private/_str-reverse.scss
66
+ - stylesheets/private/_str-rot.scss
67
+ - stylesheets/private/_str-shuffle.scss
68
+ - stylesheets/private/_str-starts-with.scss
69
+ - stylesheets/private/_str-trim.scss
70
+ - stylesheets/private/_str-ucfirst.scss
71
+ - stylesheets/private/_str-word-count.scss
72
+ - stylesheets/private/_stringify.scss
73
+ - stylesheets/public/_all.scss
74
+ - stylesheets/public/_char-at.scss
75
+ - stylesheets/public/_levenshtein.scss
76
+ - stylesheets/public/_str-count.scss
77
+ - stylesheets/public/_str-ends-with.scss
78
+ - stylesheets/public/_str-explode.scss
79
+ - stylesheets/public/_str-implode.scss
80
+ - stylesheets/public/_str-last-index.scss
81
+ - stylesheets/public/_str-lcfirst.scss
82
+ - stylesheets/public/_str-pad.scss
83
+ - stylesheets/public/_str-printf.scss
84
+ - stylesheets/public/_str-repeat.scss
85
+ - stylesheets/public/_str-replace.scss
86
+ - stylesheets/public/_str-reverse.scss
87
+ - stylesheets/public/_str-rot.scss
88
+ - stylesheets/public/_str-shuffle.scss
89
+ - stylesheets/public/_str-starts-with.scss
90
+ - stylesheets/public/_str-trim.scss
91
+ - stylesheets/public/_str-ucfirst.scss
92
+ - stylesheets/public/_str-word-count.scss
93
+ - stylesheets/public/_stringify.scss
72
94
  homepage: https://github.com/HugoGiraudel/SassyStrings
73
95
  licenses: []
74
96
  metadata: {}