Module: CloudfrontAssetHost::CssRewriter
- Defined in:
- lib/cloudfront_asset_host/css_rewriter.rb
Constant Summary collapse
- ReplaceRexeg =
matches optional quoted url(<path>)
/url\(["']?([^\)\?"']+)(\?[^"']*)?["']?\)/i
Class Method Summary collapse
-
.rewrite_stylesheet(path) ⇒ Object
Returns the path to the temporary file that contains the rewritten stylesheet.
Class Method Details
.rewrite_stylesheet(path) ⇒ Object
Returns the path to the temporary file that contains the rewritten stylesheet
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cloudfront_asset_host/css_rewriter.rb', line 16 def rewrite_stylesheet(path) contents = File.read(path) contents.gsub!(ReplaceRexeg) do |match| rewrite_asset_link(match, path) end tmp = Tempfile.new("cfah-css") tmp.write(contents) tmp.flush tmp end |