Class: AutoprefixerRails::Sprockets
- Inherits:
-
Object
- Object
- AutoprefixerRails::Sprockets
- Defined in:
- lib/autoprefixer-rails/sprockets.rb
Overview
Register autoprefixer postprocessor in Sprockets and fix common issues
Class Method Summary collapse
-
.call(input) ⇒ Object
Sprockets 3 and 4 API.
-
.install(env) ⇒ Object
Register postprocessor in Sprockets depend on issues with other gems.
- .register_processor(processor) ⇒ Object
-
.run(filename, css) ⇒ Object
Add prefixes to ‘css`.
-
.uninstall(env) ⇒ Object
Register postprocessor in Sprockets depend on issues with other gems.
Instance Method Summary collapse
-
#initialize(filename) ⇒ Sprockets
constructor
Sprockets 2 API new and render.
-
#render ⇒ Object
Sprockets 2 API new and render.
Constructor Details
#initialize(filename) ⇒ Sprockets
Sprockets 2 API new and render
54 55 56 57 |
# File 'lib/autoprefixer-rails/sprockets.rb', line 54 def initialize(filename) @filename = filename @source = yield end |
Class Method Details
.call(input) ⇒ Object
Sprockets 3 and 4 API
13 14 15 16 17 |
# File 'lib/autoprefixer-rails/sprockets.rb', line 13 def self.call(input) filename = input[:filename] source = input[:data] run(filename, source) end |
.install(env) ⇒ Object
Register postprocessor in Sprockets depend on issues with other gems
32 33 34 35 36 37 38 39 40 |
# 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 |
.register_processor(processor) ⇒ Object
8 9 10 |
# File 'lib/autoprefixer-rails/sprockets.rb', line 8 def self.register_processor(processor) @processor = processor end |
.run(filename, css) ⇒ Object
Add prefixes to ‘css`
20 21 22 23 24 25 26 27 28 29 |
# 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) ⇒ Object
Register postprocessor in Sprockets depend on issues with other gems
43 44 45 46 47 48 49 50 51 |
# 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 |
Instance Method Details
#render ⇒ Object
Sprockets 2 API new and render
60 61 62 |
# File 'lib/autoprefixer-rails/sprockets.rb', line 60 def render(*) self.class.run(@filename, @source) end |