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
-
#convert_options(opts) ⇒ Object
Convert ruby_options to jsOptions.
-
#info ⇒ Object
Return, which browsers and prefixes will be used.
-
#initialize(params = {}) ⇒ Processor
constructor
A new instance of Processor.
-
#process(css, opts = {}) ⇒ Object
Process ‘css` and return result.
-
#processor ⇒ Object
Lazy load for JS instance.
Constructor Details
#initialize(params = {}) ⇒ Processor
Returns a new instance of Processor.
7 8 9 |
# File 'lib/autoprefixer-rails/processor.rb', line 7 def initialize(params = {}) @params = params end |
Instance Method Details
#convert_options(opts) ⇒ Object
Convert ruby_options to jsOptions
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/autoprefixer-rails/processor.rb', line 34 def (opts) converted = { } opts.each_pair do |name, value| if name =~ /_/ name = name.to_s.gsub(/_\w/) { |i| i.gsub('_', '').upcase }.to_sym end value = (value) if value.is_a? Hash converted[name] = value end converted end |
#info ⇒ Object
Return, which browsers and prefixes will be used
24 25 26 |
# File 'lib/autoprefixer-rails/processor.rb', line 24 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.
17 18 19 20 21 |
# File 'lib/autoprefixer-rails/processor.rb', line 17 def process(css, opts = {}) opts = (opts) result = processor.call('process', css, opts) Result.new(result['css'], result['map']) end |
#processor ⇒ Object
Lazy load for JS instance
29 30 31 |
# File 'lib/autoprefixer-rails/processor.rb', line 29 def processor @processor ||= ExecJS.compile(build_js) end |