less 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
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 > a { text-decoration: none }
24
- .article > p { color: #110011 }
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.6
1
+ 0.8.7
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{less}
5
- s.version = "0.8.6"
5
+ s.version = "0.8.7"
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-06-04}
9
+ s.date = %q{2009-06-15}
10
10
  s.default_executable = %q{lessc}
11
11
  s.description = %q{LESS is leaner CSS}
12
12
  s.email = %q{alexis@cloudhead.net}
@@ -4,9 +4,9 @@ require 'less/command'
4
4
  require 'less/engine'
5
5
  require 'less/tree'
6
6
 
7
- module Less
8
- class MixedUnitsError < Exception
9
- end
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') )
@@ -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,7 +46,7 @@ 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
52
  css = Less::Engine.new( File.read( @source ) ).to_css @options[:inheritance]
@@ -53,16 +55,18 @@ module Less
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
- log " !! errors were found in the .less file! \n#{error}\n"
64
- rescue MixedUnitsError
65
- log "!! You're mixing units together! what do you expect?\n"
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 '} ' + s.to_s
77
+ print '* ' + s.to_s
78
+ end
79
+
80
+ def err s = ''
81
+ print "!! #{s}"
74
82
  end
75
83
  end
76
84
  end
@@ -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,9 +106,9 @@ module Less
106
106
  end
107
107
 
108
108
  if var
109
- node[ key ] = value.gsub REGEX[:path], var # Substitute variable with value
109
+ node[ key ] = value.gsub REGEX[:path], var # Substitute variable with value
110
110
  else
111
- node.delete key # Discard the declaration if the variable wasn't found
111
+ node.delete key # Discard the declaration if the variable wasn't found
112
112
  end
113
113
  end
114
114
  end
@@ -126,7 +126,7 @@ module Less
126
126
  # less: color: black;
127
127
  # hashify: "color" => "black"
128
128
  #
129
- hash = self.gsub(/\t/, ' '). # Tabs
129
+ hash = self.gsub(/\t+/, ' '). # Tabs
130
130
  gsub(/\r\n/, "\n"). # m$
131
131
  gsub(/\/\/.*/, ''). # Comments //
132
132
  gsub(/\/\*.*?\*\//m, ''). # Comments /*
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: less
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
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-06-04 00:00:00 -04:00
12
+ date: 2009-06-15 00:00:00 -04:00
13
13
  default_executable: lessc
14
14
  dependencies: []
15
15