ScriptTransformer
Extends:
A transformer that splits atvise scripts and quick dynamics into a code file and a .json file containing parameters and metadata.
Method Summary
Public Methods | ||
public |
createCombinedFile(files: Map<String, AtviseFile>, lastFile: AtviseFile, callback: function(err: ?Error, data: vinyl~File)) Creates a script from the collected files. |
|
public |
shouldBeTransformed(file: AtviseFile): boolean Returns |
|
public |
transformFromDB(file: AtviseFile, enc: string, callback: function(err: Error, file: AtviseFile)) Splits any read files containing scripts or quick dynamics into their JavaScript sources, alongside with a json file containing parameters and metadata. |
Inherited Summary
From class Transformer | ||
public static |
applyTransformers(stream: Stream, transformers: Transformer[], direction: TransformDirection): Transformer Creates a stream with all transformers passed, with the given direction. |
|
public get |
If reference config files should be handled by the transformer. |
|
public |
direction: TransformerDirection The transformer's direction |
|
private |
The options the transformer was created with. |
|
public |
applyToStream(stream: Stream, direction: TransformDirection): Stream Applies the transformer to the given stream. |
|
public |
Prints the transformer. |
|
public |
Must be overridden by all subclasses: Transforms the given chunk when using TransformDirection.FromDB. |
|
public |
Must be overridden by all subclasses: Transforms the given chunk when using TransformDirection.FromFilesystem. |
|
public |
withDirection(direction: TransformDirection): Transformer Returns the Transformer with the given direction. |
|
private |
_processError(err: Error, chunk: *, callback: function(err: ?Error), args: Array<*>) Decorates an error that occurred while running a transformer. |
|
private |
Calls Transformer#transformFromDB or Transformer#transformFromFilesystem based on the transformer's direction. |
From class PartialTransformer | ||
public |
The filter stream used. |
|
public |
applyToFilteredStream(stream: Stream, direction: TransformDirection): Stream Applies a stream transformer to the given, already filtered stream. |
|
public |
applyToStream(stream: Stream, direction: TransformDirection): Stream Applies the transformer to the given stream. |
|
public abstract |
shouldBeTransformed(file: AtviseFile)
|
|
private |
_transform(file: AtviseFile, enc: string, callback: function(err: ?Error, data: ?AtviseFile)) Transforms a file if PartialTransformer#shouldBeTransformed returns |
From class SplittingTransformer | ||
public static |
combineFiles(files: vinyl~File[], newExtension: string): vinyl~File Combines split files to a single one. |
|
public static |
splitFile(file: vinyl~File, newExtension: String): vinyl~File Splits a vinyl~File: The resulting is a clone of the input file, with a different path. |
|
private |
The cache used when collecting files to combine. |
|
public abstract |
createCombinedFile(files: Map<String, AtviseFile>, lastFile: AtviseFile, callback: function(err: ?Error, data: ?AtviseFile)) Creates a combined file from the cached split files. |
|
public |
transformFromFilesystem(file: AtviseFile, enc: string, callback: function(err: ?Error, data: ?AtviseFile)) Calls SplittingTransformer#createCombinedFile as soon as all dependencies are required files are cached. |
|
private |
If there are any missing files this method loads these files and calls {SplittingTransformer#createCombinedFile} with them. |
From class XMLTransformer | ||
public get |
Returns the XML builder to use based on the current Transformer#direction. |
|
private |
_fromDBBuilder: function(object: Object): string The builder to use with direction TransformDirection.FromDB. |
|
private |
_fromFilesystemBuilder: function(object: Object): string The builder to use with direction TransformDirection.FromFilesystem. |
|
public |
decodeContents(file: AtviseFile, callback: function(err: ?Error, result: ?Object)) Parses XML in a file's contents. |
|
public |
encodeContents(object: Object, callback: function(err: ?Error, result: ?String)) Builds an XML string from an object. |
Public Methods
public createCombinedFile(files: Map<String, AtviseFile>, lastFile: AtviseFile, callback: function(err: ?Error, data: vinyl~File)) source
Creates a script from the collected files.
Params:
Name | Type | Attribute | Description |
files | Map<String, AtviseFile> | The collected files, stored against their extension. |
|
lastFile | AtviseFile | The last file read. Used for error messages only. |
|
callback | function(err: ?Error, data: vinyl~File) | Called with the error that occured while creating the script or the resulting file. |
public shouldBeTransformed(file: AtviseFile): boolean source
Returns true
for all files containing script code or quick dynamics.
Params:
Name | Type | Attribute | Description |
file | AtviseFile | The file to check. |
public transformFromDB(file: AtviseFile, enc: string, callback: function(err: Error, file: AtviseFile)) source
Splits any read files containing scripts or quick dynamics into their JavaScript sources, alongside with a json file containing parameters and metadata.
Override:
Transformer#transformFromDBParams:
Name | Type | Attribute | Description |
file | AtviseFile | The script file to split. |
|
enc | string | The encoding used. |
|
callback | function(err: Error, file: AtviseFile) | Called with the error that occured while transforming the script, or the file passed through. |