Class: Benoit::Filters::SassFilter
- Inherits:
-
Rake::Pipeline::Filter
- Object
- Rake::Pipeline::Filter
- Benoit::Filters::SassFilter
- Defined in:
- lib/benoit/filters/sass_filter.rb
Instance Attribute Summary collapse
-
#additional_load_paths ⇒ Object
readonly
Returns the value of attribute additional_load_paths.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #additional_dependencies(input = nil) ⇒ Object
- #generate_output(inputs, output) ⇒ Object
-
#initialize(options = {}) ⇒ SassFilter
constructor
A new instance of SassFilter.
Constructor Details
#initialize(options = {}) ⇒ SassFilter
Returns a new instance of SassFilter.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/benoit/filters/sass_filter.rb', line 15 def initialize(={}) load_paths = .delete(:additional_load_paths) || [] # TODO: Handle files that don't end in .scss block ||= proc { |input| input.sub(/\.(?:css\.)?(scss|sass)$/, '.css') } super(&block) Compass.add_project_configuration Compass.configuration.project_path ||= Dir.pwd @additional_load_paths = Compass.configuration.sass_load_paths @additional_load_paths += load_paths.map do |f| File.(f) end @options = @options[:load_paths] ||= [] @options[:load_paths].concat(additional_load_paths) end |
Instance Attribute Details
#additional_load_paths ⇒ Object (readonly)
Returns the value of attribute additional_load_paths.
13 14 15 |
# File 'lib/benoit/filters/sass_filter.rb', line 13 def additional_load_paths @additional_load_paths end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/benoit/filters/sass_filter.rb', line 13 def @options end |
Instance Method Details
#additional_dependencies(input = nil) ⇒ Object
57 58 59 |
# File 'lib/benoit/filters/sass_filter.rb', line 57 def additional_dependencies(input=nil) Dir.glob("**/*.scss") end |
#generate_output(inputs, output) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/benoit/filters/sass_filter.rb', line 35 def generate_output(inputs, output) inputs.each do |input| begin = (input).merge(filename: input.path) sass_engine = Sass::Engine.for_file(input.fullpath, ) output.write sass_engine.render rescue Sass::SyntaxError => ex path = ex.sass_filename.gsub(input.root + "/", "") missing_files = ex..scan(/File to import not found or unreadable: ([\w\-]*)\./).flatten if missing_files.empty? error = Benoit::CompilerError.new(nil, path, ex) error.line = ex.sass_line else error = Benoit::FileMissingError.new(missing_files.first, ex.sass_line, path, ex) end raise error rescue StandardError => ex raise Benoit::CompilerError.new(nil, path, ex) end end end |