Class: Rake::Pipeline::Web::Filters::SassFilter
- Inherits:
-
Filter
- Object
- Filter
- Rake::Pipeline::Web::Filters::SassFilter
- Includes:
- FilterWithDependencies
- Defined in:
- lib/rake-pipeline-web-filters/sass_filter.rb
Overview
Instance Attribute Summary collapse
-
#additional_load_paths ⇒ Hash
readonly
A hash of options to pass to Sass when compiling.
-
#options ⇒ Hash
readonly
A hash of options to pass to Sass when compiling.
Instance Method Summary collapse
- #additional_dependencies(input) ⇒ Object
-
#generate_output(inputs, output) ⇒ Object
Implement the #generate_output method required by the Filter API.
-
#initialize(options = {}, &block) ⇒ SassFilter
constructor
A new instance of SassFilter.
Constructor Details
#initialize(options = {}, &block) ⇒ SassFilter
Returns a new instance of SassFilter.
34 35 36 37 38 39 40 41 42 |
# File 'lib/rake-pipeline-web-filters/sass_filter.rb', line 34 def initialize(={}, &block) block ||= proc { |input| input.sub(/\.(scss|sass)$/, '.css') } super(&block) @options = @additional_load_paths = Array(.delete(:additional_load_paths)) @options[:load_paths].concat(@additional_load_paths) @options.merge!() end |
Instance Attribute Details
#additional_load_paths ⇒ Hash (readonly)
Returns a hash of options to pass to Sass when compiling.
26 27 28 |
# File 'lib/rake-pipeline-web-filters/sass_filter.rb', line 26 def additional_load_paths @additional_load_paths end |
#options ⇒ Hash (readonly)
Returns a hash of options to pass to Sass when compiling.
26 27 28 |
# File 'lib/rake-pipeline-web-filters/sass_filter.rb', line 26 def @options end |
Instance Method Details
#additional_dependencies(input) ⇒ Object
58 59 60 61 |
# File 'lib/rake-pipeline-web-filters/sass_filter.rb', line 58 def additional_dependencies(input) engine = Sass::Engine.new(input.read, (input)) engine.dependencies.map { |dep| dep.[:filename] } end |
#generate_output(inputs, output) ⇒ Object
Implement the #generate_output method required by the Filter API. Compiles each input file with Sass.
52 53 54 55 56 |
# File 'lib/rake-pipeline-web-filters/sass_filter.rb', line 52 def generate_output(inputs, output) inputs.each do |input| output.write Sass.compile(input.read, (input)) end end |