Sha256: 09f2da0d518f0023c9178256604574e169ad8c0dff6057f870e979994c1e4bbd

Contents?: true

Size: 699 Bytes

Versions: 1

Compression:

Stored size: 699 Bytes

Contents

module Pieces
  class StyleCompiler
    attr_reader :path

    def initialize(config = {})
      @path = config[:path] || Dir.pwd
    end

    def compile(files)
      files.merge('compiled.css' => { contents: '', type: 'css' }).tap do |files|
        files['compiled.css'][:contents] << yield_stylesheets('app/assets/stylesheets/components')
        files['compiled.css'][:contents] << yield_stylesheets('app/views')
      end
    end

    private

    def yield_stylesheets(dir)
      Dir["#{path}/#{dir}/**/*.{css,scss,sass,less}"].reduce('') do |contents, stylesheet|
        contents << ::Tilt.new(stylesheet, load_paths: ["#{path}/app/assets/stylesheets/"]).render
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pieces-0.3.10 lib/pieces/compilers/style_compiler.rb