cloudhead-less 1.0.16 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/lessc +22 -0
- data/less.gemspec +2 -2
- data/lib/less/command.rb +20 -7
- data/lib/less/engine/less.tt +2 -3
- data/lib/less/engine/parser.rb +2 -91
- data/lib/less/engine.rb +1 -1
- data/lib/less.rb +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/bin/lessc
CHANGED
@@ -3,13 +3,23 @@
|
|
3
3
|
$:.unshift File.dirname(__FILE__) + "/../lib"
|
4
4
|
|
5
5
|
require 'optparse'
|
6
|
+
require 'rubygems'
|
6
7
|
require 'less'
|
7
8
|
|
9
|
+
begin
|
10
|
+
require 'growl'
|
11
|
+
rescue LoadError
|
12
|
+
Less::GROWL = false
|
13
|
+
else
|
14
|
+
Less::GROWL = true
|
15
|
+
end
|
16
|
+
|
8
17
|
# Argument defaults
|
9
18
|
options = {
|
10
19
|
:watch => false,
|
11
20
|
:compress => false,
|
12
21
|
:debug => false,
|
22
|
+
:growl => false
|
13
23
|
}
|
14
24
|
|
15
25
|
# Get arguments
|
@@ -22,6 +32,18 @@ opts = OptionParser.new do |o|
|
|
22
32
|
options[:watch] = true
|
23
33
|
end
|
24
34
|
|
35
|
+
# Growl
|
36
|
+
o.on("-g", "--growl", "growl notifications") do
|
37
|
+
if Less::GROWL && Growl.installed?
|
38
|
+
options[:growl] = true
|
39
|
+
elsif Less::GROWL
|
40
|
+
abort "Growl wasn't found on your system."
|
41
|
+
else
|
42
|
+
abort "Growl gem not found, please install with: " +
|
43
|
+
"`sudo gem install visionmedia-growl -s http://gems.github.com`"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
25
47
|
# Compression needs a proper algorithm
|
26
48
|
#
|
27
49
|
# o.on("-x", "--compress", "compress css file") do
|
data/less.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{less}
|
5
|
-
s.version = "1.0
|
5
|
+
s.version = "1.1.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["cloudhead"]
|
9
|
-
s.date = %q{2009-07-
|
9
|
+
s.date = %q{2009-07-24}
|
10
10
|
s.default_executable = %q{lessc}
|
11
11
|
s.description = %q{LESS is leaner CSS}
|
12
12
|
s.email = %q{self@cloudhead.net}
|
data/lib/less/command.rb
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
module Less
|
2
|
+
ESC = "\033"
|
3
|
+
RESET = "#{ESC}[0m"
|
4
|
+
|
5
|
+
GREEN = lambda {|s| "#{ESC}[1;32m#{s}#{RESET}"}
|
6
|
+
RED = lambda {|s| "#{ESC}[1;31m#{s}#{RESET}"}
|
7
|
+
YELLOW = lambda {|s| "#{ESC}[1;33m#{s}#{RESET}"}
|
8
|
+
BOLD = lambda {|s| "#{ESC}[1m#{s}#{RESET}"}
|
9
|
+
|
2
10
|
class Command
|
3
11
|
attr_accessor :source, :destination, :options
|
4
12
|
|
@@ -6,6 +14,7 @@ module Less
|
|
6
14
|
$verbose = options[:debug]
|
7
15
|
@source = options[:source]
|
8
16
|
@destination = (options[:destination] || options[:source]).gsub /\.(less|lss)/, '.css'
|
17
|
+
@growl = Growl.new if options[:growl]
|
9
18
|
@options = options
|
10
19
|
end
|
11
20
|
|
@@ -53,25 +62,26 @@ module Less
|
|
53
62
|
def parse new = false
|
54
63
|
begin
|
55
64
|
# Create a new Less object with the contents of a file
|
56
|
-
css = Less::Engine.new(File.new
|
65
|
+
css = Less::Engine.new(File.new(@source)).to_css
|
57
66
|
css = css.delete " \n" if compress?
|
58
67
|
|
59
68
|
File.open( @destination, "w" ) do |file|
|
60
69
|
file.write css
|
61
70
|
end
|
62
|
-
print "#{new ? '
|
71
|
+
print "#{GREEN['* ' + (new ? 'Created' : 'Updated')]} " +
|
72
|
+
"#{@destination.split('/').last}\n: " if watch?
|
63
73
|
rescue Errno::ENOENT => e
|
64
74
|
abort "#{e}"
|
65
75
|
rescue SyntaxError => e
|
66
|
-
err "#{e}\n", "
|
76
|
+
err "#{e}\n", "Syntax"
|
67
77
|
rescue MixedUnitsError => e
|
68
78
|
err "`#{e}` you're mixing units together! What do you expect?\n"
|
69
79
|
rescue PathError => e
|
70
80
|
err "`#{e}` was not found.\n", "Path"
|
71
81
|
rescue VariableNameError => e
|
72
|
-
err "
|
82
|
+
err "#{YELLOW[e]} is undefined.\n", "Name"
|
73
83
|
rescue MixinNameError => e
|
74
|
-
err "
|
84
|
+
err "#{YELLOW[e]} is undefined.\n", "Name"
|
75
85
|
else
|
76
86
|
true
|
77
87
|
end
|
@@ -84,7 +94,10 @@ module Less
|
|
84
94
|
|
85
95
|
def err s = '', type = ''
|
86
96
|
type = type.strip + ' ' unless type.empty?
|
87
|
-
print "!
|
97
|
+
print "#{RED["! #{type}Error"]}: #{s}"
|
98
|
+
@growl.message = "#{type}Error in #@source!" if @options[:growl]
|
99
|
+
@growl.run
|
100
|
+
false
|
88
101
|
end
|
89
102
|
end
|
90
|
-
end
|
103
|
+
end
|
data/lib/less/engine/less.tt
CHANGED
@@ -36,7 +36,7 @@ grammar Less
|
|
36
36
|
path = File.join(env.root.file, url.value)
|
37
37
|
path += '.less' unless path =~ /\.(le|c)ss$/
|
38
38
|
if File.exist? path
|
39
|
-
imported = Less::Engine.new(File.new
|
39
|
+
imported = Less::Engine.new(File.new(path)).to_tree
|
40
40
|
env.rules += imported.rules
|
41
41
|
else
|
42
42
|
raise ImportError, path
|
@@ -48,7 +48,7 @@ grammar Less
|
|
48
48
|
rule url
|
49
49
|
'url(' path:(string / [-a-zA-Z0-9_%$/.&=:;#+?]+) ')' {
|
50
50
|
def build env = nil
|
51
|
-
Node::String.new
|
51
|
+
Node::String.new CGI.unescape(path.text_value)
|
52
52
|
end
|
53
53
|
|
54
54
|
def value
|
@@ -313,7 +313,6 @@ grammar Less
|
|
313
313
|
('px'/'em'/'pc'/'%'/'pt'/'cm'/'mm')?
|
314
314
|
end
|
315
315
|
|
316
|
-
|
317
316
|
#
|
318
317
|
# Color
|
319
318
|
#
|
data/lib/less/engine/parser.rb
CHANGED
@@ -494,7 +494,7 @@ module Less
|
|
494
494
|
path = File.join(env.root.file, url.value)
|
495
495
|
path += '.less' unless path =~ /\.(le|c)ss$/
|
496
496
|
if File.exist? path
|
497
|
-
imported = Less::Engine.new(File.new
|
497
|
+
imported = Less::Engine.new(File.new(path)).to_tree
|
498
498
|
env.rules += imported.rules
|
499
499
|
else
|
500
500
|
raise ImportError, path
|
@@ -589,7 +589,7 @@ module Less
|
|
589
589
|
|
590
590
|
module Url1
|
591
591
|
def build env = nil
|
592
|
-
Node::String.new
|
592
|
+
Node::String.new CGI.unescape(path.text_value)
|
593
593
|
end
|
594
594
|
|
595
595
|
def value
|
@@ -1476,92 +1476,6 @@ module Less
|
|
1476
1476
|
r0
|
1477
1477
|
end
|
1478
1478
|
|
1479
|
-
def _nt_separator
|
1480
|
-
start_index = index
|
1481
|
-
if node_cache[:separator].has_key?(index)
|
1482
|
-
cached = node_cache[:separator][index]
|
1483
|
-
@index = cached.interval.end if cached
|
1484
|
-
return cached
|
1485
|
-
end
|
1486
|
-
|
1487
|
-
i0 = index
|
1488
|
-
r1 = _nt_operator
|
1489
|
-
if r1
|
1490
|
-
r0 = r1
|
1491
|
-
else
|
1492
|
-
r2 = _nt_S
|
1493
|
-
if r2
|
1494
|
-
r0 = r2
|
1495
|
-
else
|
1496
|
-
r3 = _nt_WS
|
1497
|
-
if r3
|
1498
|
-
r0 = r3
|
1499
|
-
else
|
1500
|
-
@index = i0
|
1501
|
-
r0 = nil
|
1502
|
-
end
|
1503
|
-
end
|
1504
|
-
end
|
1505
|
-
|
1506
|
-
node_cache[:separator][start_index] = r0
|
1507
|
-
|
1508
|
-
r0
|
1509
|
-
end
|
1510
|
-
|
1511
|
-
module Paren0
|
1512
|
-
def s
|
1513
|
-
elements[0]
|
1514
|
-
end
|
1515
|
-
|
1516
|
-
def s
|
1517
|
-
elements[2]
|
1518
|
-
end
|
1519
|
-
end
|
1520
|
-
|
1521
|
-
module Paren1
|
1522
|
-
def build
|
1523
|
-
Node::Paren.new(text_value.strip)
|
1524
|
-
end
|
1525
|
-
end
|
1526
|
-
|
1527
|
-
def _nt_paren
|
1528
|
-
start_index = index
|
1529
|
-
if node_cache[:paren].has_key?(index)
|
1530
|
-
cached = node_cache[:paren][index]
|
1531
|
-
@index = cached.interval.end if cached
|
1532
|
-
return cached
|
1533
|
-
end
|
1534
|
-
|
1535
|
-
i0, s0 = index, []
|
1536
|
-
r1 = _nt_s
|
1537
|
-
s0 << r1
|
1538
|
-
if r1
|
1539
|
-
if has_terminal?('\G[()]', true, index)
|
1540
|
-
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1541
|
-
@index += 1
|
1542
|
-
else
|
1543
|
-
r2 = nil
|
1544
|
-
end
|
1545
|
-
s0 << r2
|
1546
|
-
if r2
|
1547
|
-
r3 = _nt_s
|
1548
|
-
s0 << r3
|
1549
|
-
end
|
1550
|
-
end
|
1551
|
-
if s0.last
|
1552
|
-
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1553
|
-
r0.extend(Paren0)
|
1554
|
-
r0.extend(Paren1)
|
1555
|
-
else
|
1556
|
-
@index = i0
|
1557
|
-
r0 = nil
|
1558
|
-
end
|
1559
|
-
|
1560
|
-
node_cache[:paren][start_index] = r0
|
1561
|
-
|
1562
|
-
r0
|
1563
|
-
end
|
1564
|
-
|
1565
1479
|
def _nt_entity
|
1566
1480
|
start_index = index
|
1567
1481
|
if node_cache[:entity].has_key?(index)
|
@@ -1640,9 +1554,6 @@ module Less
|
|
1640
1554
|
|
1641
1555
|
module Fonts2
|
1642
1556
|
def build
|
1643
|
-
fonts = all.map do |font|
|
1644
|
-
font.build
|
1645
|
-
end
|
1646
1557
|
Node::FontFamily.new(all.map(&:build))
|
1647
1558
|
end
|
1648
1559
|
|
data/lib/less/engine.rb
CHANGED
data/lib/less.rb
CHANGED
@@ -39,9 +39,9 @@ module Treetop
|
|
39
39
|
"on line #{failure_line}: expected " + (
|
40
40
|
tf.size == 1 ?
|
41
41
|
tf[0].expected_string :
|
42
|
-
"one of #{tf.map {|f| f.expected_string }.uniq * ' '}"
|
42
|
+
"one of #{Less::YELLOW[tf.map {|f| f.expected_string }.uniq * ' ']}"
|
43
43
|
) +
|
44
|
-
" got
|
44
|
+
" got #{Less::YELLOW[input[failure_index]]}" +
|
45
45
|
" after:\n\n#{input[index...failure_index]}\n"
|
46
46
|
end
|
47
47
|
end
|
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
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cloudhead
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-24 00:00:00 -07:00
|
13
13
|
default_executable: lessc
|
14
14
|
dependencies: []
|
15
15
|
|