Index: pkg/barback/lib/src/base_transform.dart |
diff --git a/pkg/barback/lib/src/transform.dart b/pkg/barback/lib/src/base_transform.dart |
similarity index 62% |
copy from pkg/barback/lib/src/transform.dart |
copy to pkg/barback/lib/src/base_transform.dart |
index 7f0d217b072f1fd34f03ca87fc5d6b08f86af3ea..27dc12a3a1c1bf33a0c388eff562956705e98752 100644 |
--- a/pkg/barback/lib/src/transform.dart |
+++ b/pkg/barback/lib/src/base_transform.dart |
@@ -1,47 +1,28 @@ |
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-library barback.transform; |
+library barback.base_transform; |
import 'dart:async'; |
import 'dart:convert'; |
-import 'package:source_maps/span.dart'; |
- |
import 'asset.dart'; |
import 'asset_id.dart'; |
import 'asset_node.dart'; |
-import 'asset_set.dart'; |
import 'errors.dart'; |
-import 'log.dart'; |
import 'transform_logger.dart'; |
import 'transform_node.dart'; |
import 'utils.dart'; |
-typedef void LogFunction(AssetId asset, LogLevel level, String message, |
- Span span); |
- |
-/// Creates a [Transform] by forwarding to the private constructor. |
-/// |
-/// Lets [TransformNode] create [Transforms] without giving a [Transform] |
-/// itself a public constructor, which would be visible to external users. |
-/// Unlike the [Transform] class, this function is not exported by barback.dart. |
-Transform createTransform(TransformNode node, AssetSet outputs, |
- LogFunction logFunction) => |
- new Transform._(node, outputs, logFunction); |
- |
-/// While a [Transformer] represents a *kind* of transformation, this defines |
-/// one specific usage of it on a set of files. |
+/// The base class for the ephemeral transform objects that are passed to |
+/// transformers. |
/// |
-/// This ephemeral object exists only during an actual transform application to |
-/// facilitate communication between the [Transformer] and the code hosting |
-/// the transformation. It lets the [Transformer] access inputs and generate |
-/// outputs. |
-class Transform { |
+/// This class provides the transformers with inputs, but its up to the |
+/// subclasses to provide a means of emitting outputs. |
+abstract class BaseTransform { |
final TransformNode _node; |
final TransformLogger _logger; |
- final AssetSet _outputs; |
/// A logger so that the [Transformer] can report build details. |
TransformLogger get logger => _logger; |
@@ -69,7 +50,7 @@ class Transform { |
return _node.primary.asset; |
} |
- Transform._(this._node, this._outputs, LogFunction logFunction) |
+ BaseTransform(this._node, LogFunction logFunction) |
: _logger = new TransformLogger(logFunction); |
/// Gets the asset for an input [id]. |
@@ -97,13 +78,4 @@ class Transform { |
/// If the asset was created from a [String], this returns its UTF-8 encoding. |
Stream<List<int>> readInput(AssetId id) => |
futureStream(getInput(id).then((input) => input.read())); |
- |
- /// Stores [output] as the output created by this transformation. |
- /// |
- /// A transformation can output as many assets as it wants. |
- void addOutput(Asset output) { |
- // TODO(rnystrom): This should immediately throw if an output with that ID |
- // has already been created by this transformer. |
- _outputs.add(output); |
- } |
} |