Home Manual Reference Source Test
import ScriptTransformer from 'atscm/src/transform/ScriptTransformer.js'
public class | source

ScriptTransformer

Extends:

TransformerPartialTransformerSplittingTransformerXMLTransformer → ScriptTransformer

A transformer that splits atvise scripts and quick dynamics into a code file and a .json file containing parameters and metadata.

Test:

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

Returns true for all files containing script code or quick dynamics.

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

Applies the transformer to the given stream.

public

inspect(depth: Number, options: Object): string

Prints the transformer.

public

transformFromDB(chunk: Object, enc: string, callback: function(err: ?Error, obj: ?Object))

Must be overridden by all subclasses: Transforms the given chunk when using TransformDirection.FromDB.

public

transformFromFilesystem(chunk: Object, enc: string, callback: function(err: ?Error, obj: ?Object))

Must be overridden by all subclasses: Transforms the given chunk when using TransformDirection.FromFilesystem.

public

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

_transform(chunk: Object, enc: string, callback: function(err: ?Error, obj: ?Object))

Calls Transformer#transformFromDB or Transformer#transformFromFilesystem based on the transformer's direction.

From class PartialTransformer
public

The filter stream used.

public

Applies a stream transformer to the given, already filtered stream.

public

Applies the transformer to the given stream.

public abstract

true if file should be transformed.

private

_transform(file: AtviseFile, enc: string, callback: function(err: ?Error, data: ?AtviseFile))

Transforms a file if PartialTransformer#shouldBeTransformed returns true.

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

_flush(callback: function(err: ?Error))

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

The builder to use with direction TransformDirection.FromDB.

private

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.

Override:

SplittingTransformer#createCombinedFile

Params:

NameTypeAttributeDescription
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.

Test:

public shouldBeTransformed(file: AtviseFile): boolean source

Returns true for all files containing script code or quick dynamics.

Override:

PartialTransformer#shouldBeTransformed

Params:

NameTypeAttributeDescription
file AtviseFile

The file to check.

Return:

boolean

true for all files containing script code or quick dynamics.

Test:

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#transformFromDB

Params:

NameTypeAttributeDescription
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.

Test: