SassyCast 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +1 -0
- data/README.md +14 -0
- data/lib/SassyCast.rb +2 -2
- data/stylesheets/private/bool/_bool.scss +5 -11
- data/stylesheets/private/color/_color.scss +16 -23
- data/stylesheets/private/color/helpers/_from-hex.scss +8 -11
- data/stylesheets/private/color/helpers/_from-hsl.scss +7 -10
- data/stylesheets/private/color/helpers/_from-rgb.scss +6 -9
- data/stylesheets/private/color/helpers/_get-color-value.scss +6 -9
- data/stylesheets/private/color/helpers/_hex-to-dec.scss +7 -11
- data/stylesheets/private/list/_list.scss +10 -16
- data/stylesheets/private/map/_map.scss +15 -20
- data/stylesheets/private/null/_null.scss +4 -11
- data/stylesheets/private/number/_number.scss +9 -16
- data/stylesheets/private/number/helpers/_find-digits.scss +8 -12
- data/stylesheets/private/number/helpers/_find-integer.scss +7 -11
- data/stylesheets/private/number/helpers/_length.scss +10 -14
- data/stylesheets/private/number/helpers/_pow.scss +6 -10
- data/stylesheets/private/string/_string.scss +6 -11
- data/stylesheets/public/bool/_bool.scss +2 -12
- data/stylesheets/public/color/_color.scss +2 -12
- data/stylesheets/public/list/_list.scss +2 -12
- data/stylesheets/public/map/_map.scss +2 -12
- data/stylesheets/public/null/_null.scss +1 -11
- data/stylesheets/public/number/_number.scss +2 -12
- data/stylesheets/public/string/_string.scss +2 -11
- metadata +22 -20
- checksums.yaml +0 -7
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,20 @@ SassyCast
|
|
3
3
|
|
4
4
|
SassyCast is a simple API for type conversion in Sass.
|
5
5
|
|
6
|
+
# Installation
|
7
|
+
|
8
|
+
Clone repository or download [from Github](https://github.com/HugoGiraudel/SassyCast/archive/master.zip).
|
9
|
+
|
10
|
+
## Install via ruby gems
|
11
|
+
```
|
12
|
+
gem install SassyCast
|
13
|
+
````
|
14
|
+
|
15
|
+
## Install via bower
|
16
|
+
```
|
17
|
+
bower install sassy-cast
|
18
|
+
```
|
19
|
+
|
6
20
|
## `to-bool`
|
7
21
|
|
8
22
|
``` scss
|
data/lib/SassyCast.rb
CHANGED
@@ -5,8 +5,8 @@ Compass::Frameworks.register('SassyCast', :path => extension_path)
|
|
5
5
|
# Version is a number. If a version contains alphas, it will be created as a prerelease version
|
6
6
|
# Date is in the form of YYYY-MM-DD
|
7
7
|
module SassyCast
|
8
|
-
VERSION = "1.1.
|
9
|
-
DATE = "2014-
|
8
|
+
VERSION = "1.1.1"
|
9
|
+
DATE = "2014-12-31"
|
10
10
|
end
|
11
11
|
|
12
12
|
module Sass::Script::Functions
|
@@ -1,16 +1,10 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
|
4
|
-
* @access private
|
5
|
-
* ---
|
6
|
-
* @param {*} $value - value to cast
|
7
|
-
* ---
|
8
|
-
* @return {bool}
|
9
|
-
*/
|
10
|
-
|
1
|
+
/// Convert to bool
|
2
|
+
/// @param {*} $value - value to cast
|
3
|
+
/// @return {Bool}
|
11
4
|
@function _sc-to-bool($value) {
|
12
5
|
@if not $value or $value == "" or $value == 0 {
|
13
6
|
@return false;
|
14
7
|
}
|
8
|
+
|
15
9
|
@return true;
|
16
|
-
}
|
10
|
+
}
|
@@ -1,23 +1,16 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
|
4
|
-
* @access private
|
5
|
-
* ---
|
6
|
-
* @param {*} $value - value to cast
|
7
|
-
* ---
|
8
|
-
* @return {color | null}
|
9
|
-
*/
|
10
|
-
|
1
|
+
/// Convert to color
|
2
|
+
/// @param {*} $value - value to cast
|
3
|
+
/// @return {color | null}
|
11
4
|
@function _sc-to-color($value) {
|
12
|
-
@if type-of($value) == color {
|
5
|
+
@if type-of($value) == "color" {
|
13
6
|
@return $value;
|
14
7
|
}
|
15
8
|
|
16
|
-
@if type-of($value) != string {
|
9
|
+
@if type-of($value) != "string" {
|
17
10
|
//@warn "Could not cast `#{inspect($value)}` to color.";
|
18
11
|
@return null;
|
19
12
|
}
|
20
|
-
|
13
|
+
|
21
14
|
$value-lower: to-lower-case($value);
|
22
15
|
$colors: transparent black silver gray white maroon red purple fuchsia green lime olive yellow navy blue teal aqua aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen;
|
23
16
|
$keywords: ();
|
@@ -26,35 +19,35 @@
|
|
26
19
|
@each $color in $colors {
|
27
20
|
$keywords: append($keywords, $color + "");
|
28
21
|
}
|
29
|
-
|
22
|
+
|
30
23
|
// Deal with inherit keyword
|
31
24
|
@if $value-lower == "inherit" {
|
32
25
|
@return unquote($value);
|
33
26
|
}
|
34
|
-
|
27
|
+
|
35
28
|
// Deal with color keywords
|
36
29
|
@if index($keywords, $value-lower) {
|
37
30
|
@return nth($colors, index($keywords, $value-lower));
|
38
31
|
}
|
39
|
-
|
32
|
+
|
40
33
|
// Deal with hexadecimal triplets
|
41
|
-
@else if str-slice($value-lower, 1, 1) ==
|
34
|
+
@else if str-slice($value-lower, 1, 1) == "#" {
|
42
35
|
@return _sc-from-hex($value);
|
43
36
|
}
|
44
|
-
|
37
|
+
|
45
38
|
// Deal with rgb(a) colors
|
46
|
-
@else if str-slice($value-lower, 1, 3) ==
|
39
|
+
@else if str-slice($value-lower, 1, 3) == "rgb" {
|
47
40
|
@return _sc-from-rgb($value);
|
48
41
|
}
|
49
|
-
|
42
|
+
|
50
43
|
// Deal with hsl(a) colors
|
51
|
-
@else if str-slice($value-lower, 1, 3) ==
|
44
|
+
@else if str-slice($value-lower, 1, 3) == "hsl" {
|
52
45
|
@return _sc-from-hsl($value);
|
53
46
|
}
|
54
|
-
|
47
|
+
|
55
48
|
// Return value
|
56
49
|
@else {
|
57
50
|
//@warn "Could not cast `#{inspect($value)}` to color.";
|
58
51
|
@return null;
|
59
52
|
}
|
60
|
-
}
|
53
|
+
}
|
@@ -1,11 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
* @return {color|string} - string or hex color depending on the match
|
7
|
-
*/
|
8
|
-
|
1
|
+
/// Cast a string into a hexadecimal color
|
2
|
+
/// @access private
|
3
|
+
/// @param {string} $string - string
|
4
|
+
/// @return {Color | String} - string or hex color depending on the match
|
5
|
+
/// @require {function} _hex-to-dec
|
9
6
|
@function _sc-from-hex($string) {
|
10
7
|
$string-lower: to-lower-case($string);
|
11
8
|
$r: ""; $g: ""; $b: "";
|
@@ -31,12 +28,12 @@
|
|
31
28
|
@else if str-length($g) < $max { $g: $g + $c }
|
32
29
|
@else if str-length($b) < $max { $b: $b + $c }
|
33
30
|
}
|
34
|
-
|
31
|
+
|
35
32
|
@if $length == 4 {
|
36
33
|
$r: $r + $r;
|
37
34
|
$g: $g + $g;
|
38
35
|
$b: $b + $b;
|
39
36
|
}
|
40
|
-
|
37
|
+
|
41
38
|
@return rgb(_hex-to-dec($r), _hex-to-dec($g), _hex-to-dec($b));
|
42
|
-
}
|
39
|
+
}
|
@@ -1,11 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
* @return {color|string} - string or hsl color depending on the match
|
7
|
-
*/
|
8
|
-
|
1
|
+
/// Cast a string into a hsl color
|
2
|
+
/// @access private
|
3
|
+
/// @param {string} $string - string
|
4
|
+
/// @return {Color | String} - string or hsl color depending on the match
|
5
|
+
/// @require {function} _get-color-value
|
9
6
|
@function _sc-from-hsl($string) {
|
10
7
|
$frags: ();
|
11
8
|
$string-lower: to-lower-case($string);
|
@@ -43,7 +40,7 @@
|
|
43
40
|
@else {
|
44
41
|
$frags: set-nth($frags, length($frags), nth($frags, length($frags)) + $token);
|
45
42
|
}
|
46
|
-
}
|
43
|
+
}
|
47
44
|
|
48
45
|
@return $string;
|
49
|
-
}
|
46
|
+
}
|
@@ -1,11 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
* @return {color|string} - string or rgb color depending on the match
|
7
|
-
*/
|
8
|
-
|
1
|
+
/// Cast a string into a rgb color
|
2
|
+
/// @access private
|
3
|
+
/// @param {String} $string - string
|
4
|
+
/// @return {Color | String} - string or rgb color depending on the match
|
5
|
+
/// @require {function} _get-color-value
|
9
6
|
@function _sc-from-rgb($string) {
|
10
7
|
$string-lower: to-lower-case($string);
|
11
8
|
$frags: ();
|
@@ -43,7 +40,7 @@
|
|
43
40
|
@else {
|
44
41
|
$frags: set-nth($frags, length($frags), nth($frags, length($frags)) + $token);
|
45
42
|
}
|
46
|
-
}
|
43
|
+
}
|
47
44
|
|
48
45
|
@return $string;
|
49
46
|
}
|
@@ -1,11 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
* @return {number} - unitless number or percentage
|
7
|
-
*/
|
8
|
-
|
1
|
+
/// Cast a stringified number / stringified percentage into number type
|
2
|
+
/// @access private
|
3
|
+
/// @param {string} $string - string
|
4
|
+
/// @return {Number} - unitless number or percentage
|
5
|
+
/// @require {function} to-number
|
9
6
|
@function _sc-get-color-value($string) {
|
10
7
|
$first: str-slice($string, 1, 1);
|
11
8
|
|
@@ -15,6 +12,6 @@
|
|
15
12
|
}
|
16
13
|
|
17
14
|
$last: str-slice($string, -1, -1);
|
18
|
-
|
15
|
+
|
19
16
|
@return if($last == '%', to-number(str-slice($string, 1, -2), 2) * 1%, to-number($string));
|
20
17
|
}
|
@@ -1,22 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
* ---
|
6
|
-
* @return {number} - decimal number
|
7
|
-
*/
|
8
|
-
|
1
|
+
/// Convert an hexadecimal number to a decimal number
|
2
|
+
/// @access private
|
3
|
+
/// @param {String} $string - hexadecimal value
|
4
|
+
/// @return {Number} - decimal number
|
9
5
|
@function _sc-hex-to-dec($string){
|
10
6
|
$hex: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f";
|
11
7
|
$string: to-lower-case($string);
|
12
8
|
$length: str-length($string);
|
13
|
-
|
9
|
+
|
14
10
|
$dec: 0;
|
15
11
|
@for $i from 1 through $length {
|
16
12
|
$factor: 1 + ( 15 * ( $length - $i ));
|
17
13
|
$index: index($hex, str-slice($string, $i, $i));
|
18
14
|
$dec: $dec + $factor * ($index - 1);
|
19
15
|
}
|
20
|
-
|
16
|
+
|
21
17
|
@return $dec;
|
22
|
-
}
|
18
|
+
}
|
@@ -1,17 +1,11 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
* ---
|
8
|
-
* @return {list}
|
9
|
-
*/
|
1
|
+
/// Convert to list
|
2
|
+
/// @param {*} $value - value to cast
|
3
|
+
/// @param {String} $keep ("both") - whether to keep `keys`, `values` or `both` when casting a map
|
4
|
+
/// @return {List}
|
5
|
+
@function _sc-to-list($value, $keep: "both") {
|
6
|
+
$keep: if(index("keys" "values" "both", $keep), $keep, "both");
|
10
7
|
|
11
|
-
@
|
12
|
-
$keep: if(index('keys' 'values' 'both', $keep), $keep, 'both');
|
13
|
-
|
14
|
-
@if type-of($value) == map {
|
8
|
+
@if type-of($value) == "map" {
|
15
9
|
$keys: ();
|
16
10
|
$values: ();
|
17
11
|
@each $key, $val in $value {
|
@@ -19,10 +13,10 @@
|
|
19
13
|
$values: append($values, $val);
|
20
14
|
}
|
21
15
|
|
22
|
-
@if $keep ==
|
16
|
+
@if $keep == "keys" {
|
23
17
|
@return $keys;
|
24
18
|
}
|
25
|
-
@else if $keep ==
|
19
|
+
@else if $keep == "values" {
|
26
20
|
@return $values;
|
27
21
|
}
|
28
22
|
@else {
|
@@ -31,4 +25,4 @@
|
|
31
25
|
}
|
32
26
|
|
33
27
|
@return if(type-of($value) != list, ($value,), $value);
|
34
|
-
}
|
28
|
+
}
|
@@ -1,23 +1,18 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
|
4
|
-
* @access private
|
5
|
-
* ---
|
6
|
-
* @param {*} $value - value to cast
|
7
|
-
* ---
|
8
|
-
* @return {map}
|
9
|
-
*/
|
10
|
-
|
1
|
+
/// Convert to map
|
2
|
+
/// @param {*} $value - value to cast
|
3
|
+
/// @return {Map}
|
11
4
|
@function _sc-to-map($value) {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@return $map;
|
5
|
+
@if type-of($value) == "list" {
|
6
|
+
$map: ();
|
7
|
+
|
8
|
+
@if length($value) > 1 {
|
9
|
+
@for $i from 1 through length($value) {
|
10
|
+
$map: map-merge($map, ($i: nth($value, $i)));
|
11
|
+
}
|
20
12
|
}
|
21
13
|
|
22
|
-
@return
|
23
|
-
}
|
14
|
+
@return $map;
|
15
|
+
}
|
16
|
+
|
17
|
+
@return if(type-of($value) != map, (1: $value), $value);
|
18
|
+
}
|
@@ -1,13 +1,6 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
|
4
|
-
* @access private
|
5
|
-
* ---
|
6
|
-
* @param {*} $value - value to cast
|
7
|
-
* ---
|
8
|
-
* @return null
|
9
|
-
*/
|
10
|
-
|
1
|
+
/// Convert to null
|
2
|
+
/// @param {*} $value - value to cast
|
3
|
+
/// @return {Null}
|
11
4
|
@function _sc-to-null($value) {
|
12
5
|
@return null;
|
13
|
-
}
|
6
|
+
}
|
@@ -1,16 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
* @access private
|
5
|
-
* ---
|
6
|
-
* @param {string} $value - complete source
|
7
|
-
* ---
|
8
|
-
* @return {number}
|
9
|
-
*/
|
10
|
-
|
1
|
+
/// Cast a value to a number if possible or return 0
|
2
|
+
/// @param {String} $value - complete source
|
3
|
+
/// @return {Number}
|
11
4
|
@function _sc-to-number($value) {
|
12
5
|
// In case everything's good
|
13
|
-
@if type-of($value) == number {
|
6
|
+
@if type-of($value) == "number" {
|
14
7
|
@return $value;
|
15
8
|
}
|
16
9
|
|
@@ -20,16 +13,16 @@
|
|
20
13
|
}
|
21
14
|
|
22
15
|
// Fail
|
23
|
-
@if type-of($value) != string {
|
16
|
+
@if type-of($value) != "string" {
|
24
17
|
@return 0;
|
25
18
|
}
|
26
19
|
|
27
20
|
// Trying to cast
|
28
21
|
$pointer: 1;
|
29
22
|
$result: 0;
|
30
|
-
$allowed:
|
23
|
+
$allowed: "-" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9"; // Allowed characted to start with
|
31
24
|
$first: str-slice($value, $pointer, $pointer); // First character of the number
|
32
|
-
$minus: $first ==
|
25
|
+
$minus: $first == "-"; // Is it negative?
|
33
26
|
|
34
27
|
// Early check for errors
|
35
28
|
@if not index($allowed, $first) {
|
@@ -43,7 +36,7 @@
|
|
43
36
|
$result: nth($find-integer, 2);
|
44
37
|
|
45
38
|
// Find digits
|
46
|
-
@if str-slice($value, $pointer, $pointer) ==
|
39
|
+
@if str-slice($value, $pointer, $pointer) == "." {
|
47
40
|
$find-digits: _sc-find-digits($value, $pointer);
|
48
41
|
$pointer: nth($find-digits, 1);
|
49
42
|
$digits: nth($find-digits, 2);
|
@@ -61,4 +54,4 @@
|
|
61
54
|
}
|
62
55
|
|
63
56
|
@return $result;
|
64
|
-
}
|
57
|
+
}
|
@@ -1,16 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
* ---
|
7
|
-
* @return {list} - new pointer, parsed number
|
8
|
-
*/
|
9
|
-
|
1
|
+
/// Finding the digits part of a stringified number
|
2
|
+
/// @access private
|
3
|
+
/// @param {string} $source - string source
|
4
|
+
/// @param {Number} $pointer - current pointer
|
5
|
+
/// @return {List} - new pointer, parsed number
|
10
6
|
@function _sc-find-digits($source, $pointer) {
|
11
7
|
$source: to-lower-case($source);
|
12
8
|
$length: str-length($source);
|
13
|
-
$numbers:
|
9
|
+
$numbers: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9";
|
14
10
|
$result: 0;
|
15
11
|
$runs: 1;
|
16
12
|
|
@@ -18,7 +14,7 @@
|
|
18
14
|
$token: str-slice($source, $pointer, $pointer);
|
19
15
|
$index: index($numbers, $token);
|
20
16
|
|
21
|
-
@if $token ==
|
17
|
+
@if $token == "." {
|
22
18
|
// @continue;
|
23
19
|
}
|
24
20
|
@else if $index and $index > 0 {
|
@@ -33,4 +29,4 @@
|
|
33
29
|
}
|
34
30
|
|
35
31
|
@return $pointer, $result / $runs;
|
36
|
-
}
|
32
|
+
}
|
@@ -1,23 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
* ---
|
7
|
-
* @return {list} new pointer, parsed number
|
8
|
-
*/
|
9
|
-
|
1
|
+
/// Finding the integer part of a stringified number
|
2
|
+
/// @access private
|
3
|
+
/// @param {String} $source - string source
|
4
|
+
/// @param {Number} $pointer - current pointer
|
5
|
+
/// @return {List} new pointer, parsed number
|
10
6
|
@function _sc-find-integer($source, $pointer) {
|
11
7
|
$source: to-lower-case($source);
|
12
8
|
$length: str-length($source);
|
13
|
-
$numbers:
|
9
|
+
$numbers: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9";
|
14
10
|
$result: 0;
|
15
11
|
|
16
12
|
@while $pointer <= $length {
|
17
13
|
$token: str-slice($source, $pointer, $pointer);
|
18
14
|
$index: index($numbers, $token);
|
19
15
|
|
20
|
-
@if $token ==
|
16
|
+
@if $token == "-" {
|
21
17
|
// @continue;
|
22
18
|
}
|
23
19
|
@else if $index {
|
@@ -1,21 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
* ---
|
7
|
-
* @return {number} length (0 if cast failed)
|
8
|
-
*/
|
9
|
-
|
1
|
+
/// Tries to find a unit that would match a CSS length
|
2
|
+
/// @access private
|
3
|
+
/// @param {Number} $number - number
|
4
|
+
/// @param {String} $unit - potential unit
|
5
|
+
/// @return {Number} length (0 if cast failed)
|
10
6
|
@function _sc-length($number, $unit) {
|
11
|
-
$strings: 'px' 'cm' 'mm' '%' 'ch' '
|
12
|
-
$units: 1px 1cm 1mm 1% 1ch
|
7
|
+
$strings: 'px' 'cm' 'mm' '%' 'ch' 'pc' 'in' 'em' 'rem' 'pt' 'pc' 'ex' 'vw' 'vh' 'vmin' 'vmax';
|
8
|
+
$units: 1px 1cm 1mm 1% 1ch 1pc 1in 1em 1rem 1pt 1pc 1ex 1vw 1vh 1vmin 1vmax;
|
13
9
|
$index: index($strings, $unit);
|
14
|
-
|
10
|
+
|
15
11
|
@if not $index {
|
16
12
|
@warn "Unknown unit `#{inspect($unit)}`.";
|
17
13
|
@return 0;
|
18
14
|
}
|
19
|
-
|
15
|
+
|
20
16
|
@return $number * nth($units, $index);
|
21
|
-
}
|
17
|
+
}
|
@@ -1,12 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
* ---
|
7
|
-
* @return [number] $x ^ $n
|
8
|
-
*/
|
9
|
-
|
1
|
+
/// Power function
|
2
|
+
/// @access private
|
3
|
+
/// @param {Number} $x - number
|
4
|
+
/// @param {Number} $n - power
|
5
|
+
/// @return {Number} $x ^ $n
|
10
6
|
@function _sc-pow($x, $n) {
|
11
7
|
$ret: 1;
|
12
8
|
|
@@ -21,4 +17,4 @@
|
|
21
17
|
}
|
22
18
|
|
23
19
|
@return $ret;
|
24
|
-
}
|
20
|
+
}
|
@@ -1,15 +1,10 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
|
4
|
-
* ---
|
5
|
-
* @param {*} $value - value to cast
|
6
|
-
* ---
|
7
|
-
* @return {string}
|
8
|
-
*/
|
9
|
-
|
1
|
+
/// Convert to string
|
2
|
+
/// @param {*} $value - value to cast
|
3
|
+
/// @return {String}
|
10
4
|
@function _sc-to-string($value) {
|
11
|
-
@if type-of($value) == color {
|
5
|
+
@if type-of($value) == "color" {
|
12
6
|
@warn "Beware! Sass does some color conversion. The resulting string may be different from the color input.";
|
13
7
|
}
|
8
|
+
|
14
9
|
@return if(type-of($value) != string, inspect($value), $value);
|
15
|
-
}
|
10
|
+
}
|
@@ -1,13 +1,3 @@
|
|
1
|
-
/**
|
2
|
-
* Convert to list
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @param {*} $value - value to cast
|
7
|
-
* ---
|
8
|
-
* @return {list}
|
9
|
-
*/
|
10
|
-
|
11
1
|
@function to-list($value, $keep: 'both') {
|
12
|
-
|
13
|
-
}
|
2
|
+
@return _sc-to-list($value, $keep);
|
3
|
+
}
|
@@ -1,13 +1,3 @@
|
|
1
|
-
/*
|
2
|
-
* Cast a value to a number if possible or return 0
|
3
|
-
* ---
|
4
|
-
* @access public
|
5
|
-
* ---
|
6
|
-
* @param {string} $value - complete source
|
7
|
-
* ---
|
8
|
-
* @return {number}
|
9
|
-
*/
|
10
|
-
|
11
1
|
@function to-number($value) {
|
12
|
-
|
13
|
-
}
|
2
|
+
@return _sc-to-number($value);
|
3
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: SassyCast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Hugo Giraudel
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
+
date: 2014-12-31 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
14
|
description: Sass API for type conversion.
|
14
15
|
email:
|
@@ -20,53 +21,54 @@ files:
|
|
20
21
|
- README.md
|
21
22
|
- CHANGELOG.md
|
22
23
|
- lib/SassyCast.rb
|
23
|
-
- stylesheets/
|
24
|
+
- stylesheets/SassyCast.scss
|
24
25
|
- stylesheets/private/bool/_bool.scss
|
25
|
-
- stylesheets/private/color/_color.scss
|
26
|
-
- stylesheets/private/color/helpers/_from-hex.scss
|
27
|
-
- stylesheets/private/color/helpers/_from-hsl.scss
|
28
|
-
- stylesheets/private/color/helpers/_from-rgb.scss
|
29
|
-
- stylesheets/private/color/helpers/_get-color-value.scss
|
30
|
-
- stylesheets/private/color/helpers/_hex-to-dec.scss
|
31
26
|
- stylesheets/private/list/_list.scss
|
27
|
+
- stylesheets/private/_all.scss
|
32
28
|
- stylesheets/private/map/_map.scss
|
29
|
+
- stylesheets/private/string/_string.scss
|
33
30
|
- stylesheets/private/null/_null.scss
|
34
31
|
- stylesheets/private/number/_number.scss
|
35
|
-
- stylesheets/private/number/helpers/_find-digits.scss
|
36
32
|
- stylesheets/private/number/helpers/_find-integer.scss
|
33
|
+
- stylesheets/private/number/helpers/_find-digits.scss
|
37
34
|
- stylesheets/private/number/helpers/_length.scss
|
38
35
|
- stylesheets/private/number/helpers/_pow.scss
|
39
|
-
- stylesheets/private/
|
40
|
-
- stylesheets/
|
36
|
+
- stylesheets/private/color/_color.scss
|
37
|
+
- stylesheets/private/color/helpers/_from-rgb.scss
|
38
|
+
- stylesheets/private/color/helpers/_from-hsl.scss
|
39
|
+
- stylesheets/private/color/helpers/_get-color-value.scss
|
40
|
+
- stylesheets/private/color/helpers/_hex-to-dec.scss
|
41
|
+
- stylesheets/private/color/helpers/_from-hex.scss
|
41
42
|
- stylesheets/public/bool/_bool.scss
|
42
|
-
- stylesheets/public/color/_color.scss
|
43
43
|
- stylesheets/public/list/_list.scss
|
44
|
+
- stylesheets/public/_all.scss
|
44
45
|
- stylesheets/public/map/_map.scss
|
46
|
+
- stylesheets/public/string/_string.scss
|
45
47
|
- stylesheets/public/null/_null.scss
|
46
48
|
- stylesheets/public/number/_number.scss
|
47
|
-
- stylesheets/public/
|
48
|
-
- stylesheets/SassyCast.scss
|
49
|
+
- stylesheets/public/color/_color.scss
|
49
50
|
homepage: https://github.com/HugoGiraudel/SassyCast/
|
50
51
|
licenses: []
|
51
|
-
metadata: {}
|
52
52
|
post_install_message:
|
53
53
|
rdoc_options: []
|
54
54
|
require_paths:
|
55
55
|
- lib
|
56
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
57
58
|
requirements:
|
58
|
-
- - '>='
|
59
|
+
- - ! '>='
|
59
60
|
- !ruby/object:Gem::Version
|
60
61
|
version: '0'
|
61
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
62
64
|
requirements:
|
63
|
-
- - '>='
|
65
|
+
- - ! '>='
|
64
66
|
- !ruby/object:Gem::Version
|
65
67
|
version: 1.3.6
|
66
68
|
requirements: []
|
67
69
|
rubyforge_project: SassyCast
|
68
|
-
rubygems_version:
|
70
|
+
rubygems_version: 1.8.23
|
69
71
|
signing_key:
|
70
|
-
specification_version:
|
72
|
+
specification_version: 3
|
71
73
|
summary: SassyCast is a Sass-powered API for type conversion.
|
72
74
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 1a2f1dc189fde28c3eab8bdc0d8437f41f2bde33
|
4
|
-
data.tar.gz: 48f936048f7a036c01ede59ed44347f2f5410dfb
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: f6f42c4059bd809b9ac44695b689695cf2ad22e1e61825f84990b56d6dd329d0752159fdb3de8df685942a586eb4ae7ac005a3bba079222f3c0a53074a37be85
|
7
|
-
data.tar.gz: 51d15bcb539e4796ebca7d86237471acc2f0085fb78f66db35f89d7fb2f9d51e82de138a02f14ddb7495bc03e0c93a5de55cb3057069fea26725434a9ff3e7dd
|