Class: Compass::Compiler

Inherits:
Object
  • Object
show all
Includes:
Actions
Defined in:
lib/compass/compiler.rb

Instance Attribute Summary collapse

Attributes included from Actions

#logger

Instance Method Summary collapse

Methods included from Actions

#basename, #compile, #copy, #directory, #relativize, #separate, #strip_trailing_separator, #write_file

Constructor Details

#initialize(working_path, from, to, options) ⇒ Compiler

Returns a new instance of Compiler.



8
9
10
11
12
13
# File 'lib/compass/compiler.rb', line 8

def initialize(working_path, from, to, options)
  self.working_path = working_path
  self.from, self.to = from, to
  self.logger = options.delete(:logger)
  self.options = options
end

Instance Attribute Details

#fromObject

Returns the value of attribute from.



6
7
8
# File 'lib/compass/compiler.rb', line 6

def from
  @from
end

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'lib/compass/compiler.rb', line 6

def options
  @options
end

#toObject

Returns the value of attribute to.



6
7
8
# File 'lib/compass/compiler.rb', line 6

def to
  @to
end

#working_pathObject

Returns the value of attribute working_path.



6
7
8
# File 'lib/compass/compiler.rb', line 6

def working_path
  @working_path
end

Instance Method Details

#css_filesObject



23
24
25
# File 'lib/compass/compiler.rb', line 23

def css_files
  @css_files || sass_files.map{|sass_file| "#{to}/#{stylesheet_name(sass_file)}.css"}
end

#runObject



31
32
33
34
35
36
37
38
# File 'lib/compass/compiler.rb', line 31

def run
  target_directories.each do |dir|
    directory dir
  end
  sass_files.zip(css_files).each do |sass_filename, css_filename|
    compile sass_filename, css_filename, options
  end
end

#sass_filesObject



15
16
17
# File 'lib/compass/compiler.rb', line 15

def sass_files
  @sass_files || Dir.glob(separate("#{from}/**/[^_]*.sass"))
end

#stylesheet_name(sass_file) ⇒ Object



19
20
21
# File 'lib/compass/compiler.rb', line 19

def stylesheet_name(sass_file)
  sass_file[("#{from}/".length)..-6]
end

#target_directoriesObject



27
28
29
# File 'lib/compass/compiler.rb', line 27

def target_directories
  css_files.map{|css_file| File.dirname(css_file)}.uniq.sort.sort_by{|d| d.length }
end