Class: AssetTrip::UrlRewriter

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::AssetTagHelper
Defined in:
lib/asset_trip/url_rewriter.rb

Instance Method Summary collapse

Constructor Details

#initialize(scheme, stylesheet_path = nil) ⇒ UrlRewriter

Returns a new instance of UrlRewriter.



10
11
12
13
14
15
# File 'lib/asset_trip/url_rewriter.rb', line 10

def initialize(scheme, stylesheet_path = nil)
  @scheme = scheme
  @stylesheet_path = stylesheet_path

  setup_fake_controller_for_asset_host_computation
end

Instance Method Details

#rewrite(contents) ⇒ Object



17
18
19
20
21
# File 'lib/asset_trip/url_rewriter.rb', line 17

def rewrite(contents)
  contents.gsub(/url *\(([^\)]+)\)/) do
    "url(#{add_asset_host_to_path($1)})"
  end
end