Class: AssetFinder::Stylesheet::DartsassConfigGenerator

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

Instance Method Summary collapse

Constructor Details

#initialize(root_dir: nil) ⇒ DartsassConfigGenerator

Returns a new instance of DartsassConfigGenerator.



6
7
8
9
10
11
12
13
# File 'lib/asset_finder/stylesheet/dartsass_config_generator.rb', line 6

def initialize(root_dir: nil)
  @root_dir = root_dir || File.join(Rails.root, 'app/assets/stylesheets/')
  @path_pattern_collection = PathPatternCollection.build
  @path_collector = PathCollector.new(root_dir: @root_dir, path_pattern_collection: @path_pattern_collection)
  @normalizer = Normalizer.new(root_dir: @root_dir, path_pattern_collection: @path_pattern_collection)

  freeze
end

Instance Method Details

#executeObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/asset_finder/stylesheet/dartsass_config_generator.rb', line 15

def execute
  {}.tap do |results|
    path_collector.execute.each do |path|
      key = path.delete_prefix(root_dir)
      value = normalizer.normalize(path)

      results[key] = value
    end
  end
end