less 0.8.8 → 1.2.21
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/CHANGELOG +62 -0
- data/README.md +24 -6
- data/Rakefile +28 -37
- data/VERSION +1 -1
- data/bin/lessc +41 -11
- data/less.gemspec +85 -16
- data/lib/less/command.rb +47 -28
- data/lib/less/engine/grammar/common.tt +29 -0
- data/lib/less/engine/grammar/entity.tt +144 -0
- data/lib/less/engine/grammar/less.tt +341 -0
- data/lib/less/engine/nodes/element.rb +281 -0
- data/lib/less/engine/nodes/entity.rb +79 -0
- data/lib/less/engine/nodes/function.rb +93 -0
- data/lib/less/engine/nodes/literal.rb +171 -0
- data/lib/less/engine/nodes/property.rb +232 -0
- data/lib/less/engine/nodes/ruleset.rb +12 -0
- data/lib/less/engine/nodes/selector.rb +44 -0
- data/lib/less/engine/nodes.rb +9 -0
- data/lib/less/engine.rb +44 -140
- data/lib/less/ext.rb +60 -0
- data/lib/less.rb +25 -13
- data/spec/command_spec.rb +3 -7
- data/spec/css/accessors.css +18 -0
- data/spec/css/big.css +3768 -0
- data/spec/css/colors.css +14 -0
- data/spec/css/comments.css +9 -0
- data/spec/css/css-3.css +21 -0
- data/spec/css/css.css +50 -0
- data/spec/css/dash-prefix.css +12 -0
- data/spec/css/functions.css +6 -0
- data/spec/css/import-with-extra-paths.css +8 -0
- data/spec/css/import-with-partial-in-extra-path.css +6 -0
- data/spec/css/import.css +12 -0
- data/spec/css/lazy-eval.css +1 -0
- data/spec/css/mixins-args.css +32 -0
- data/spec/css/mixins.css +28 -0
- data/spec/css/operations.css +28 -0
- data/spec/css/parens.css +20 -0
- data/spec/css/rulesets.css +17 -0
- data/spec/css/scope.css +11 -0
- data/spec/css/selectors.css +13 -0
- data/spec/css/strings.css +12 -0
- data/spec/css/variables.css +8 -0
- data/spec/css/whitespace.css +7 -0
- data/spec/engine_spec.rb +107 -15
- data/spec/less/accessors.less +20 -0
- data/spec/less/big.less +1264 -0
- data/spec/less/colors.less +35 -0
- data/spec/less/comments.less +46 -0
- data/spec/less/css-3.less +52 -0
- data/spec/less/css.less +104 -0
- data/spec/less/dash-prefix.less +21 -0
- data/spec/less/exceptions/mixed-units-error.less +3 -0
- data/spec/less/exceptions/name-error-1.0.less +3 -0
- data/spec/less/exceptions/syntax-error-1.0.less +3 -0
- data/spec/less/extra_import_path/extra.less +1 -0
- data/spec/less/extra_import_path/import/import-test-a.css +1 -0
- data/spec/less/extra_import_path/import/import-test-a.less +4 -0
- data/spec/less/functions.less +6 -0
- data/spec/less/hidden.less +25 -0
- data/spec/less/import/import-test-a.less +2 -0
- data/spec/less/import/import-test-b.less +8 -0
- data/spec/less/import/import-test-c.less +7 -0
- data/spec/less/import/import-test-d.css +1 -0
- data/spec/less/import-with-extra-paths.less +4 -0
- data/spec/less/import.less +8 -0
- data/spec/less/lazy-eval.less +6 -0
- data/spec/less/literal-css.less +11 -0
- data/spec/less/mixins-args.less +59 -0
- data/spec/less/mixins.less +43 -0
- data/spec/less/operations.less +39 -0
- data/spec/less/parens.less +26 -0
- data/spec/less/rulesets.less +30 -0
- data/spec/less/scope.less +32 -0
- data/spec/less/selectors.less +24 -0
- data/spec/less/strings.less +14 -0
- data/spec/less/variables.less +29 -0
- data/spec/less/whitespace.less +34 -0
- data/spec/spec.css +50 -25
- data/spec/spec_helper.rb +4 -1
- metadata +96 -15
- data/lib/less/tree.rb +0 -82
- data/spec/css/less-0.8.5.css +0 -24
- data/spec/css/less-0.8.6.css +0 -24
- data/spec/css/less-0.8.7.css +0 -24
- data/spec/css/less-0.8.8.css +0 -25
- data/spec/spec.less +0 -128
- data/spec/tree_spec.rb +0 -5
data/CHANGELOG
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
1.1.6
|
|
2
|
+
- hsl() fix
|
|
3
|
+
1.1.5
|
|
4
|
+
- rgb() fix
|
|
5
|
+
1.1.4
|
|
6
|
+
- support for uppercase ids and classes
|
|
7
|
+
- `ex` support
|
|
8
|
+
- fixed ruby 1.8 from outputting ascii numbers in the CLI
|
|
9
|
+
1.1.3
|
|
10
|
+
- fix to Growl messages
|
|
11
|
+
- better benchmark task output
|
|
12
|
+
1.1.2
|
|
13
|
+
- full parens support
|
|
14
|
+
- don't raise an exception if growlnotify wasn't found
|
|
15
|
+
1.1.1
|
|
16
|
+
- added title to Growl notifications
|
|
17
|
+
1.1.0
|
|
18
|
+
- added color to command line output
|
|
19
|
+
- added Growl support
|
|
20
|
+
1.0.16
|
|
21
|
+
- basic support for parens
|
|
22
|
+
- support for operations in shorthand properties
|
|
23
|
+
1.0.15
|
|
24
|
+
- moved to treetop 1.3.0
|
|
25
|
+
- fixed benchmark task
|
|
26
|
+
1.0.14
|
|
27
|
+
- support for `*property:` hack
|
|
28
|
+
1.0.13
|
|
29
|
+
- importing .css files now works
|
|
30
|
+
1.0.12
|
|
31
|
+
- basic selector grouping for better output
|
|
32
|
+
- evaluate variables lazily
|
|
33
|
+
- support for values starting with `-`
|
|
34
|
+
1.0.11
|
|
35
|
+
- ruby 1.8 compatibility fix
|
|
36
|
+
1.0.10
|
|
37
|
+
- additional support for css 3
|
|
38
|
+
1.0.9
|
|
39
|
+
- overhauled color support & operations
|
|
40
|
+
- better handling of css 3 selectors
|
|
41
|
+
1.0.8
|
|
42
|
+
- support for rgba
|
|
43
|
+
- fixed color expansion
|
|
44
|
+
- fixed new-line error in declarations
|
|
45
|
+
- fixed attriute selector without element name error
|
|
46
|
+
1.0.6
|
|
47
|
+
- fixed grammar for .class#id
|
|
48
|
+
- fixed color padding issue
|
|
49
|
+
1.0.5
|
|
50
|
+
- added attribute selectors (accessors)
|
|
51
|
+
- semi-column at end of ruleset now works
|
|
52
|
+
1.0.4
|
|
53
|
+
- removed dependency on polyglot gem
|
|
54
|
+
- fixed a moz hack not compiling
|
|
55
|
+
1.0.3
|
|
56
|
+
- fixed problem with floats repeating unit twice
|
|
57
|
+
1.0.2
|
|
58
|
+
- added support for url() without quotes
|
|
59
|
+
1.0.1
|
|
60
|
+
- pulled some patches from jgarber's treetop
|
|
61
|
+
1.0.0
|
|
62
|
+
- initial release
|
data/README.md
CHANGED
|
@@ -2,6 +2,16 @@ LESS
|
|
|
2
2
|
====
|
|
3
3
|
It's time CSS was done right – LESS is _leaner_ css.
|
|
4
4
|
|
|
5
|
+
Setup
|
|
6
|
+
------
|
|
7
|
+
to get the latest development version:
|
|
8
|
+
|
|
9
|
+
sudo gem install less -s http://gemcutter.org
|
|
10
|
+
|
|
11
|
+
to get the latest stable version:
|
|
12
|
+
|
|
13
|
+
sudo gem install less
|
|
14
|
+
|
|
5
15
|
Explained
|
|
6
16
|
---------
|
|
7
17
|
LESS allows you to write CSS the way (I think) it was meant to, that is: with *variables*, *nested rules* and *mixins*!
|
|
@@ -9,22 +19,30 @@ LESS allows you to write CSS the way (I think) it was meant to, that is: with *v
|
|
|
9
19
|
### Here's some example LESS code:
|
|
10
20
|
|
|
11
21
|
@dark: #110011;
|
|
12
|
-
.outline { border:
|
|
22
|
+
.outline (@width: 1) { border: (@width * 10px) solid black }
|
|
13
23
|
|
|
14
24
|
.article {
|
|
15
25
|
a { text-decoration: none }
|
|
16
26
|
p { color: @dark }
|
|
17
|
-
.outline;
|
|
27
|
+
.outline(3);
|
|
18
28
|
}
|
|
19
29
|
|
|
20
30
|
### And the CSS output it produces:
|
|
21
31
|
|
|
22
|
-
.outline { border: 1px solid black }
|
|
23
32
|
.article a { text-decoration: none }
|
|
24
33
|
.article p { color: #110011 }
|
|
25
|
-
.article { border:
|
|
34
|
+
.article { border: 30px solid black }
|
|
26
35
|
|
|
27
|
-
If you have CSS nightmares, just
|
|
36
|
+
If you have CSS nightmares, just
|
|
28
37
|
$ lessc style.less
|
|
29
38
|
|
|
30
|
-
For more information, see you at http://lesscss.org
|
|
39
|
+
For more information, see you at <http://lesscss.org>
|
|
40
|
+
|
|
41
|
+
People without whom this wouldn't have happened a.k.a *Credits*
|
|
42
|
+
---------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
- **Dmitry Fadeyev**, for pushing me to do this, and designing our awesome website
|
|
45
|
+
- **August Lilleaas**, for initiating the work on the treetop grammar, as well as writing the rails plugin
|
|
46
|
+
- **Nathan Sobo**, for creating treetop
|
|
47
|
+
- **Jason Garber**, for his magical performance optimizations on treetop
|
|
48
|
+
- And finally, the people of #ruby-lang for answering all my ruby questions. **apeiros**, **manveru** and **rue** come to mind
|
data/Rakefile
CHANGED
|
@@ -3,59 +3,50 @@ begin
|
|
|
3
3
|
Jeweler::Tasks.new do |s|
|
|
4
4
|
s.name = "less"
|
|
5
5
|
s.authors = ["cloudhead"]
|
|
6
|
-
s.email = "
|
|
6
|
+
s.email = "self@cloudhead.net"
|
|
7
7
|
s.summary = "LESS compiler"
|
|
8
8
|
s.homepage = "http://www.lesscss.org"
|
|
9
9
|
s.description = "LESS is leaner CSS"
|
|
10
10
|
s.rubyforge_project = 'less'
|
|
11
|
+
s.add_dependency('treetop', '>= 1.4.2')
|
|
12
|
+
s.add_dependency('mutter', '>= 0.4.2')
|
|
11
13
|
end
|
|
14
|
+
Jeweler::GemcutterTasks.new
|
|
12
15
|
rescue LoadError
|
|
13
16
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
|
14
17
|
end
|
|
15
18
|
|
|
16
|
-
|
|
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"]
|
|
19
|
+
require 'spec/rake/spectask'
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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'
|
|
21
|
+
Spec::Rake::SpecTask.new("spec") do |t|
|
|
22
|
+
t.libs << 'lib' << 'spec'
|
|
23
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
24
|
+
t.spec_opts = ['--color', '--format=specdoc']
|
|
25
|
+
end
|
|
34
26
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
rescue LoadError
|
|
40
|
-
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
|
27
|
+
task :test do
|
|
28
|
+
Rake::Task['spec'].invoke
|
|
41
29
|
end
|
|
42
30
|
|
|
43
31
|
begin
|
|
44
|
-
require '
|
|
32
|
+
require 'lib/less'
|
|
33
|
+
require 'benchmark'
|
|
45
34
|
|
|
46
|
-
|
|
47
|
-
t
|
|
48
|
-
|
|
35
|
+
task :compile do
|
|
36
|
+
abort "compiling isn't necessary anymore."
|
|
37
|
+
puts "compiling #{LESS_GRAMMAR.split('/').last}..."
|
|
38
|
+
File.open(LESS_PARSER, 'w') {|f| f.write Treetop::Compiler::GrammarCompiler.new.ruby_source(LESS_GRAMMAR) }
|
|
49
39
|
end
|
|
50
40
|
|
|
51
|
-
task :
|
|
52
|
-
|
|
41
|
+
task :benchmark do
|
|
42
|
+
less = File.read("spec/less/big.less")
|
|
43
|
+
result = nil
|
|
44
|
+
Benchmark.bmbm do |b|
|
|
45
|
+
b.report("parse: ") { result = Less::Engine.new(less).parse(false) }
|
|
46
|
+
b.report("build: ") { result = result.build(Less::Node::Element.new) }
|
|
47
|
+
b.report("compile:") { result.to_css }
|
|
48
|
+
end
|
|
53
49
|
end
|
|
50
|
+
end
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
57
|
-
t.spec_opts = ['--color']
|
|
58
|
-
t.rcov = true
|
|
59
|
-
t.rcov_opts = ['--exclude', '^spec,/gems/']
|
|
60
|
-
end
|
|
61
|
-
end
|
|
52
|
+
task :default => :spec
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1.2.21
|
data/bin/lessc
CHANGED
|
@@ -3,39 +3,69 @@
|
|
|
3
3
|
$:.unshift File.dirname(__FILE__) + "/../lib"
|
|
4
4
|
|
|
5
5
|
require 'optparse'
|
|
6
|
+
require 'rubygems'
|
|
6
7
|
require 'less'
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
begin
|
|
10
|
+
require 'growl'
|
|
11
|
+
rescue LoadError
|
|
12
|
+
Less::GROWL = false
|
|
13
|
+
else
|
|
14
|
+
Less::GROWL = true
|
|
15
|
+
end
|
|
9
16
|
|
|
10
17
|
# Argument defaults
|
|
11
18
|
options = {
|
|
12
19
|
:watch => false,
|
|
13
20
|
:compress => false,
|
|
14
21
|
:debug => false,
|
|
15
|
-
:
|
|
22
|
+
:growl => false,
|
|
23
|
+
:timestamps => false,
|
|
24
|
+
:color => $stdout.tty?
|
|
16
25
|
}
|
|
17
26
|
|
|
18
27
|
# Get arguments
|
|
19
28
|
opts = OptionParser.new do |o|
|
|
20
29
|
o.banner = "usage: lessc source [destination] [--watch]"
|
|
21
30
|
o.separator ""
|
|
22
|
-
|
|
31
|
+
|
|
23
32
|
# Watch mode
|
|
24
33
|
o.on("-w", "--watch", "watch for changes") do
|
|
25
34
|
options[:watch] = true
|
|
26
35
|
end
|
|
27
|
-
|
|
28
|
-
#
|
|
29
|
-
o.on("-
|
|
30
|
-
|
|
36
|
+
|
|
37
|
+
# Growl
|
|
38
|
+
o.on("-g", "--growl", "growl notifications") do
|
|
39
|
+
if Less::GROWL && (Growl.installed? rescue false)
|
|
40
|
+
options[:growl] = true
|
|
41
|
+
elsif Less::GROWL
|
|
42
|
+
abort "Growl or 'growlnotify' wasn't found on your system."
|
|
43
|
+
else
|
|
44
|
+
abort "Growl gem not found, please install with: " +
|
|
45
|
+
"`sudo gem install visionmedia-growl -s http://gems.github.com`"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Timestamps
|
|
50
|
+
o.on("-t", "--timestamps", "show timestamps in watch mode") do
|
|
51
|
+
options[:timestamps] = true
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# No color in output
|
|
55
|
+
o.on("--no-color", "suppress color in output") do
|
|
56
|
+
options[:color] = false
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
o.on('--verbose', 'show success messages when using growl') do
|
|
60
|
+
options[:verbose] = true
|
|
31
61
|
end
|
|
32
|
-
|
|
62
|
+
|
|
33
63
|
# Compression needs a proper algorithm
|
|
34
64
|
#
|
|
35
65
|
# o.on("-x", "--compress", "compress css file") do
|
|
36
66
|
# options[:compress] = true
|
|
37
67
|
# end
|
|
38
|
-
|
|
68
|
+
|
|
39
69
|
o.separator ""
|
|
40
70
|
|
|
41
71
|
# Help
|
|
@@ -43,7 +73,7 @@ opts = OptionParser.new do |o|
|
|
|
43
73
|
puts opts
|
|
44
74
|
exit
|
|
45
75
|
end
|
|
46
|
-
|
|
76
|
+
|
|
47
77
|
o.on_tail("-d", "--debug", "show full error messages") do
|
|
48
78
|
options[:debug] = true
|
|
49
79
|
end
|
|
@@ -69,4 +99,4 @@ case ARGV.size
|
|
|
69
99
|
exit
|
|
70
100
|
end
|
|
71
101
|
|
|
72
|
-
Less::Command.new( options ).run!
|
|
102
|
+
Less::Command.new( options ).run! ? exit(0) : exit(1)
|
data/less.gemspec
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
|
1
4
|
# -*- encoding: utf-8 -*-
|
|
2
5
|
|
|
3
6
|
Gem::Specification.new do |s|
|
|
4
7
|
s.name = %q{less}
|
|
5
|
-
s.version = "
|
|
8
|
+
s.version = "1.2.21"
|
|
6
9
|
|
|
7
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
11
|
s.authors = ["cloudhead"]
|
|
9
|
-
s.date = %q{
|
|
12
|
+
s.date = %q{2010-01-13}
|
|
10
13
|
s.default_executable = %q{lessc}
|
|
11
14
|
s.description = %q{LESS is leaner CSS}
|
|
12
|
-
s.email = %q{
|
|
15
|
+
s.email = %q{self@cloudhead.net}
|
|
13
16
|
s.executables = ["lessc"]
|
|
14
17
|
s.extra_rdoc_files = [
|
|
15
18
|
"LICENSE",
|
|
@@ -17,6 +20,7 @@ Gem::Specification.new do |s|
|
|
|
17
20
|
]
|
|
18
21
|
s.files = [
|
|
19
22
|
".gitignore",
|
|
23
|
+
"CHANGELOG",
|
|
20
24
|
"LICENSE",
|
|
21
25
|
"README.md",
|
|
22
26
|
"Rakefile",
|
|
@@ -26,39 +30,104 @@ Gem::Specification.new do |s|
|
|
|
26
30
|
"lib/less.rb",
|
|
27
31
|
"lib/less/command.rb",
|
|
28
32
|
"lib/less/engine.rb",
|
|
29
|
-
"lib/less/
|
|
33
|
+
"lib/less/engine/grammar/common.tt",
|
|
34
|
+
"lib/less/engine/grammar/entity.tt",
|
|
35
|
+
"lib/less/engine/grammar/less.tt",
|
|
36
|
+
"lib/less/engine/nodes.rb",
|
|
37
|
+
"lib/less/engine/nodes/element.rb",
|
|
38
|
+
"lib/less/engine/nodes/entity.rb",
|
|
39
|
+
"lib/less/engine/nodes/function.rb",
|
|
40
|
+
"lib/less/engine/nodes/literal.rb",
|
|
41
|
+
"lib/less/engine/nodes/property.rb",
|
|
42
|
+
"lib/less/engine/nodes/ruleset.rb",
|
|
43
|
+
"lib/less/engine/nodes/selector.rb",
|
|
44
|
+
"lib/less/ext.rb",
|
|
30
45
|
"spec/command_spec.rb",
|
|
31
|
-
"spec/css/
|
|
32
|
-
"spec/css/
|
|
33
|
-
"spec/css/
|
|
34
|
-
"spec/css/
|
|
46
|
+
"spec/css/accessors.css",
|
|
47
|
+
"spec/css/big.css",
|
|
48
|
+
"spec/css/colors.css",
|
|
49
|
+
"spec/css/comments.css",
|
|
50
|
+
"spec/css/css-3.css",
|
|
51
|
+
"spec/css/css.css",
|
|
52
|
+
"spec/css/dash-prefix.css",
|
|
53
|
+
"spec/css/functions.css",
|
|
54
|
+
"spec/css/import-with-extra-paths.css",
|
|
55
|
+
"spec/css/import-with-partial-in-extra-path.css",
|
|
56
|
+
"spec/css/import.css",
|
|
57
|
+
"spec/css/lazy-eval.css",
|
|
58
|
+
"spec/css/mixins-args.css",
|
|
59
|
+
"spec/css/mixins.css",
|
|
60
|
+
"spec/css/operations.css",
|
|
61
|
+
"spec/css/parens.css",
|
|
62
|
+
"spec/css/rulesets.css",
|
|
63
|
+
"spec/css/scope.css",
|
|
64
|
+
"spec/css/selectors.css",
|
|
65
|
+
"spec/css/strings.css",
|
|
66
|
+
"spec/css/variables.css",
|
|
67
|
+
"spec/css/whitespace.css",
|
|
35
68
|
"spec/engine_spec.rb",
|
|
69
|
+
"spec/less/accessors.less",
|
|
70
|
+
"spec/less/big.less",
|
|
71
|
+
"spec/less/colors.less",
|
|
72
|
+
"spec/less/comments.less",
|
|
73
|
+
"spec/less/css-3.less",
|
|
74
|
+
"spec/less/css.less",
|
|
75
|
+
"spec/less/dash-prefix.less",
|
|
76
|
+
"spec/less/exceptions/mixed-units-error.less",
|
|
77
|
+
"spec/less/exceptions/name-error-1.0.less",
|
|
78
|
+
"spec/less/exceptions/syntax-error-1.0.less",
|
|
79
|
+
"spec/less/extra_import_path/extra.less",
|
|
80
|
+
"spec/less/extra_import_path/import/import-test-a.css",
|
|
81
|
+
"spec/less/extra_import_path/import/import-test-a.less",
|
|
82
|
+
"spec/less/functions.less",
|
|
83
|
+
"spec/less/hidden.less",
|
|
84
|
+
"spec/less/import-with-extra-paths.less",
|
|
85
|
+
"spec/less/import.less",
|
|
86
|
+
"spec/less/import/import-test-a.less",
|
|
87
|
+
"spec/less/import/import-test-b.less",
|
|
88
|
+
"spec/less/import/import-test-c.less",
|
|
89
|
+
"spec/less/import/import-test-d.css",
|
|
90
|
+
"spec/less/lazy-eval.less",
|
|
91
|
+
"spec/less/literal-css.less",
|
|
92
|
+
"spec/less/mixins-args.less",
|
|
93
|
+
"spec/less/mixins.less",
|
|
94
|
+
"spec/less/operations.less",
|
|
95
|
+
"spec/less/parens.less",
|
|
96
|
+
"spec/less/rulesets.less",
|
|
97
|
+
"spec/less/scope.less",
|
|
98
|
+
"spec/less/selectors.less",
|
|
99
|
+
"spec/less/strings.less",
|
|
100
|
+
"spec/less/variables.less",
|
|
101
|
+
"spec/less/whitespace.less",
|
|
36
102
|
"spec/spec.css",
|
|
37
|
-
"spec/
|
|
38
|
-
"spec/spec_helper.rb",
|
|
39
|
-
"spec/tree_spec.rb"
|
|
103
|
+
"spec/spec_helper.rb"
|
|
40
104
|
]
|
|
41
|
-
s.has_rdoc = true
|
|
42
105
|
s.homepage = %q{http://www.lesscss.org}
|
|
43
106
|
s.rdoc_options = ["--charset=UTF-8"]
|
|
44
107
|
s.require_paths = ["lib"]
|
|
45
108
|
s.rubyforge_project = %q{less}
|
|
46
|
-
s.rubygems_version = %q{1.3.
|
|
109
|
+
s.rubygems_version = %q{1.3.5}
|
|
47
110
|
s.summary = %q{LESS compiler}
|
|
48
111
|
s.test_files = [
|
|
49
112
|
"spec/command_spec.rb",
|
|
50
113
|
"spec/engine_spec.rb",
|
|
51
|
-
"spec/spec_helper.rb"
|
|
52
|
-
"spec/tree_spec.rb"
|
|
114
|
+
"spec/spec_helper.rb"
|
|
53
115
|
]
|
|
54
116
|
|
|
55
117
|
if s.respond_to? :specification_version then
|
|
56
118
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
57
|
-
s.specification_version =
|
|
119
|
+
s.specification_version = 3
|
|
58
120
|
|
|
59
121
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
122
|
+
s.add_runtime_dependency(%q<treetop>, [">= 1.4.2"])
|
|
123
|
+
s.add_runtime_dependency(%q<mutter>, [">= 0.4.2"])
|
|
60
124
|
else
|
|
125
|
+
s.add_dependency(%q<treetop>, [">= 1.4.2"])
|
|
126
|
+
s.add_dependency(%q<mutter>, [">= 0.4.2"])
|
|
61
127
|
end
|
|
62
128
|
else
|
|
129
|
+
s.add_dependency(%q<treetop>, [">= 1.4.2"])
|
|
130
|
+
s.add_dependency(%q<mutter>, [">= 0.4.2"])
|
|
63
131
|
end
|
|
64
132
|
end
|
|
133
|
+
|
data/lib/less/command.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
module Less
|
|
2
2
|
class Command
|
|
3
|
-
CSS = '.css'
|
|
4
|
-
|
|
5
3
|
attr_accessor :source, :destination, :options
|
|
6
4
|
|
|
7
5
|
def initialize options
|
|
6
|
+
$verbose = options[:debug]
|
|
8
7
|
@source = options[:source]
|
|
9
|
-
@destination = (options[:destination] || options[:source]).gsub /\.(less|lss)/,
|
|
8
|
+
@destination = (options[:destination] || options[:source]).gsub /\.(less|lss)/, '.css'
|
|
10
9
|
@options = options
|
|
10
|
+
@mutter = Mutter.new.clear
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def watch?() @options[:watch] end
|
|
@@ -16,9 +16,9 @@ module Less
|
|
|
16
16
|
|
|
17
17
|
# little function which allows us to
|
|
18
18
|
# Ctrl-C exit inside the passed block
|
|
19
|
-
def watch
|
|
19
|
+
def watch
|
|
20
20
|
begin
|
|
21
|
-
|
|
21
|
+
yield
|
|
22
22
|
rescue Interrupt
|
|
23
23
|
puts
|
|
24
24
|
exit 0
|
|
@@ -26,10 +26,10 @@ module Less
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def run!
|
|
29
|
-
compile(true) unless File.exist? @destination
|
|
30
|
-
|
|
31
29
|
if watch?
|
|
32
|
-
|
|
30
|
+
parse(true) unless File.exist? @destination
|
|
31
|
+
|
|
32
|
+
log "Watching for changes in #@source... Ctrl-C to abort.\n: "
|
|
33
33
|
|
|
34
34
|
# Main watch loop
|
|
35
35
|
loop do
|
|
@@ -37,55 +37,74 @@ module Less
|
|
|
37
37
|
|
|
38
38
|
# File has changed
|
|
39
39
|
if File.stat( @source ).mtime > File.stat( @destination ).mtime
|
|
40
|
-
|
|
40
|
+
print Time.now.strftime("%H:%M:%S -- ") if @options[:timestamps]
|
|
41
|
+
print "Change detected... "
|
|
41
42
|
|
|
42
43
|
# Loop until error is fixed
|
|
43
|
-
until
|
|
44
|
-
log "Press [
|
|
44
|
+
until parse
|
|
45
|
+
log "Press [return] to continue..."
|
|
45
46
|
watch { $stdin.gets }
|
|
46
47
|
end
|
|
47
48
|
end
|
|
48
49
|
end
|
|
49
50
|
else
|
|
50
|
-
|
|
51
|
+
parse
|
|
51
52
|
end
|
|
52
53
|
end
|
|
53
54
|
|
|
54
|
-
def
|
|
55
|
+
def parse new = false
|
|
55
56
|
begin
|
|
56
57
|
# Create a new Less object with the contents of a file
|
|
57
|
-
css = Less::Engine.new(
|
|
58
|
+
css = Less::Engine.new(File.new(@source), @options).to_css
|
|
58
59
|
css = css.delete " \n" if compress?
|
|
59
60
|
|
|
60
61
|
File.open( @destination, "w" ) do |file|
|
|
61
62
|
file.write css
|
|
62
63
|
end
|
|
63
|
-
|
|
64
|
+
|
|
65
|
+
act, file = (new ? 'Created' : 'Updated'), @destination.split('/').last
|
|
66
|
+
print "#{o("* #{act}", :green)} #{file}\n: " if watch?
|
|
67
|
+
Growl.notify "#{act} #{file}", :title => 'LESS' if @options[:growl] && @options[:verbose]
|
|
64
68
|
rescue Errno::ENOENT => e
|
|
65
69
|
abort "#{e}"
|
|
66
|
-
rescue SyntaxError
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
err "errors were found in the .less file! \n#{error}\n"
|
|
70
|
+
rescue SyntaxError => e
|
|
71
|
+
err "#{e}\n", "Syntax"
|
|
72
|
+
rescue CompileError => e
|
|
73
|
+
err "#{e}\n", "Compile"
|
|
71
74
|
rescue MixedUnitsError => e
|
|
72
|
-
err "`#{e}` you're mixing units together! What do you expect?\n"
|
|
73
|
-
rescue CompoundOperationError => e
|
|
74
|
-
err "`#{e}` operations in compound declarations aren't allowed, sorry!\n"
|
|
75
|
+
err "`#{e}` you're mixing units together! What do you expect?\n", "Mixed Units"
|
|
75
76
|
rescue PathError => e
|
|
76
|
-
err "`#{e}` was not found.\n"
|
|
77
|
+
err "`#{e}` was not found.\n", "Path"
|
|
78
|
+
rescue VariableNameError => e
|
|
79
|
+
err "#{o(e, :yellow)} is undefined.\n", "Variable Name"
|
|
80
|
+
rescue MixinNameError => e
|
|
81
|
+
err "#{o(e, :yellow)} is undefined.\n", "Mixin Name"
|
|
77
82
|
else
|
|
78
83
|
true
|
|
79
84
|
end
|
|
80
85
|
end
|
|
81
86
|
|
|
82
|
-
# Just a logging function to avoid typing '
|
|
87
|
+
# Just a logging function to avoid typing '*'
|
|
83
88
|
def log s = ''
|
|
84
89
|
print '* ' + s.to_s
|
|
85
90
|
end
|
|
86
91
|
|
|
87
|
-
def err s = ''
|
|
88
|
-
|
|
92
|
+
def err s = '', type = ''
|
|
93
|
+
type = type.strip + ' ' unless type.empty?
|
|
94
|
+
$stderr.print "#{o("! #{type}Error", :red)}: #{s}"
|
|
95
|
+
if @options[:growl]
|
|
96
|
+
growl = Growl.new
|
|
97
|
+
growl.title = "LESS"
|
|
98
|
+
growl.message = "#{type}Error in #@source!"
|
|
99
|
+
growl.run
|
|
100
|
+
false
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
private
|
|
105
|
+
|
|
106
|
+
def o ex, *styles
|
|
107
|
+
@mutter.process(ex.to_s, *(@options[:color] ? styles : []))
|
|
89
108
|
end
|
|
90
109
|
end
|
|
91
|
-
end
|
|
110
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Less
|
|
2
|
+
module StyleSheet
|
|
3
|
+
grammar Common
|
|
4
|
+
#
|
|
5
|
+
# Whitespace
|
|
6
|
+
#
|
|
7
|
+
rule s
|
|
8
|
+
[ ]*
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
rule S
|
|
12
|
+
[ ]+
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
rule ws
|
|
16
|
+
[\n ]*
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
rule WS
|
|
20
|
+
[\n ]+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Non-space char
|
|
24
|
+
rule ns
|
|
25
|
+
![ ;,!})\n] .
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|