Class: Compass::Compiler
- Inherits:
-
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, #remove, #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
14
|
# 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
self.options[:cache_location] ||= File.join(from, ".sass-cache")
end
|
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
6
7
8
|
# File 'lib/compass/compiler.rb', line 6
def from
@from
end
|
#options ⇒ Object
Returns the value of attribute options.
6
7
8
|
# File 'lib/compass/compiler.rb', line 6
def options
@options
end
|
#to ⇒ Object
Returns the value of attribute to.
6
7
8
|
# File 'lib/compass/compiler.rb', line 6
def to
@to
end
|
#working_path ⇒ Object
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
#corresponding_css_file(sass_file) ⇒ Object
28
29
30
|
# File 'lib/compass/compiler.rb', line 28
def corresponding_css_file(sass_file)
"#{to}/#{stylesheet_name(sass_file)}.css"
end
|
#css_files ⇒ Object
24
25
26
|
# File 'lib/compass/compiler.rb', line 24
def css_files
@css_files ||= sass_files.map{|sass_file| corresponding_css_file(sass_file)}
end
|
#out_of_date? ⇒ Boolean
36
37
38
39
40
41
42
|
# File 'lib/compass/compiler.rb', line 36
def out_of_date?
Compass.configure_sass_plugin! unless Compass.sass_plugin_configured?
sass_files.zip(css_files).each do |sass_filename, css_filename|
return sass_filename if Sass::Plugin.exact_stylesheet_needs_update?(css_filename, sass_filename)
end
false
end
|
#run ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'lib/compass/compiler.rb', line 44
def run
Compass.configure_sass_plugin! unless Compass.sass_plugin_configured?
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_files ⇒ Object
16
17
18
|
# File 'lib/compass/compiler.rb', line 16
def sass_files
@sass_files || Dir.glob(separate("#{from}/**/[^_]*.sass"))
end
|
#stylesheet_name(sass_file) ⇒ Object
20
21
22
|
# File 'lib/compass/compiler.rb', line 20
def stylesheet_name(sass_file)
sass_file[("#{from}/".length)..-6]
end
|
#target_directories ⇒ Object
32
33
34
|
# File 'lib/compass/compiler.rb', line 32
def target_directories
css_files.map{|css_file| File.dirname(css_file)}.uniq.sort.sort_by{|d| d.length }
end
|