Class: Propshaft::Compilers::CssAssetUrls

Inherits:
Object
  • Object
show all
Defined in:
lib/propshaft/compilers/css_asset_urls.rb

Constant Summary collapse

ASSET_URL_PATTERN =
/url\(\s*["']?(?!(?:\#|data|http))([^"'\s)]+)\s*["']?\)/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(assembly) ⇒ CssAssetUrls

Returns a new instance of CssAssetUrls.



9
10
11
# File 'lib/propshaft/compilers/css_asset_urls.rb', line 9

def initialize(assembly)
  @assembly = assembly
end

Instance Attribute Details

#assemblyObject (readonly)

Returns the value of attribute assembly.



5
6
7
# File 'lib/propshaft/compilers/css_asset_urls.rb', line 5

def assembly
  @assembly
end

Instance Method Details

#compile(logical_path, input) ⇒ Object



13
14
15
# File 'lib/propshaft/compilers/css_asset_urls.rb', line 13

def compile(logical_path, input)
  input.gsub(ASSET_URL_PATTERN) { asset_url resolve_path(logical_path.dirname, $1) }
end