Class: HtmlMockupAutoprefixer::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/html_mockup-autoprefixer/processor.rb

Instance Method Summary collapse

Instance Method Details

#call(release, options = {}) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :match (Array)

    An array of shell globs, defaults to [“stylesheets/*/.scss”]

  • :skip (Array)

    An array of regexps which will be skipped, defaults to [/_.*.scssZ/], Attention! Skipped files will be deleted as well!



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/html_mockup-autoprefixer/processor.rb', line 5

def call(release, options={})
  options = {
    :match => ["stylesheets/**/*.css"],
    :skip => []
  }.update(options)
  
  match = options.delete(:match)
  skip = options.delete(:skip)
  
  # Prefix CSS files
  files = release.get_files(match)
  files.each do |f|
    if !skip.detect{|r| r.match(f) }
      release.log(self, "Processing: #{f}")          
      # Compile SCSS
      content = File.read(f)
      File.open(f, "w") do |fh|
        fh.write AutoprefixerRails.compile(content)
      end
    end        
  end
end