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 13 def self.call(input) filename = 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 32 def self.install(env) if ::Sprockets::VERSION.to_f < 4 env.register_postprocessor("text/css", ::AutoprefixerRails::Sprockets) else env.register_bundle_processor("text/css", ::AutoprefixerRails::Sprockets) end end
new(filename) { || ... }
click to toggle source
Sprockets
2 API new and render
# File lib/autoprefixer-rails/sprockets.rb, line 54 def initialize(filename) @filename = filename @source = yield end
register_processor(processor)
click to toggle source
# File lib/autoprefixer-rails/sprockets.rb, line 8 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 20 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| warn "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 43 def self.uninstall(env) if ::Sprockets::VERSION.to_f < 4 env.unregister_postprocessor("text/css", ::AutoprefixerRails::Sprockets) 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 60 def render(*) self.class.run(@filename, @source) end