Class: AssetFinder::Stylesheet::Normalizer

Inherits:
Object
  • Object
show all
Defined in:
lib/asset_finder/stylesheet/normalizer.rb

Instance Method Summary collapse

Constructor Details

#initialize(root_dir:, path_pattern_collection:) ⇒ Normalizer

Returns a new instance of Normalizer.



4
5
6
7
8
9
# File 'lib/asset_finder/stylesheet/normalizer.rb', line 4

def initialize(root_dir:, path_pattern_collection:)
  @root_dir = root_dir.to_s
  @path_pattern_collection = path_pattern_collection

  freeze
end

Instance Method Details

#normalize(path) ⇒ Object



11
12
13
14
15
16
# File 'lib/asset_finder/stylesheet/normalizer.rb', line 11

def normalize(path)
  match = path_pattern_collection.match(path: path)
  return unless match

  match[1].sub(root_dir, '') + '.css'
end