Method: Less::Command#parse

Defined in:
lib/less/command.rb

#parse(new = false) ⇒ Object



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

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

    File.open( @destination, "w" ) do |file|
      file.write css
    end
    print "#{new ? '* [Created]' : '* [Updated]'} #{@destination.split('/').last}\n: " if watch?
  rescue Errno::ENOENT => e
    abort "#{e}"
  rescue SyntaxError => e
    err "#{e}\n", "Parse"
  rescue MixedUnitsError => e
    err "`#{e}` you're  mixing units together! What do you expect?\n"
  rescue PathError => e
    err "`#{e}` was not found.\n", "Path"
  rescue VariableNameError => e
    err "`#{e}` is undefined.\n", "Name"
  rescue MixinNameError => e
    err "`#{e}` is undefined.\n", "Name"
  else
    true
  end
end