class AutoprefixerRails::Sprockets
Register autoprefixer postprocessor in Sprockets and fix common issues
Public Class Methods
call(input)
click to toggle source
Sprockets 3 and 4 API
# File lib/autoprefixer-rails/sprockets.rb, line 11 def self.call(input) filename = input[:source_path] || input[:filename] source = input[:data] run(filename, source) end
install(env)
click to toggle source
Register postprocessor in Sprockets depend on issues with other gems
# File lib/autoprefixer-rails/sprockets.rb, line 35 def self.install(env) if ::Sprockets::VERSION.to_i < 4 env.register_postprocessor('text/css', :autoprefixer) do |context, css| process(context, css) end else env.register_bundle_processor('text/css', ::AutoprefixerRails::Sprockets) end end
new(filename, &block)
click to toggle source
Sprockets 2 API new and render
# File lib/autoprefixer-rails/sprockets.rb, line 57 def initialize(filename, &block) @filename = filename @source = block.call end
process(context, css)
click to toggle source
Sprockets 2 compatibility
# File lib/autoprefixer-rails/sprockets.rb, line 18 def self.process(context, css) self.run(context.pathname.to_s, css) end
register_processor(processor)
click to toggle source
# File lib/autoprefixer-rails/sprockets.rb, line 6 def self.register_processor(processor) @processor = processor end
run(filename, css)
click to toggle source
Add prefixes to `css`
# File lib/autoprefixer-rails/sprockets.rb, line 23 def self.run(filename, css) output = filename.chomp(File.extname(filename)) + '.css' result = @processor.process(css, from: filename, to: output) result.warnings.each do |warning| $stderr.puts "autoprefixer: #{ warning }" end result.css end
uninstall(env)
click to toggle source
Register postprocessor in Sprockets depend on issues with other gems
# File lib/autoprefixer-rails/sprockets.rb, line 47 def self.uninstall(env) if ::Sprockets::VERSION.to_i < 4 env.unregister_postprocessor('text/css', :autoprefixer) else env.unregister_bundle_processor('text/css', ::AutoprefixerRails::Sprockets) end end
Public Instance Methods
render(_, _)
click to toggle source
Sprockets 2 API new and render
# File lib/autoprefixer-rails/sprockets.rb, line 63 def render(_, _) self.class.run(@filename, @source) end