Class: WebResourceBundler::Filters::CdnFilter::Filter

Inherits:
BaseFilter
  • Object
show all
Defined in:
lib/web_resource_bundler/filters/cdn_filter.rb

Constant Summary collapse

FILE_PREFIX =
'cdn_'
IMAGE_URL_PATTERN =
/url\s*\(['|"]?([^\)'"]+\.(jpg|gif|png|jpeg|bmp))['|"]?\)/i

Instance Attribute Summary

Attributes inherited from BaseFilter

#settings

Instance Method Summary collapse

Methods inherited from BaseFilter

#set_settings

Constructor Details

#initialize(settings, file_manager) ⇒ Filter

Returns a new instance of Filter.



7
8
9
# File 'lib/web_resource_bundler/filters/cdn_filter.rb', line 7

def initialize(settings, file_manager)
  super(settings, file_manager)
end

Instance Method Details

#apply!(block_data) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/web_resource_bundler/filters/cdn_filter.rb', line 11

def apply!(block_data)
  block_data.styles.each do |file| 
    rewrite_content_urls!(file.path, file.content) unless file.content.empty? 
    file.path = new_filepath(file.path)
  end
  block_data
end