Sha256: 9541ae5b2a6a0924b5fbebd2194cfe0aa66d5d0c3a78afd7b9607aa3d1b9130d

Contents?: true

Size: 1.15 KB

Versions: 11

Compression:

Stored size: 1.15 KB

Contents

# ===========================================================================
# Project:   Abbot - SproutCore Build Tools
# Copyright: ©2009 Apple Inc.
#            portions copyright @2006-2009 Sprout Systems, Inc.
#            and contributors
# ===========================================================================

require "sproutcore/builders/stylesheet"
require 'fileutils'

module SC

  # This build can compile a Less stylesheet.
  class Builder::Less < Builder::Stylesheet

    def build(dst_path)
      begin
        require 'less'
      rescue
        raise "Cannot compile #{entry.source_path} because less is not installed.  Please try 'sudo gem install less' and try again"
      end

      begin
        content = readlines(entry.source_path)
        css = ::Less::Engine.new(content).to_css
        lines = []
        css.each_line { |l| lines << rewrite_inline_code(l) }
        writelines dst_path, lines
      rescue Exception => e

        # explain sass syntax error a bit more...
        if e.is_a? Less::SyntaxError
          e.message << " of #{@entry.source_path}"
        end
        raise e # reraise
      end # rescue
    end # def

  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sproutcore-1.4.4-java lib/sproutcore/builders/less.rb
sproutcore-1.4.4 lib/sproutcore/builders/less.rb
sproutcore-1.4.3.1 lib/sproutcore/builders/less.rb
sproutcore-1.4.3-java lib/sproutcore/builders/less.rb
sproutcore-1.4.3 lib/sproutcore/builders/less.rb
sproutcore-1.4.2-java lib/sproutcore/builders/less.rb
sproutcore-1.4.2 lib/sproutcore/builders/less.rb
sproutcore-1.4.1-java lib/sproutcore/builders/less.rb
sproutcore-1.4.1 lib/sproutcore/builders/less.rb
sproutcore-1.4.0-java lib/sproutcore/builders/less.rb
sproutcore-1.4.0 lib/sproutcore/builders/less.rb