Method: Less::Command#parse

Defined in:
lib/less/command.rb

#parse(new = false) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/less/command.rb', line 55

def parse new = false
  begin
    # Create a new Less object with the contents of a file
    css = Less::Engine.new(File.new(@source), @options).to_css
    css = css.delete " \n" if compress?

    File.open( @destination, "w" ) do |file|
      file.write css
    end

    act, file = (new ? 'Created' : 'Updated'), @destination.split('/').last
    print "#{o("* #{act}", :green)} #{file}\n: " if watch?
    # Growl.notify "#{act} #{file}", :title => 'LESS' if @options[:growl] && @options[:verbose]
    Notifier.notify "#{act} #{file}", :title => 'LESS' if @options[:growl] && @options[:verbose]
  rescue Errno::ENOENT => e
    abort "#{e}"
  rescue SyntaxError => e
    err "#{e}\n", "Syntax"
  rescue CompileError => e
    err "#{e}\n", "Compile"
  rescue MixedUnitsError => e
    err "`#{e}` you're  mixing units together! What do you expect?\n", "Mixed Units"
  rescue PathError => e
    err "`#{e}` was not found.\n", "Path"
  rescue VariableNameError => e
    err "#{o(e, :yellow)} is undefined.\n", "Variable Name"
  rescue MixinNameError => e
    err "#{o(e, :yellow)} is undefined.\n", "Mixin Name"
  else
    true
  end
end