Class: Pieces::StyleCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/pieces/compilers/style_compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ StyleCompiler

Returns a new instance of StyleCompiler.



5
6
7
# File 'lib/pieces/compilers/style_compiler.rb', line 5

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

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/pieces/compilers/style_compiler.rb', line 3

def path
  @path
end

Instance Method Details

#compile(files) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/pieces/compilers/style_compiler.rb', line 9

def compile(files)
  files.merge('compiled.css' => { contents: '', type: 'css' }).tap do |files|
    Dir["#{path}/app/views/*/*.{css,scss,sass,less}"].each do |file|
      files['compiled.css'][:contents] << ::Tilt.new(file).render
    end
  end
end