Class: Redmine::Asset

Inherits:
Propshaft::Asset
  • Object
show all
Defined in:
lib/redmine/asset_path.rb

Constant Summary collapse

ASSET_URL_PATTERN =
/(url\(\s*["']?([^"'\s)]+)\s*["']?\s*\))/

Instance Method Summary collapse

Constructor Details

#initialize(file, logical_path:, load_path:, transition_map:) ⇒ Asset

Returns a new instance of Asset.



192
193
194
195
# File 'lib/redmine/asset_path.rb', line 192

def initialize(file, logical_path:, load_path:, transition_map:)
  @transition_map = transition_map
  super(file, logical_path: logical_path, load_path: load_path)
end

Instance Method Details

#contentObject



197
198
199
200
201
202
203
# File 'lib/redmine/asset_path.rb', line 197

def content
  if conversion = @transition_map[logical_path.dirname.to_s]
    convert_path super, conversion
  else
    super
  end
end

#convert_path(input, conversion) ⇒ Object



207
208
209
210
211
212
213
214
# File 'lib/redmine/asset_path.rb', line 207

def convert_path(input, conversion)
  input.gsub(ASSET_URL_PATTERN) do |matched|
    conversion.each do |key, val|
      matched.sub!(key, val)
    end
    matched
  end
end