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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/README.md +5 -0
- data/lib/SassyStrings.rb +2 -2
- data/stylesheets/_SassyStrings.scss +2 -20
- data/stylesheets/private/_all.scss +24 -0
- data/stylesheets/private/_char-at.scss +16 -0
- data/stylesheets/private/_levenshtein.scss +105 -0
- data/stylesheets/private/_str-count.scss +27 -0
- data/stylesheets/private/_str-ends-with.scss +16 -0
- data/stylesheets/private/_str-explode.scss +41 -0
- data/stylesheets/private/_str-implode.scss +21 -0
- data/stylesheets/private/_str-last-index.scss +27 -0
- data/stylesheets/private/_str-lcfirst.scss +15 -0
- data/stylesheets/private/_str-pad.scss +36 -0
- data/stylesheets/private/_str-printf.scss +29 -0
- data/stylesheets/private/_str-repeat.scss +22 -0
- data/stylesheets/private/_str-replace.scss +33 -0
- data/stylesheets/private/_str-reverse.scss +21 -0
- data/stylesheets/private/_str-rot.scss +39 -0
- data/stylesheets/private/_str-shuffle.scss +36 -0
- data/stylesheets/private/_str-starts-with.scss +16 -0
- data/stylesheets/private/_str-trim.scss +31 -0
- data/stylesheets/private/_str-ucfirst.scss +15 -0
- data/stylesheets/{functions → private}/_str-word-count.scss +5 -6
- data/stylesheets/private/_stringify.scss +26 -0
- data/stylesheets/public/_all.scss +23 -0
- data/stylesheets/public/_char-at.scss +31 -0
- data/stylesheets/public/_levenshtein.scss +26 -0
- data/stylesheets/public/_str-count.scss +26 -0
- data/stylesheets/public/_str-ends-with.scss +26 -0
- data/stylesheets/public/_str-explode.scss +26 -0
- data/stylesheets/public/_str-implode.scss +19 -0
- data/stylesheets/{functions → public}/_str-last-index.scss +5 -12
- data/stylesheets/public/_str-lcfirst.scss +20 -0
- data/stylesheets/public/_str-pad.scss +33 -0
- data/stylesheets/public/_str-printf.scss +21 -0
- data/stylesheets/public/_str-repeat.scss +26 -0
- data/stylesheets/public/_str-replace.scss +39 -0
- data/stylesheets/public/_str-reverse.scss +20 -0
- data/stylesheets/public/_str-rot.scss +26 -0
- data/stylesheets/public/_str-shuffle.scss +18 -0
- data/stylesheets/public/_str-starts-with.scss +26 -0
- data/stylesheets/public/_str-trim.scss +20 -0
- data/stylesheets/{functions → public}/_str-ucfirst.scss +6 -2
- data/stylesheets/public/_str-word-count.scss +20 -0
- data/stylesheets/public/_stringify.scss +15 -0
- metadata +44 -22
- data/stylesheets/functions/_char-at.scss +0 -25
- data/stylesheets/functions/_levenshtein.scss +0 -99
- data/stylesheets/functions/_str-count.scss +0 -31
- data/stylesheets/functions/_str-ends-with.scss +0 -20
- data/stylesheets/functions/_str-explode.scss +0 -45
- data/stylesheets/functions/_str-implode.scss +0 -15
- data/stylesheets/functions/_str-lcfirst.scss +0 -14
- data/stylesheets/functions/_str-pad.scss +0 -45
- data/stylesheets/functions/_str-printf.scss +0 -28
- data/stylesheets/functions/_str-repeat.scss +0 -26
- data/stylesheets/functions/_str-replace.scss +0 -47
- data/stylesheets/functions/_str-reverse.scss +0 -20
- data/stylesheets/functions/_str-rot.scss +0 -43
- data/stylesheets/functions/_str-shuffle.scss +0 -26
- data/stylesheets/functions/_str-starts-with.scss +0 -20
- data/stylesheets/functions/_str-trim.scss +0 -30
- 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
|
-
|
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
|
-
* @
|
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
|
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
|
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-
|
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/
|
53
|
-
- stylesheets/
|
54
|
-
- stylesheets/
|
55
|
-
- stylesheets/
|
56
|
-
- stylesheets/
|
57
|
-
- stylesheets/
|
58
|
-
- stylesheets/
|
59
|
-
- stylesheets/
|
60
|
-
- stylesheets/
|
61
|
-
- stylesheets/
|
62
|
-
- stylesheets/
|
63
|
-
- stylesheets/
|
64
|
-
- stylesheets/
|
65
|
-
- stylesheets/
|
66
|
-
- stylesheets/
|
67
|
-
- stylesheets/
|
68
|
-
- stylesheets/
|
69
|
-
- stylesheets/
|
70
|
-
- stylesheets/
|
71
|
-
- stylesheets/
|
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: {}
|