cloudhead-less 0.5.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +29 -1
- data/VERSION +1 -1
- data/bin/lessc +1 -1
- data/less.gemspec +4 -3
- data/lib/less.rb +6 -1
- data/lib/less/command.rb +10 -9
- data/lib/less/engine.rb +36 -13
- data/spec/spec.less +4 -14
- metadata +4 -4
data/Rakefile
CHANGED
@@ -6,8 +6,36 @@ begin
|
|
6
6
|
s.email = "alexis@cloudhead.net"
|
7
7
|
s.summary = "LESS compiler"
|
8
8
|
s.homepage = "http://www.lesscss.org"
|
9
|
-
s.description = "
|
9
|
+
s.description = "LESS is leaner CSS"
|
10
|
+
s.rubyforge_project = 'less'
|
10
11
|
end
|
11
12
|
rescue LoadError
|
12
13
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
14
|
+
end
|
15
|
+
|
16
|
+
# rubyforge
|
17
|
+
begin
|
18
|
+
require 'rake/contrib/sshpublisher'
|
19
|
+
namespace :rubyforge do
|
20
|
+
|
21
|
+
desc "Release gem and RDoc documentation to RubyForge"
|
22
|
+
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
23
|
+
|
24
|
+
namespace :release do
|
25
|
+
desc "Publish RDoc to RubyForge."
|
26
|
+
task :docs => [:rdoc] do
|
27
|
+
config = YAML.load(
|
28
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
29
|
+
)
|
30
|
+
options << '--line-numbers' << '--inline-source'
|
31
|
+
host = "#{config['username']}@rubyforge.org"
|
32
|
+
remote_dir = "/var/www/gforge-projects/the-perfect-gem/"
|
33
|
+
local_dir = 'rdoc'
|
34
|
+
|
35
|
+
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
rescue LoadError
|
40
|
+
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
13
41
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
data/bin/lessc
CHANGED
data/less.gemspec
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{less}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.7.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-05-
|
9
|
+
s.date = %q{2009-05-20}
|
10
10
|
s.default_executable = %q{lessc}
|
11
|
-
s.description = %q{
|
11
|
+
s.description = %q{LESS is leaner CSS}
|
12
12
|
s.email = %q{alexis@cloudhead.net}
|
13
13
|
s.executables = ["lessc"]
|
14
14
|
s.extra_rdoc_files = [
|
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.homepage = %q{http://www.lesscss.org}
|
34
34
|
s.rdoc_options = ["--charset=UTF-8"]
|
35
35
|
s.require_paths = ["lib"]
|
36
|
+
s.rubyforge_project = %q{less}
|
36
37
|
s.rubygems_version = %q{1.3.1}
|
37
38
|
s.summary = %q{LESS compiler}
|
38
39
|
|
data/lib/less.rb
CHANGED
data/lib/less/command.rb
CHANGED
@@ -33,16 +33,9 @@ module Less
|
|
33
33
|
# Error loop
|
34
34
|
#
|
35
35
|
loop do
|
36
|
-
|
37
|
-
compile
|
38
|
-
rescue SyntaxError
|
39
|
-
error = $!.message.split("\n")[1..-1].collect {|e| e.gsub(/\(eval\)\:\d+\:\s/, '') } * "\n"
|
40
|
-
log " errors were found in the .less file! \n#{error}\n"
|
36
|
+
unless compile
|
41
37
|
log "Press [enter] to continue..."
|
42
|
-
watch
|
43
|
-
$stdin.gets
|
44
|
-
print "} "
|
45
|
-
end
|
38
|
+
watch { $stdin.gets }
|
46
39
|
next # continue within the error loop, until the error is fixed
|
47
40
|
end
|
48
41
|
break # break to main loop, as no errors were encountered
|
@@ -59,12 +52,20 @@ module Less
|
|
59
52
|
# Create a new Less object with the contents of a file
|
60
53
|
css = Less::Engine.new( File.read( @source ) ).to_css
|
61
54
|
css = css.delete " \n" if compress?
|
55
|
+
|
62
56
|
File.open( @destination, "w" ) do |file|
|
63
57
|
file.write css
|
64
58
|
end
|
65
59
|
puts "#{@destination.split('/').last} was updated!" if watch?
|
66
60
|
rescue Errno::ENOENT => e
|
67
61
|
abort "#{e}"
|
62
|
+
rescue SyntaxError
|
63
|
+
error = $!.message.split("\n")[1..-1].collect {|e| e.gsub(/\(eval\)\:\d+\:\s/, '') } * "\n"
|
64
|
+
log " !! errors were found in the .less file! \n#{error}\n"
|
65
|
+
rescue MixedUnitsError
|
66
|
+
log "!! You're mixing units together! what do you expect?\n"
|
67
|
+
else
|
68
|
+
true
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
data/lib/less/engine.rb
CHANGED
@@ -3,7 +3,7 @@ module Less
|
|
3
3
|
REGEXP = {
|
4
4
|
:path => /([#.][->#.\w]+)?( ?> ?)?@([\w\-]+)/, # #header > .title > @var
|
5
5
|
:selector => /[-\w #.>*_:]/, # .cow .milk > a
|
6
|
-
:values => /[-\w @>\/*+#%.,'"]/,
|
6
|
+
:values => /[-\w \(\)@>\/*+#%.,'"]/, # 10px solid #fff
|
7
7
|
:variable => /^@([\w\-]+)/ # @milk-white
|
8
8
|
}
|
9
9
|
|
@@ -45,24 +45,24 @@ module Less
|
|
45
45
|
end
|
46
46
|
|
47
47
|
#
|
48
|
-
# Evaluate
|
48
|
+
# Evaluate variables
|
49
49
|
#
|
50
50
|
@tree = @tree.traverse :leaf do |key, value, path, node|
|
51
|
-
convert = lambda do |key, value, node|
|
52
|
-
if value.is_a?(String) && value.include?('@')
|
51
|
+
convert = lambda do |key, value, node| # We declare this as a lambda, for re-use
|
52
|
+
if value.is_a?(String) && value.include?('@') # There's a var to evaluate
|
53
53
|
|
54
54
|
# Find its value
|
55
55
|
var = value.delete(' ').match( REGEXP[:path] ).captures.join
|
56
56
|
var = unless var.include? '>'
|
57
|
-
node.var( var ) || @tree.var( var )
|
57
|
+
node.var( var ) || @tree.var( var ) # Try local first, then global
|
58
58
|
else
|
59
|
-
@tree.find :var, var.split('>')
|
59
|
+
@tree.find :var, var.split('>') # Try finding it in a specific namespace
|
60
60
|
end
|
61
61
|
|
62
62
|
if var
|
63
|
-
node[ key ] = value.gsub REGEXP[:path], var
|
63
|
+
node[ key ] = value.gsub REGEXP[:path], var # Substitute variable with value
|
64
64
|
else
|
65
|
-
node.delete key
|
65
|
+
node.delete key # Discard the declaration if the variable wasn't found
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -76,7 +76,34 @@ module Less
|
|
76
76
|
convert.call key, value, node
|
77
77
|
end
|
78
78
|
end
|
79
|
-
end
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# Evaluate operations (2+2)
|
83
|
+
#
|
84
|
+
# Units are: 1px, 1em, 1%, #111
|
85
|
+
@tree = @tree.traverse :leaf do |key, value, path, node|
|
86
|
+
if value.match /[-+\/*]/
|
87
|
+
if (unit = value.scan(/(%)|\d+(px)|\d+(em)|(#)/i).flatten.compact.uniq).size <= 1
|
88
|
+
unit = unit.join
|
89
|
+
value = if unit == '#'
|
90
|
+
value.gsub(/#([a-z0-9]+)/i) do
|
91
|
+
hex = $1 * ( $1.size == 3 ? 2 : 1 )
|
92
|
+
hex.to_i(16)
|
93
|
+
end.delete unit
|
94
|
+
evaluate = lambda {|v| unit + eval( v ).to_s(16) }
|
95
|
+
else
|
96
|
+
value.gsub(/px|em|%/, '')
|
97
|
+
evaluate = lambda {|v| eval( v ).to_s + unit }
|
98
|
+
end.to_s
|
99
|
+
next if value.match /[a-z]/i
|
100
|
+
node[ key ] = evaluate.call value
|
101
|
+
else
|
102
|
+
raise MixedUnitsError
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
80
107
|
end
|
81
108
|
alias render compile
|
82
109
|
|
@@ -84,10 +111,6 @@ module Less
|
|
84
111
|
self.compile.to_css
|
85
112
|
end
|
86
113
|
|
87
|
-
def evaluate s
|
88
|
-
eval( s )
|
89
|
-
end
|
90
|
-
|
91
114
|
def hashify
|
92
115
|
#
|
93
116
|
# Parse the LESS structure into a hash
|
data/spec/spec.less
CHANGED
@@ -14,18 +14,6 @@
|
|
14
14
|
color: @fa;
|
15
15
|
line-height: 1999px;
|
16
16
|
}
|
17
|
-
.ccc {
|
18
|
-
color: black;
|
19
|
-
}
|
20
|
-
.ddd {
|
21
|
-
color: black;
|
22
|
-
}
|
23
|
-
.bbb {
|
24
|
-
color: black;
|
25
|
-
}
|
26
|
-
.aaa {
|
27
|
-
color: red;
|
28
|
-
}
|
29
17
|
.alt {
|
30
18
|
@base-color: green;
|
31
19
|
@darker-color: @base-color / 2;
|
@@ -33,13 +21,15 @@
|
|
33
21
|
}
|
34
22
|
.altfoo { color: .alt > @base-color; }
|
35
23
|
.foo { border: 1px solid black; color: @base-color; }
|
36
|
-
|
24
|
+
.foo2 {
|
25
|
+
width: 10px * 2;
|
26
|
+
}
|
37
27
|
#content {
|
38
28
|
font-size: 12px;
|
39
29
|
@some-color: blue;
|
40
30
|
#header {
|
41
31
|
.foo;
|
42
|
-
font-size: #
|
32
|
+
font-size: #222 / 2;
|
43
33
|
}
|
44
34
|
#main-page {
|
45
35
|
#content > .small;
|
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.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cloudhead
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-20 00:00:00 -07:00
|
13
13
|
default_executable: lessc
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
16
|
+
description: LESS is leaner CSS
|
17
17
|
email: alexis@cloudhead.net
|
18
18
|
executables:
|
19
19
|
- lessc
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
version:
|
57
57
|
requirements: []
|
58
58
|
|
59
|
-
rubyforge_project:
|
59
|
+
rubyforge_project: less
|
60
60
|
rubygems_version: 1.2.0
|
61
61
|
signing_key:
|
62
62
|
specification_version: 2
|