Class: AutoprefixerRails::Processor

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

Overview

Ruby to JS wrapper for Autoprefixer processor instance

Instance Method Summary collapse

Constructor Details

#initialize(browsers = nil, opts = {}) ⇒ Processor

Returns a new instance of Processor.



7
8
9
10
11
# File 'lib/autoprefixer-rails/processor.rb', line 7

def initialize(browsers = nil, opts = {})
  @browsers = browsers || []
  @options  = opts
  @options[:cascade] = true unless @options.has_key? :cascade
end

Instance Method Details

#infoObject

Return, which browsers and prefixes will be used



25
26
27
# File 'lib/autoprefixer-rails/processor.rb', line 25

def info
  processor.call('info')
end

#process(css, opts = {}) ⇒ Object

Process ‘css` and return result.

Options can be:

  • ‘from` with input CSS file name. Will be used in error messages.

  • ‘to` with output CSS file name.

  • ‘map` with true to generate new source map or with previous map.



19
20
21
22
# File 'lib/autoprefixer-rails/processor.rb', line 19

def process(css, opts = {})
  result = processor.call('process', css, opts)
  Result.new(result['css'], result['map'])
end

#processorObject

Lazy load for JS instance



30
31
32
# File 'lib/autoprefixer-rails/processor.rb', line 30

def processor
  @processor ||= ExecJS.compile(build_js)
end