Sha256: 5f6a71327556e9814844d3fdcd82bd5309663038acb0591e62b071a573e98847
Contents?: true
Size: 777 Bytes
Versions: 5
Compression:
Stored size: 777 Bytes
Contents
module TsAssets module Generators class ConstGenerator < TsAssets::ApplicationGenerator # @return [Hash] attr_reader :mapping # @param [Hash] mapping def initialize(mapping) @mapping = mapping end # @return [TsAssets::Models::Content] def generate ts_paths = mapping.map { |full_path, asset_meta_info| constify(asset_meta_info) } TsAssets::Models::Content.new(header: nil, body: ts_paths.join("\n")) end # @param [TsAssets::Models::AssetMetaInfo] meta_info # @return [String] def constify(meta_info) <<~TS /** #{meta_info.asset_path} */ const #{meta_info.normalised_path} = "/assets/#{meta_info.digest_path}"; TS end end end end
Version data entries
5 entries across 5 versions & 1 rubygems