cloudhead-less 0.8.4 → 0.8.6
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/README.md +2 -2
- data/VERSION +1 -1
- data/bin/lessc +8 -2
- data/less.gemspec +2 -2
- data/lib/less.rb +3 -3
- data/lib/less/command.rb +15 -7
- data/lib/less/engine.rb +6 -6
- data/lib/less/tree.rb +5 -5
- metadata +2 -2
data/README.md
CHANGED
@@ -20,8 +20,8 @@ LESS allows you to write CSS the way (I think) it was meant to, that is: with *v
|
|
20
20
|
### And the CSS output it produces:
|
21
21
|
|
22
22
|
.outline { border: 1px solid black }
|
23
|
-
.article
|
24
|
-
.article
|
23
|
+
.article a { text-decoration: none }
|
24
|
+
.article p { color: #110011 }
|
25
25
|
.article { border: 1px solid black }
|
26
26
|
|
27
27
|
If you have CSS nightmares, just
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.7
|
data/bin/lessc
CHANGED
@@ -11,7 +11,8 @@ CSS = '.css'
|
|
11
11
|
options = {
|
12
12
|
:watch => false,
|
13
13
|
:compress => false,
|
14
|
-
:debug => false
|
14
|
+
:debug => false,
|
15
|
+
:inheritance => :desc
|
15
16
|
}
|
16
17
|
|
17
18
|
# Get arguments
|
@@ -24,9 +25,14 @@ opts = OptionParser.new do |o|
|
|
24
25
|
options[:watch] = true
|
25
26
|
end
|
26
27
|
|
28
|
+
# Child-type inheritance
|
29
|
+
o.on("-c", "--child", "nesting uses child-type inheritance") do
|
30
|
+
options[:chain] = :child
|
31
|
+
end
|
32
|
+
|
27
33
|
# Compression needs a proper algorithm
|
28
34
|
#
|
29
|
-
# o.on("-
|
35
|
+
# o.on("-x", "--compress", "compress css file") do
|
30
36
|
# options[:compress] = true
|
31
37
|
# end
|
32
38
|
|
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 = "0.8.
|
5
|
+
s.version = "0.8.6"
|
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-
|
9
|
+
s.date = %q{2009-06-04}
|
10
10
|
s.default_executable = %q{lessc}
|
11
11
|
s.description = %q{LESS is leaner CSS}
|
12
12
|
s.email = %q{alexis@cloudhead.net}
|
data/lib/less.rb
CHANGED
@@ -4,9 +4,9 @@ require 'less/command'
|
|
4
4
|
require 'less/engine'
|
5
5
|
require 'less/tree'
|
6
6
|
|
7
|
-
module Less
|
8
|
-
|
9
|
-
|
7
|
+
module Less
|
8
|
+
MixedUnitsError = Class.new(Exception)
|
9
|
+
PathError = Class.new(Exception)
|
10
10
|
|
11
11
|
def self.version
|
12
12
|
File.read( File.join( File.dirname(__FILE__), '..', 'VERSION') )
|
data/lib/less/command.rb
CHANGED
@@ -21,6 +21,8 @@ module Less
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def run!
|
24
|
+
compile(true) unless File.exist? @destination
|
25
|
+
|
24
26
|
if watch?
|
25
27
|
log "Watching for changes in #@source ...Ctrl-C to abort.\n"
|
26
28
|
|
@@ -44,25 +46,27 @@ module Less
|
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
|
-
def compile
|
49
|
+
def compile new = false
|
48
50
|
begin
|
49
51
|
# Create a new Less object with the contents of a file
|
50
|
-
css = Less::Engine.new( File.read( @source ) ).to_css
|
52
|
+
css = Less::Engine.new( File.read( @source ) ).to_css @options[:inheritance]
|
51
53
|
css = css.delete " \n" if compress?
|
52
54
|
|
53
55
|
File.open( @destination, "w" ) do |file|
|
54
56
|
file.write css
|
55
57
|
end
|
56
|
-
puts " [Updated] #{@destination.split('/').last}" if watch?
|
58
|
+
puts "#{new ? '* [Created]' : ' [Updated]'} #{@destination.split('/').last}" if watch?
|
57
59
|
rescue Errno::ENOENT => e
|
58
60
|
abort "#{e}"
|
59
61
|
rescue SyntaxError
|
60
62
|
error = debug?? $! : $!.message.split("\n")[1..-1].collect {|e|
|
61
63
|
e.gsub(/\(eval\)\:(\d+)\:\s/, 'line \1: ')
|
62
64
|
} * "\n"
|
63
|
-
|
64
|
-
rescue MixedUnitsError
|
65
|
-
|
65
|
+
err "errors were found in the .less file! \n#{error}\n"
|
66
|
+
rescue MixedUnitsError => e
|
67
|
+
err "`#{e}` you're mixing units together! What do you expect?\n"
|
68
|
+
rescue PathError => e
|
69
|
+
err "`#{e}` was not found.\n"
|
66
70
|
else
|
67
71
|
true
|
68
72
|
end
|
@@ -70,7 +74,11 @@ module Less
|
|
70
74
|
|
71
75
|
# Just a logging function to avoid typing '}'
|
72
76
|
def log s = ''
|
73
|
-
print '
|
77
|
+
print '* ' + s.to_s
|
78
|
+
end
|
79
|
+
|
80
|
+
def err s = ''
|
81
|
+
print "!! #{s}"
|
74
82
|
end
|
75
83
|
end
|
76
84
|
end
|
data/lib/less/engine.rb
CHANGED
@@ -85,7 +85,7 @@ module Less
|
|
85
85
|
next if operation.match /[a-z]/i
|
86
86
|
evaluate.call operation
|
87
87
|
else
|
88
|
-
raise MixedUnitsError
|
88
|
+
raise MixedUnitsError, value
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
@@ -106,16 +106,16 @@ module Less
|
|
106
106
|
end
|
107
107
|
|
108
108
|
if var
|
109
|
-
node[ key ] = value.gsub REGEX[:path], var
|
109
|
+
node[ key ] = value.gsub REGEX[:path], var # Substitute variable with value
|
110
110
|
else
|
111
|
-
node.delete key
|
111
|
+
node.delete key # Discard the declaration if the variable wasn't found
|
112
112
|
end
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
-
def to_css
|
118
|
-
self.compile.to_css
|
117
|
+
def to_css chain
|
118
|
+
self.compile.to_css chain
|
119
119
|
end
|
120
120
|
|
121
121
|
def hashify
|
@@ -126,7 +126,7 @@ module Less
|
|
126
126
|
# less: color: black;
|
127
127
|
# hashify: "color" => "black"
|
128
128
|
#
|
129
|
-
hash = self.gsub(/\t
|
129
|
+
hash = self.gsub(/\t+/, ' '). # Tabs
|
130
130
|
gsub(/\r\n/, "\n"). # m$
|
131
131
|
gsub(/\/\/.*/, ''). # Comments //
|
132
132
|
gsub(/\/\*.*?\*\//m, ''). # Comments /*
|
data/lib/less/tree.rb
CHANGED
@@ -24,7 +24,7 @@ module Less
|
|
24
24
|
if what == :var && k == path.last
|
25
25
|
branch[:variables][ k ]
|
26
26
|
else
|
27
|
-
branch = branch[ k ]
|
27
|
+
branch = branch[ k ] or raise PathError, path.join(' > ')
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -56,7 +56,7 @@ module Less
|
|
56
56
|
self[ key ] = value.to_tree. # Make sure any change is saved to the main tree
|
57
57
|
traverse by, path, &blk # Recurse, with the current node becoming `self`
|
58
58
|
yield path, self[ key ] if by == :branch # The node is a branch, yield it to the block
|
59
|
-
path.pop # We're returning from a branch, pop the last element
|
59
|
+
path.pop # We're returning from a branch, pop the last path element
|
60
60
|
elsif by == :leaf and key.is_a? String
|
61
61
|
yield key, value, path, self # The node is a leaf, yield it to the block
|
62
62
|
else
|
@@ -69,12 +69,12 @@ module Less
|
|
69
69
|
#
|
70
70
|
# Convert the tree to css, using full paths
|
71
71
|
#
|
72
|
-
def to_css css = []
|
72
|
+
def to_css chain = :desc, css = []
|
73
73
|
self.traverse :branch do |path, node|
|
74
74
|
properties = node.inject("") do |s, (k, v)|
|
75
|
-
v.is_a?(String) ? (s + "#{k}: #{CGI.unescape(v)}; ") : s
|
75
|
+
v.is_a?(String) ? (s + "#{k}: #{CGI.unescape(v)}; ") : s # Add the property to the list
|
76
76
|
end
|
77
|
-
css << path * ' > ' + " { " + properties + "}"
|
77
|
+
css << path * ( chain == :desc ? ' ' : ' > ') + " { " + properties + "}" # Add the rule-set to the CSS
|
78
78
|
end
|
79
79
|
css.join "\n"
|
80
80
|
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: 0.8.
|
4
|
+
version: 0.8.6
|
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-
|
12
|
+
date: 2009-06-04 00:00:00 -07:00
|
13
13
|
default_executable: lessc
|
14
14
|
dependencies: []
|
15
15
|
|