class TsAssets::ApplicationGenerator
Attributes
es_module_interop[R]
@return [Boolean]
mapping[R]
@return [Hash] mapping
Public Class Methods
new(include:, es_module_interop: false)
click to toggle source
@param [String] include
# File lib/ts_assets/application_generator.rb, line 14 def initialize(include:, es_module_interop: false) @mapping = build_mapping(include) @es_module_interop = es_module_interop environment.append_path(include) end
Public Instance Methods
build_mapping(include_path)
click to toggle source
@param [String] include_path @return [Hash]
# File lib/ts_assets/application_generator.rb, line 50 def build_mapping(include_path) mapping = {} Dir.glob("#{include_path}/**/*.{png,svg,jpg,jpeg,gif}").sort.each do |full_path| mapping[full_path] = TsAssets::Models::AssetMetaInfo.new( full_path: full_path, include_path: include_path, environment: environment, ) end mapping end
const_content()
click to toggle source
@return [TsAssets::Models::Content]
# File lib/ts_assets/application_generator.rb, line 39 def const_content @const_content ||= TsAssets::Generators::ConstGenerator.new(mapping).generate end
environment()
click to toggle source
@return [Sprockets::Environment]
# File lib/ts_assets/application_generator.rb, line 22 def environment @environment ||= Sprockets::Environment.new end
generate()
click to toggle source
@return [String]
# File lib/ts_assets/application_generator.rb, line 27 def generate [ # header react_content.header, # body const_content.body, react_content.body, ].join("\n") end
react_content()
click to toggle source
@return [TsAssets::Models::Content]
# File lib/ts_assets/application_generator.rb, line 44 def react_content @react_content ||= TsAssets::Generators::ReactGenerator.new(mapping, es_module_interop: es_module_interop).generate end