Sha256: 2e60099e704d6819479f140d04fe1825b0462ddaf8f5bd1a9fbdc3231fb37dae

Contents?: true

Size: 1.16 KB

Versions: 12

Compression:

Stored size: 1.16 KB

Contents

# Use the sass gem
require 'sass'

module HtmlMockup::Release::Processors
  class Sass < Base
    # @param [Hash] options Options as described below, all other options will be passed to Sass.compile_file.
    #
    # @option options [Array] :match An array of shell globs, defaults to ["stylesheets/**/*.scss"]
    # @option options [Array] :skip An array of regexps which will be skipped, defaults to [/_.*\.scss\Z/], Attention! Skipped files will be deleted as well!
    def call(release, options={})
      options = {
        :match => ["stylesheets/**/*.scss"],
        :skip => [/_.*\.scss\Z/],
        :style => :expanded
      }.update(options)
      
      match = options.delete(:match)
      skip = options.delete(:skip)
      
      # Sassify SCSS files
      files = release.get_files(match)
      files.each do |f|
        if !skip.detect{|r| r.match(f) }
          release.log(self, "Processing: #{f}")          
          # Compile SCSS
          ::Sass.compile_file(f, f.gsub(/\.scss$/, ".css"), options)
        end        
      end
      
      # Cleanup
      files.each do |f|
        # Remove source file
        File.unlink(f)
      end
      
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
html_mockup-0.7.2 lib/html_mockup/release/processors/sass.rb
html_mockup-0.7.1 lib/html_mockup/release/processors/sass.rb
html_mockup-0.7.0 lib/html_mockup/release/processors/sass.rb
html_mockup-0.6.5 lib/html_mockup/release/processors/sass.rb
html_mockup-0.6.4 lib/html_mockup/release/processors/sass.rb
html_mockup-0.6.3 lib/html_mockup/release/processors/sass.rb
html_mockup-0.6.2 lib/html_mockup/release/processors/sass.rb
html_mockup-0.6.1 lib/html_mockup/release/processors/sass.rb
html_mockup-0.6.0 lib/html_mockup/release/processors/sass.rb
html_mockup-0.5.2 lib/html_mockup/release/processors/sass.rb
html_mockup-0.5.1 lib/html_mockup/release/processors/sass.rb
html_mockup-0.5.0 lib/html_mockup/release/processors/sass.rb