class RailsPixrem::Sprockets
Public Class Methods
new(processor)
click to toggle source
# File lib/rails-pixrem/sprockets.rb, line 3 def initialize(processor) @processor = processor end
Public Instance Methods
install(assets)
click to toggle source
# File lib/rails-pixrem/sprockets.rb, line 21 def install(assets) if ignore_syntax_error? register(assets) { |context, css| process_only_css(context, css) } else register(assets) { |context, css| process(context, css) } end end
process(context, css)
click to toggle source
# File lib/rails-pixrem/sprockets.rb, line 7 def process(context, css) @processor.process(css) end
process_only_css(context, content)
click to toggle source
# File lib/rails-pixrem/sprockets.rb, line 11 def process_only_css(context, content) process(context, content) rescue ExecJS::ProgramError => e if e.message =~ /Can't parse CSS/ content else raise e end end
Private Instance Methods
ignore_syntax_error?()
click to toggle source
Return true if broken sass-rails is loaded
# File lib/rails-pixrem/sprockets.rb, line 36 def ignore_syntax_error? return false unless defined? Sass::Rails fixed = Gem::Version.new('4.0.1') current = Gem::Version.new(Sass::Rails::VERSION) current < fixed end
register(assets, &block)
click to toggle source
# File lib/rails-pixrem/sprockets.rb, line 31 def register(assets, &block) assets.register_postprocessor('text/css', :pixrem, &block) end