class CabezaDeTermo::AssetsPublisher::OneFilePerAssetBuilder

Public Instance Methods

add_timestamps?() click to toggle source

Answer if we must append a timestamp to the relative assets or not

# File lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb, line 54
def add_timestamps?()
        configuration.add_timestamps_to_published_assets?
end
asset() click to toggle source

Answer the current asset

# File lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb, line 19
def asset()
        @asset
end
asset_to_compile_to() click to toggle source

Answer the asset that will hold the compiled assets.

# File lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb, line 35
def asset_to_compile_to()
        return asset if asset.location.is_absolute?

        asset_to_publish
                .set_uri_parameters(timestamp_string)
end
assets_to_compile() click to toggle source

Answer the asset to compile. If the asset has an absolute location we won’t compile it

# File lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb, line 25
def assets_to_compile()
        if asset.location.is_absolute?
                asset.validate_real_path
                return [] 
        end

        [asset]
end
compiled_filename() click to toggle source
# File lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb, line 42
def compiled_filename
        return asset.uri if ['.css', '.js'].include?(asset.uri.extname)
        Pathname.new(remove_last_extension_from_uri)
end
jobs_for(assets) click to toggle source

Answer a collection of CompilationJob to send to a Compiler.

# File lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb, line 8
def jobs_for(assets)
        assets.collect { |asset| new_compilation_job_for asset }
end
new_compilation_job_for(asset) click to toggle source

Answer a new CompilationJob for a single asset to send to a Compiler

# File lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb, line 13
def new_compilation_job_for(asset)
        @asset = asset
        CompilationJob.new(assets: assets_to_compile, destination: asset_to_compile_to)
end
remove_last_extension_from_uri() click to toggle source
# File lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb, line 47
def remove_last_extension_from_uri
        asset.uri.to_s.split('.')[0..-2].join('.')
end
timestamp_string() click to toggle source

Answer the timestamp string to add to this asset.

# File lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb, line 59
def timestamp_string()
        return nil unless add_timestamps?

        Time.now.to_s
end