sass-aleksi 0.1.2 → 0.2.1
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/lib/sass-aleksi.rb +2 -2
- data/stylesheets/_aleksi.scss +1 -1
- data/stylesheets/aleksi/_strings.scss +11 -0
- data/stylesheets/aleksi/config/_constants.scss +7 -3
- data/stylesheets/aleksi/lists/_walk.scss +3 -1
- data/stylesheets/aleksi/strings/_char-at.scss +37 -0
- data/stylesheets/aleksi/strings/_str-explode.scss +58 -0
- data/stylesheets/aleksi/strings/_str-remove.scss +37 -0
- data/stylesheets/aleksi/strings/_str-replace.scss +43 -0
- metadata +7 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83216fd754d48f2ec46e12d93615f9de9d0fa14c
|
4
|
+
data.tar.gz: 175cea34f5c09d95b63afcd8a4b6b83342a46686
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ca2fb411c78025b29ad0db7437bcc8bcf76937565a77d55ea17ff10c9612534dabda7717f22474bc91b3b42f2163988b11f3a7190e87596624b02ce937472cc
|
7
|
+
data.tar.gz: acb8a36fdc3af8b6149a04f942c0df9988f1cf09a7fabadd8a09a977d374c6de3ca21886f4955045251c565272ff75daa72787a5438ef22f5067a473fa8ff3c6
|
data/lib/sass-aleksi.rb
CHANGED
data/stylesheets/_aleksi.scss
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
|
9
9
|
// LIBRARIES/FRAMEWORKS
|
10
10
|
@import "SassyCast";
|
11
|
-
@import "SassyStrings";
|
12
11
|
@import "SassyLists";
|
13
12
|
@import "sassy-maps";
|
14
13
|
|
@@ -17,6 +16,7 @@
|
|
17
16
|
@import "aleksi/general";
|
18
17
|
@import "aleksi/math";
|
19
18
|
@import "aleksi/lengths";
|
19
|
+
@import "aleksi/strings";
|
20
20
|
@import "aleksi/colors";
|
21
21
|
@import "aleksi/lists";
|
22
22
|
@import "aleksi/maps";
|
@@ -0,0 +1,11 @@
|
|
1
|
+
// =============================================================================
|
2
|
+
// =ALEKSI - STRINGS
|
3
|
+
// =============================================================================
|
4
|
+
//// Tools to work with sass strings.
|
5
|
+
//// @author [Hugo Giraudel](http://hugogiraudel.com)
|
6
|
+
//// @author [Yoannis Jamar](http://yoannis.me)
|
7
|
+
|
8
|
+
@import "aleksi/strings/char-at";
|
9
|
+
@import "aleksi/strings/str-replace";
|
10
|
+
@import "aleksi/strings/str-remove";
|
11
|
+
@import "aleksi/strings/str-explode";
|
@@ -49,6 +49,10 @@ $CONSTANTS: () !default;
|
|
49
49
|
/// @throw Error if $name is not a full-caps name or contains hyphens.
|
50
50
|
/// @throw Error if $name is already a defined constant.
|
51
51
|
///
|
52
|
+
/// @note When redefining a constant with the same value, no error will be
|
53
|
+
/// thrown. This is to deal with cases where the file defining the constant
|
54
|
+
/// is imported multiple times by sass.
|
55
|
+
///
|
52
56
|
/// @example scss
|
53
57
|
/// @include const('HOURS_IN_DAY', 24);
|
54
58
|
///
|
@@ -61,12 +65,12 @@ $CONSTANTS: () !default;
|
|
61
65
|
@include throw-error('const():: $name must be string. Was #{inspect($name)}.');
|
62
66
|
}
|
63
67
|
|
64
|
-
@else if to-upper-case($name)
|
68
|
+
@else if (unquote($name) != unquote(to-upper-case($name))) or str-index($name, '-') {
|
65
69
|
@include throw-error('const():: Constant name #{inspect($name)} is not valid. Must be upper-case and without hyphens.');
|
66
70
|
}
|
67
71
|
|
68
|
-
@else if map-has-key($CONSTANTS, $name) {
|
69
|
-
@include throw-error('Constant #{inspect($name)}
|
72
|
+
@else if map-has-key($CONSTANTS, $name) and map-get($CONSANTS, $name) != $value {
|
73
|
+
@include throw-error('Constant #{inspect($name)} can not be redefined.');
|
70
74
|
}
|
71
75
|
|
72
76
|
$CONSTANTS: map-set($CONSTANTS, $name, $value) !global;
|
@@ -6,6 +6,7 @@
|
|
6
6
|
//// @author [Yoannis Jamar](http://yoannis.me)
|
7
7
|
|
8
8
|
@import "SassyLists";
|
9
|
+
@import "SassyCast";
|
9
10
|
@import "aleksi/general/throw";
|
10
11
|
@import "aleksi/maps/map-walk";
|
11
12
|
@import "aleksi/lists/set-list-separator";
|
@@ -48,7 +49,8 @@
|
|
48
49
|
}
|
49
50
|
|
50
51
|
$w: throw-warning("Walking over a simple value #{inspect($list)} — resulting value will be returned inside a list.");
|
51
|
-
@return call($func, $list, $args...);
|
52
|
+
// @return call($func, $list, $args...);
|
53
|
+
@return list-walk(to-list($list), $func, $args...);
|
52
54
|
}
|
53
55
|
|
54
56
|
// =list-walk( $list, $func[, $args... ])
|
@@ -0,0 +1,37 @@
|
|
1
|
+
// =============================================================================
|
2
|
+
// =ALEKSI - CHAR-AT
|
3
|
+
// =============================================================================
|
4
|
+
////
|
5
|
+
//// @group aleksi-strings
|
6
|
+
//// @author [Hugo Giraudel](http://hugogiraudel.com)
|
7
|
+
//// @author [Yoannis Jamar](http://yoannis.me)
|
8
|
+
//// @link https://github.com/HugoGiraudel/SassyStrings/tree/master/stylesheets/public
|
9
|
+
|
10
|
+
// =char-at( $str, $index )
|
11
|
+
// -----------------------------------------------------------------------------
|
12
|
+
/// Returns the character at a given index inside a string.
|
13
|
+
///
|
14
|
+
/// @param {string} $str - The string to search in
|
15
|
+
/// @param {number} $index - The index of the character to return
|
16
|
+
///
|
17
|
+
/// @return {string} - The character at `$index` in `$str`
|
18
|
+
/// @throw - Error if `$index` is out smaller then 0 or greater then`$str`'s length
|
19
|
+
///
|
20
|
+
/// @access public
|
21
|
+
/// @since 0.2.0
|
22
|
+
|
23
|
+
@function char-at($str, $index) {
|
24
|
+
@if type-of($str) != "string" {
|
25
|
+
@return throw-error('char-at():: $str must be a string, was #{inspect($str)}.');
|
26
|
+
}
|
27
|
+
|
28
|
+
@if type-of($index) != "number" {
|
29
|
+
@return throw-error('char-at():: $index must be a number, was #{inspect($index)}.');
|
30
|
+
}
|
31
|
+
|
32
|
+
@if $index < 1 or $index > str-length($str) {
|
33
|
+
@return throw-error('char-at():: $index #{inspect($index)} is out of bounds for \'#{$str}\'');
|
34
|
+
}
|
35
|
+
|
36
|
+
@return str-slice($str, $index, $index);
|
37
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
// =============================================================================
|
2
|
+
// =ALEKSI - STR-EXPLODE
|
3
|
+
// =============================================================================
|
4
|
+
////
|
5
|
+
//// @group aleksi-strings
|
6
|
+
//// @author [Hugo Giraudel](http://hugogiraudel.com)
|
7
|
+
//// @author [Yoannis Jamar](http://yoannis.me)
|
8
|
+
//// @link https://github.com/HugoGiraudel/SassyStrings/tree/master/stylesheets/public
|
9
|
+
|
10
|
+
// =str-explode( $str[, $delimiter ])
|
11
|
+
// -----------------------------------------------------------------------------
|
12
|
+
/// Splits a given string into several parts using `$delimiter`.
|
13
|
+
///
|
14
|
+
/// @param {string} $str - The string to split
|
15
|
+
/// @param {string} $delimiter [''] - The string to use to as a delimiter to split `$str`
|
16
|
+
///
|
17
|
+
/// @return {list} - A list containing the separated parts of `$str`.
|
18
|
+
///
|
19
|
+
/// @access public
|
20
|
+
/// @since 0.2.0
|
21
|
+
|
22
|
+
@function str-explode($str, $delimiter: '') {
|
23
|
+
@if type-of($str) != "string" {
|
24
|
+
@return throw-error('str-explode():: $str must be a string, was #{inspect($str)}.');
|
25
|
+
}
|
26
|
+
|
27
|
+
@if type-of($delimiter) != "string" {
|
28
|
+
@return throw-error('str-explode():: $delimiter must be a string, was #{inspect($delimiter)}.');
|
29
|
+
}
|
30
|
+
|
31
|
+
$result: ();
|
32
|
+
$length: str-length($str);
|
33
|
+
|
34
|
+
@if str-length($delimiter) == 0 {
|
35
|
+
@for $i from 1 through $length {
|
36
|
+
$result: append($result, str-slice($str, $i, $i));
|
37
|
+
}
|
38
|
+
|
39
|
+
@return $result;
|
40
|
+
}
|
41
|
+
|
42
|
+
$running: true;
|
43
|
+
$remaining: $str;
|
44
|
+
|
45
|
+
@while $running {
|
46
|
+
$index: str-index($remaining, $delimiter);
|
47
|
+
|
48
|
+
@if $index {
|
49
|
+
$slice: str-slice($remaining, 1, $index - 1);
|
50
|
+
$result: append($result, $slice);
|
51
|
+
$remaining: str-slice($remaining, $index + str-length($delimiter));
|
52
|
+
} @else {
|
53
|
+
$running: false;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
@return append($result, $remaining);
|
58
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
// =============================================================================
|
2
|
+
// =ALEKSI - STR-REMOVE
|
3
|
+
// =============================================================================
|
4
|
+
////
|
5
|
+
//// @group aleksi-strings
|
6
|
+
//// @author [Hugo Giraudel](http://hugogiraudel.com)
|
7
|
+
//// @author [Yoannis Jamar](http://yoannis.me)
|
8
|
+
//// @link https://github.com/HugoGiraudel/SassyStrings/tree/master/stylesheets/public
|
9
|
+
|
10
|
+
@import "aleksi/strings/str-replace";
|
11
|
+
|
12
|
+
// =str-remove( $str, $search )
|
13
|
+
// -----------------------------------------------------------------------------
|
14
|
+
/// Removes all occurences of a substring inside a given string.
|
15
|
+
/// Delegates to `str-replace`
|
16
|
+
///
|
17
|
+
/// @param {string} $str - The string to search in
|
18
|
+
/// @param {string} $search - The substring to search for
|
19
|
+
///
|
20
|
+
/// @see {function} str-replace
|
21
|
+
///
|
22
|
+
/// @return {string} - `$str` without any occurence of `$search`
|
23
|
+
///
|
24
|
+
/// @access public
|
25
|
+
/// @since 0.2.0
|
26
|
+
|
27
|
+
@function str-remove($str, $search) {
|
28
|
+
@if type-of($str) != "string" {
|
29
|
+
@return throw-error('str-remove():: $str must be a string, was #{inspect($str)}.');
|
30
|
+
}
|
31
|
+
|
32
|
+
@if type-of($search) != "string" {
|
33
|
+
@return throw-error('str-remove():: $search must be a string, was #{inspect($search)}.');
|
34
|
+
}
|
35
|
+
|
36
|
+
@return str-replace($str, $search, '');
|
37
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
// =============================================================================
|
2
|
+
// =ALEKSI - STR-REPLACE
|
3
|
+
// =============================================================================
|
4
|
+
////
|
5
|
+
//// @group aleksi-strings
|
6
|
+
//// @author [Hugo Giraudel](http://hugogiraudel.com)
|
7
|
+
//// @author [Yoannis Jamar](http://yoannis.me)
|
8
|
+
//// @link https://github.com/HugoGiraudel/SassyStrings/tree/master/stylesheets/public
|
9
|
+
|
10
|
+
// =str-replace( $str, $search, $replace )
|
11
|
+
// -----------------------------------------------------------------------------
|
12
|
+
/// Replaces all occurences of a substring inside a given string.
|
13
|
+
///
|
14
|
+
/// @param {string} $str - The string to search in
|
15
|
+
/// @param {string} $search - The substring to search for
|
16
|
+
/// @param {string} $replace - The substring to replace `$search` with
|
17
|
+
///
|
18
|
+
/// @return {string} - `$str` with `$search` replaced by `$replace`
|
19
|
+
///
|
20
|
+
/// @access public
|
21
|
+
/// @since 0.2.0
|
22
|
+
|
23
|
+
@function str-replace($str, $search, $replace: '') {
|
24
|
+
@if type-of($str) != "string" {
|
25
|
+
@return throw-error('str-replace():: $str must be a string, was #{inspect($str)}.');
|
26
|
+
}
|
27
|
+
|
28
|
+
@if type-of($search) != "string" {
|
29
|
+
@return throw-error('str-replace():: $search must be a string, was #{inspect($search)}.');
|
30
|
+
}
|
31
|
+
|
32
|
+
@if type-of($replace) != "string" {
|
33
|
+
@return throw-error('str-replace():: $replace must be a string, was #{inspect($replace)}.');
|
34
|
+
}
|
35
|
+
|
36
|
+
$index: str-index($str, $search);
|
37
|
+
|
38
|
+
@if $index {
|
39
|
+
@return str-slice($str, 1, $index - 1) + $replace + str-replace(str-slice($str, $index + str-length($search)), $search, $replace);
|
40
|
+
}
|
41
|
+
|
42
|
+
@return $str;
|
43
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass-aleksi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoannis Jamar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.5'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: SassyStrings
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.1'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '1.1'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: SassyLists
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,6 +112,7 @@ files:
|
|
126
112
|
- stylesheets/aleksi/_maps.scss
|
127
113
|
- stylesheets/aleksi/_math.scss
|
128
114
|
- stylesheets/aleksi/_sides.scss
|
115
|
+
- stylesheets/aleksi/_strings.scss
|
129
116
|
- stylesheets/aleksi/config/_constants.scss
|
130
117
|
- stylesheets/aleksi/general/_apply.scss
|
131
118
|
- stylesheets/aleksi/general/_css-rule.scss
|
@@ -171,6 +158,10 @@ files:
|
|
171
158
|
- stylesheets/aleksi/sides/_sides-shorthand.scss
|
172
159
|
- stylesheets/aleksi/sides/_to-sides-list.scss
|
173
160
|
- stylesheets/aleksi/sides/_to-sides-map.scss
|
161
|
+
- stylesheets/aleksi/strings/_char-at.scss
|
162
|
+
- stylesheets/aleksi/strings/_str-explode.scss
|
163
|
+
- stylesheets/aleksi/strings/_str-remove.scss
|
164
|
+
- stylesheets/aleksi/strings/_str-replace.scss
|
174
165
|
homepage: https://github.com/yoannisj/sass-aleksi
|
175
166
|
licenses:
|
176
167
|
- MIT
|