Sha256: 4ba7d223f9f52182d27c8ea149c9af3e5f75b1c71e333ef8c2ebd6d50e5b802d
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
module Rack::PageSpeed::Filters class Base attr_reader :document, :options @@subclasses = [] def initialize options = {} @options = options end class << self def inherited klass @@subclasses << klass end def available_filters @@subclasses end def requires_store instance_eval do def new options = {} options[:store] ? super(options) : false end end end def name _name = nil _name ? @name = _name : @name ||= underscore(to_s) end def priority _number = nil _number ? @priority = _number.to_i : @priority end private def underscore word word.split('::').last. gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end end private def file_for node path = ::File.join options[:public], case node.name when 'script' node['src'] when 'img' node['src'] when 'link' node['href'] end ::File.open path if ::File.exists? path end end # shortcut Rack::PageSpeed::Filter = Base end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rack-pagespeed-1.0.1 | lib/rack/pagespeed/filters/base.rb |
rack-pagespeed-1.0.0 | lib/rack/pagespeed/filters/base.rb |
rack-pagespeed-0.2.0 | lib/rack/pagespeed/filters/base.rb |