cloudhead-less 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/less.gemspec +1 -1
- data/lib/less/engine/nodes/literal.rb +17 -25
- data/lib/less/engine/nodes/property.rb +1 -1
- data/lib/less.rb +3 -3
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.11
|
data/less.gemspec
CHANGED
@@ -15,13 +15,15 @@ module Less
|
|
15
15
|
include Literal
|
16
16
|
attr_reader :r, :g, :b, :a
|
17
17
|
|
18
|
-
def initialize
|
19
|
-
r, g, b = [r, g, b].map
|
20
|
-
|
18
|
+
def initialize r, g, b, a = 1.0
|
19
|
+
@r, @g, @b = [r, g, b].map do |c|
|
20
|
+
normalize(c.is_a?(::String) ? c.to_i(16) : c)
|
21
|
+
end
|
22
|
+
@a = normalize(a, 1.0)
|
21
23
|
end
|
22
24
|
|
23
|
-
def alpha
|
24
|
-
self.class.new
|
25
|
+
def alpha v
|
26
|
+
self.class.new r, g, b, v
|
25
27
|
end
|
26
28
|
|
27
29
|
def rgb
|
@@ -29,28 +31,18 @@ module Less
|
|
29
31
|
end
|
30
32
|
|
31
33
|
def operate op, other
|
32
|
-
if other.is_a? Numeric
|
33
|
-
|
34
|
+
color = if other.is_a? Numeric
|
35
|
+
rgb.map {|c| c.send(op, other) }
|
34
36
|
else
|
35
|
-
|
37
|
+
rgb.zip(other.rgb).map {|a, b| a.send(op, b) }
|
36
38
|
end
|
39
|
+
self.class.new *[color, @a].flatten # Ruby 1.8 hack
|
37
40
|
end
|
38
41
|
|
39
|
-
def + other
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
def - other
|
44
|
-
operate :-, other
|
45
|
-
end
|
46
|
-
|
47
|
-
def * other
|
48
|
-
operate :*, other
|
49
|
-
end
|
50
|
-
|
51
|
-
def / other
|
52
|
-
operate :/, other
|
53
|
-
end
|
42
|
+
def + other; operate :+, other end
|
43
|
+
def - other; operate :-, other end
|
44
|
+
def * other; operate :*, other end
|
45
|
+
def / other; operate :/, other end
|
54
46
|
|
55
47
|
def coerce other
|
56
48
|
return self, other
|
@@ -60,7 +52,7 @@ module Less
|
|
60
52
|
if a < 1.0
|
61
53
|
"rgba(#{r.to_i}, #{g.to_i}, #{b.to_i}, #{a})"
|
62
54
|
else
|
63
|
-
"#%02x%02x%02x" % [r,g,b]
|
55
|
+
"#%02x%02x%02x" % [r, g, b]
|
64
56
|
end
|
65
57
|
end
|
66
58
|
|
@@ -77,7 +69,7 @@ module Less
|
|
77
69
|
end
|
78
70
|
|
79
71
|
def to_ruby
|
80
|
-
"
|
72
|
+
"#{self.class}.new(#{r},#{g},#{b},#{a})"
|
81
73
|
end
|
82
74
|
|
83
75
|
protected
|
data/lib/less.rb
CHANGED
@@ -13,12 +13,12 @@ require 'less/command'
|
|
13
13
|
require 'less/engine'
|
14
14
|
|
15
15
|
module Less
|
16
|
-
MixedUnitsError = Class.new(
|
17
|
-
PathError = Class.new(
|
16
|
+
MixedUnitsError = Class.new(RuntimeError)
|
17
|
+
PathError = Class.new(RuntimeError)
|
18
18
|
VariableNameError = Class.new(NameError)
|
19
19
|
MixinNameError = Class.new(NameError)
|
20
20
|
SyntaxError = Class.new(RuntimeError)
|
21
|
-
ImportError = Class.new(
|
21
|
+
ImportError = Class.new(RuntimeError)
|
22
22
|
|
23
23
|
$verbose = false
|
24
24
|
|