Class: AssetMapper::ManifestGenerator

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/asset_mapper/manifest_generator.rb

Constant Summary collapse

FILES =
Dry::Files.new

Instance Method Summary collapse

Instance Method Details

#configAssetMapper::Configuration



11
# File 'lib/asset_mapper/manifest_generator.rb', line 11

param :config

#generateObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/asset_mapper/manifest_generator.rb', line 13

def generate
  return if config.asset_files.nil?
  return if config.asset_files.size.zero?

  map = {
    "files" => {}
  }

  config.asset_files.each do |file|
    hash = handle_file(file)

    map["files"][hash[:relative_path]] = {
      file_path: hash[:file_path],
      asset_path: hash[:asset_path]
    }
  end

  FILES.write(config.manifest_output_path, JSON.pretty_generate(map))
end