OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library barback.test.transformer.declare_asset; |
| 6 |
| 7 import 'dart:async'; |
| 8 |
| 9 import 'package:barback/barback.dart'; |
| 10 import 'package:barback/src/utils.dart'; |
| 11 |
| 12 import 'mock.dart'; |
| 13 |
| 14 /// A transformer that declares some outputs and emits others. |
| 15 class DeclareAssetsTransformer extends MockTransformer |
| 16 implements DeclaringTransformer { |
| 17 /// The assets that the transformer declares that it will emit. |
| 18 final List<AssetId> declared; |
| 19 |
| 20 /// The assets that the transformer actually emits. |
| 21 /// |
| 22 /// These assets' contents will be identical to their ids. |
| 23 final List<AssetId> emitted; |
| 24 |
| 25 DeclareAssetsTransformer(Iterable<String> declared, Iterable<String> emitted) |
| 26 : this.declared = declared.map((id) => new AssetId.parse(id)).toList(), |
| 27 this.emitted = emitted.map((id) => new AssetId.parse(id)).toList(); |
| 28 |
| 29 Future<bool> doIsPrimary(AssetId id) => new Future.value(true); |
| 30 |
| 31 Future doApply(Transform transform) { |
| 32 return newFuture(() { |
| 33 for (var id in emitted) { |
| 34 transform.addOutput(new Asset.fromString(id, id.toString())); |
| 35 } |
| 36 }); |
| 37 } |
| 38 |
| 39 Future declareOutputs(DeclaringTransform transform) { |
| 40 return newFuture(() { |
| 41 declared.forEach(transform.declareOutput); |
| 42 }); |
| 43 } |
| 44 } |
OLD | NEW |