import PartialTransformer from 'atscm/src/lib/transform/PartialTransformer.js'PartialTransformer
Extends:
Direct Subclass:
Indirect Subclass:
A transformer that transforms only some of the files read.
Constructor Summary
| Public Constructor | ||
| public |
constructor(options: Object) Creates a new partial transformer with the specified options. |
|
Method Summary
| Public Methods | ||
| 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 Methods | ||
| private |
_transform(file: AtviseFile, enc: string, callback: function(err: ?Error, data: ?AtviseFile)) Transforms a file if PartialTransformer#shouldBeTransformed returns |
|
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. |
|
Public Constructors
public constructor(options: Object) source
Creates a new partial transformer with the specified options.
Override:
Transformer#constructorParams:
| Name | Type | Attribute | Description |
| options | Object | The options to use. See Transformer#constructor for available options. |
Public Members
Public Methods
public applyToFilteredStream(stream: Stream, direction: TransformDirection): Stream source
Applies a stream transformer to the given, already filtered stream. Override this method if you want to pipe streams directly. Returning a falsy value (false, null, undefined, ...) invokes Transformer#transformFromDB or Transformer#transformFromFilesystem instead.
Params:
| Name | Type | Attribute | Description |
| stream | Stream | The stream to apply the transformer to. |
|
| direction | TransformDirection | The direction to use. |
public applyToStream(stream: Stream, direction: TransformDirection): Stream source
Applies the transformer to the given stream. It does so by running the following steps:
- Pipe the PartialTransformer#filter stream
- If PartialTransformer#applyToFilteredStream is overrridden, apply it.
- Otherwise pipe Transformer#withDirection.
- Restore the filter stream.
Override:
Transformer#applyToStreamParams:
| Name | Type | Attribute | Description |
| stream | Stream | The stream to apply the transformer to. |
|
| direction | TransformDirection | The direction to use. |
public abstract shouldBeTransformed(file: AtviseFile) source
true if file should be transformed.
Params:
| Name | Type | Attribute | Description |
| file | AtviseFile | The file to transform or not. |
Private Methods
private _transform(file: AtviseFile, enc: string, callback: function(err: ?Error, data: ?AtviseFile)) source
Transforms a file if PartialTransformer#shouldBeTransformed returns true.
Override:
Transformer#_transformParams:
| Name | Type | Attribute | Description |
| file | AtviseFile | The file to transform. |
|
| enc | string | The encoding used. |
|
| callback | function(err: ?Error, data: ?AtviseFile) | Called with the error that occured while transforming or (optionally) the transformed file. |
