| 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 'package:barback/barback.dart'; | |
| 8 | |
| 9 import 'mock.dart'; | |
| 10 | |
| 11 /// A transformer that declares some outputs and emits others. | |
| 12 class DeclareAssetsTransformer extends MockTransformer | |
| 13 implements DeclaringTransformer { | |
| 14 /// The assets that the transformer declares that it will emit. | |
| 15 final List<AssetId> declared; | |
| 16 | |
| 17 /// The assets that the transformer actually emits. | |
| 18 /// | |
| 19 /// These assets' contents will be identical to their ids. | |
| 20 final List<AssetId> emitted; | |
| 21 | |
| 22 /// If this is non-`null`, assets are only declared for this input. | |
| 23 final AssetId input; | |
| 24 | |
| 25 DeclareAssetsTransformer(Iterable<String> declared, {Iterable<String> emitted, | |
| 26 String input}) | |
| 27 : this.declared = declared.map((id) => new AssetId.parse(id)).toList(), | |
| 28 this.emitted = (emitted == null ? declared : emitted) | |
| 29 .map((id) => new AssetId.parse(id)).toList(), | |
| 30 this.input = input == null ? null : new AssetId.parse(input); | |
| 31 | |
| 32 bool doIsPrimary(AssetId id) => input == null || id == input; | |
| 33 | |
| 34 void doApply(Transform transform) { | |
| 35 for (var id in emitted) { | |
| 36 transform.addOutput(new Asset.fromString(id, id.toString())); | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 void declareOutputs(DeclaringTransform transform) { | |
| 41 declared.forEach(transform.declareOutput); | |
| 42 } | |
| 43 } | |
| OLD | NEW |