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 CHANGED
@@ -1 +1 @@
1
- 1.0.10
1
+ 1.0.11
data/less.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{less}
5
- s.version = "1.0.9"
5
+ s.version = "1.0.10"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["cloudhead"]
@@ -15,13 +15,15 @@ module Less
15
15
  include Literal
16
16
  attr_reader :r, :g, :b, :a
17
17
 
18
- def initialize(r, g, b, a = 1.0)
19
- r, g, b = [r, g, b].map {|c| c.is_a?(::String) ? c.to_i(16) : c }
20
- @r, @g, @b, @a = normalize(r), normalize(g), normalize(b), normalize(a, 1.0)
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(v)
24
- self.class.new(r,g,b,v)
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
- self.class.new *self.rgb.map {|c| c.send(op, other) }, @a
34
+ color = if other.is_a? Numeric
35
+ rgb.map {|c| c.send(op, other) }
34
36
  else
35
- self.class.new *self.rgb.zip(other.rgb).map {|a, b| a.send(op, b) }, @a
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
- operate :+, other
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
- "Color.new(#{r},#{g},#{b},#{a})"
72
+ "#{self.class}.new(#{r},#{g},#{b},#{a})"
81
73
  end
82
74
 
83
75
  protected
@@ -98,7 +98,7 @@ module Less
98
98
  if result.is_a? Entity
99
99
  result
100
100
  else
101
- entity.class.new(*result, *(unit if entity.class == Node::Number))
101
+ entity.class.new(result, *(unit if entity.class == Node::Number))
102
102
  end
103
103
  else
104
104
  first
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(Exception)
17
- PathError = Class.new(Exception)
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(Exception)
21
+ ImportError = Class.new(RuntimeError)
22
22
 
23
23
  $verbose = false
24
24
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudhead-less
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - cloudhead