All Downloads are FREE. Search and download functionalities are using the official Maven repository.

asset.pipeline.AssetPipelineConfigHolder.groovy Maven / Gradle / Ivy

Go to download

JVM Asset Pipeline library for serving static web assets, bundling, minifying, and extensibility for transpiling.

There is a newer version: 5.0.1
Show newest version
package asset.pipeline

import asset.pipeline.fs.AssetResolver

/**
 * Holder for Asset Pipeline's configuration
 * Also Provides Helper methods for loading in config from properties
 * @author David Estes
 */
class AssetPipelineConfigHolder {
	public static Collection resolvers = []
	public static Properties manifest
	public static Map config = [:]

    private static Integer configHashCode
    private static Integer resolverHashCode
    private static String digestString

	public static registerResolver(AssetResolver resolver) {
		resolvers << resolver
	}

	public static Properties getManifest() {
		return this.manifest
	}

	public static void setManifest(Properties manifest) {
		this.manifest = manifest
	}

	public static Map getConfig() {
		return this.config
	}

	public static void setConfig(Map config) {
		this.config = config;
	}

	public static Collection getResolvers() {
		return this.resolvers;
	}

	public static void setResolvers(Collection resolvers) {
		this.resolvers = resolvers
	}

    public static String getDigestString() {
        //check if the maps or arrays have changed to reset the digest
        if(resolvers?.hashCode() != resolverHashCode || config?.hashCode() != configHashCode) {
            digestString = AssetHelper.getByteDigest([config: config?.sort(),resolvers: resolvers?.collect{AssetResolver resolver -> resolver.name}?.sort()].sort().toString().bytes)
            resolverHashCode = resolvers?.hashCode()
            configHashCode = config?.hashCode()
        }
        return digestString
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy