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, #process_erb, #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
29
30
31
|
# File 'lib/compass/compiler.rb', line 29
def corresponding_css_file(sass_file)
"#{to}/#{stylesheet_name(sass_file)}.css"
end
|
#css_files ⇒ Object
25
26
27
|
# File 'lib/compass/compiler.rb', line 25
def css_files
@css_files ||= sass_files.map{|sass_file| corresponding_css_file(sass_file)}
end
|
#run ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/compass/compiler.rb', line 45
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|
begin
compile sass_filename, css_filename, options
rescue Sass::SyntaxError => e
full_exception = Compass.configuration.environment == :development
logger.record :error, basename(sass_filename), "(Line #{e.sass_line}: #{e.message})"
write_file(css_filename,
Sass::SyntaxError.exception_to_css(e, :full_exception => full_exception),
options.merge(:force => true))
end
end
end
|
#sass_files(options = {}) ⇒ Object
16
17
18
19
|
# File 'lib/compass/compiler.rb', line 16
def sass_files(options = {})
exclude_partials = options.fetch(:exclude_partials, true)
@sass_files || Dir.glob(separate("#{from}/**/#{'[^_]' if exclude_partials}*.sass"))
end
|
#stylesheet_name(sass_file) ⇒ Object
21
22
23
|
# File 'lib/compass/compiler.rb', line 21
def stylesheet_name(sass_file)
sass_file[("#{from}/".length)..-6]
end
|
#target_directories ⇒ Object
33
34
35
|
# File 'lib/compass/compiler.rb', line 33
def target_directories
css_files.map{|css_file| File.dirname(css_file)}.uniq.sort.sort_by{|d| d.length }
end
|