Method: Less::Command#parse

Defined in:
lib/less/command.rb

#parse(is_new = false) ⇒ Object



54
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
# File 'lib/less/command.rb', line 54

def parse is_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 = (is_new ? 'Created' : 'Updated'), @destination.split('/').last
    print "* #{act} #{file}\n: " if watch?
    Growl.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 "#{e} is undefined.\n", "Variable Name"
  rescue MixinNameError => e
    err "#{e} is undefined.\n", "Mixin Name"
  else
    true
  end
end