Class: AutoprefixerRails::Processor
- Inherits:
-
Object
- Object
- AutoprefixerRails::Processor
- Defined in:
- lib/autoprefixer-rails/processor.rb
Overview
Ruby to JS wrapper for Autoprefixer processor instance
Instance Method Summary collapse
-
#info ⇒ Object
Return, which browsers and prefixes will be used.
-
#initialize(params = { }) ⇒ Processor
constructor
A new instance of Processor.
-
#parse_config(config) ⇒ Object
Parse Browserslist config.
-
#process(css, opts = {}) ⇒ Object
Process ‘css` and return result.
Constructor Details
#initialize(params = { }) ⇒ Processor
Returns a new instance of Processor.
9 10 11 |
# File 'lib/autoprefixer-rails/processor.rb', line 9 def initialize(params = { }) @params = params || { } end |
Instance Method Details
#info ⇒ Object
Return, which browsers and prefixes will be used
30 31 32 |
# File 'lib/autoprefixer-rails/processor.rb', line 30 def info runtime.eval("autoprefixer(#{ js_params }).info()") end |
#parse_config(config) ⇒ Object
Parse Browserslist config
35 36 37 38 39 40 |
# File 'lib/autoprefixer-rails/processor.rb', line 35 def parse_config(config) config.gsub(/#[^\n]*/, '') .split(/\n/) .map(&:strip) .reject(&:empty?) 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 23 24 25 26 27 |
# File 'lib/autoprefixer-rails/processor.rb', line 19 def process(css, opts = {}) opts = (opts) result = runtime.exec( "processor = autoprefixer(#{ js_params(opts[:from]) });" + "return eval(process.apply(this, #{::JSON.generate([css,opts])}));") Result.new(result['css'], result['map']) end |