haml-edge 2.3.85 → 2.3.86
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.
- data/EDGE_GEM_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/sass/script/functions.rb +16 -7
- data/test/sass/functions_test.rb +16 -0
- metadata +1 -1
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.86
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.86
|
@@ -126,11 +126,14 @@ module Sass::Script
|
|
126
126
|
|
127
127
|
# Creates a {Color} object from red, green, and blue values.
|
128
128
|
# @param red
|
129
|
-
# A number between 0 and 255 inclusive
|
129
|
+
# A number between 0 and 255 inclusive,
|
130
|
+
# or between 0% and 100% inclusive
|
130
131
|
# @param green
|
131
|
-
# A number between 0 and 255 inclusive
|
132
|
+
# A number between 0 and 255 inclusive,
|
133
|
+
# or between 0% and 100% inclusive
|
132
134
|
# @param blue
|
133
|
-
# A number between 0 and 255 inclusive
|
135
|
+
# A number between 0 and 255 inclusive,
|
136
|
+
# or between 0% and 100% inclusive
|
134
137
|
def rgb(red, green, blue)
|
135
138
|
rgba(red, green, blue, Number.new(1))
|
136
139
|
end
|
@@ -152,16 +155,22 @@ module Sass::Script
|
|
152
155
|
assert_type blue, :Number
|
153
156
|
assert_type alpha, :Number
|
154
157
|
|
155
|
-
[red
|
156
|
-
|
157
|
-
|
158
|
+
rgb = [red, green, blue].map do |c|
|
159
|
+
v = c.value
|
160
|
+
if c.numerator_units == ["%"] && c.denominator_units.empty?
|
161
|
+
next v * 255 / 100.0 if (0..100).include?(v)
|
162
|
+
raise ArgumentError.new("Color value #{c} must be between 0% and 100% inclusive")
|
163
|
+
else
|
164
|
+
next v if (0..255).include?(v)
|
165
|
+
raise ArgumentError.new("Color value #{v} must be between 0 and 255 inclusive")
|
166
|
+
end
|
158
167
|
end
|
159
168
|
|
160
169
|
unless (0..1).include?(alpha.value)
|
161
170
|
raise ArgumentError.new("Alpha channel #{alpha.value} must be between 0 and 1 inclusive")
|
162
171
|
end
|
163
172
|
|
164
|
-
Color.new(
|
173
|
+
Color.new(rgb + [alpha.value])
|
165
174
|
end
|
166
175
|
|
167
176
|
# Creates a {Color} object from hue, saturation, and lightness.
|
data/test/sass/functions_test.rb
CHANGED
@@ -96,6 +96,13 @@ class SassFunctionTest < Test::Unit::TestCase
|
|
96
96
|
assert_equal("#00ff7f", evaluate("rgb(0, 255, 127)"))
|
97
97
|
end
|
98
98
|
|
99
|
+
def test_rgb_percent
|
100
|
+
assert_equal("#123456", evaluate("rgb(7.1%, 20.4%, 34%)"))
|
101
|
+
assert_equal("#beaded", evaluate("rgb(74.7%, 173, 93%)"))
|
102
|
+
assert_equal("#beaded", evaluate("rgb(190, 68%, 237)"))
|
103
|
+
assert_equal("#00ff7f", evaluate("rgb(0%, 100%, 50%)"))
|
104
|
+
end
|
105
|
+
|
99
106
|
def test_rgb_tests_bounds
|
100
107
|
assert_error_message("Color value 256 must be between 0 and 255 inclusive for `rgb'",
|
101
108
|
"rgb(256, 1, 1)")
|
@@ -109,6 +116,15 @@ class SassFunctionTest < Test::Unit::TestCase
|
|
109
116
|
"rgb(-1, 1, 1)")
|
110
117
|
end
|
111
118
|
|
119
|
+
def test_rgb_test_percent_bounds
|
120
|
+
assert_error_message("Color value 100.1% must be between 0% and 100% inclusive for `rgb'",
|
121
|
+
"rgb(100.1%, 0, 0)")
|
122
|
+
assert_error_message("Color value -0.1% must be between 0% and 100% inclusive for `rgb'",
|
123
|
+
"rgb(0, -0.1%, 0)")
|
124
|
+
assert_error_message("Color value 101% must be between 0% and 100% inclusive for `rgb'",
|
125
|
+
"rgb(0, 0, 101%)")
|
126
|
+
end
|
127
|
+
|
112
128
|
def test_rgb_tests_types
|
113
129
|
assert_error_message("\"foo\" is not a number for `rgb'", "rgb(\"foo\", 10, 12)");
|
114
130
|
assert_error_message("\"foo\" is not a number for `rgb'", "rgb(10, \"foo\", 12)");
|