| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2014, 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.sync_rewrite; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 | |
| 9 import 'package:barback/barback.dart'; | |
| 10 | |
| 11 /// Like [DeclaringRewriteTransformer], but with no methods returning Futures. | |
| 12 class SyncRewriteTransformer extends Transformer | |
| 13 implements DeclaringTransformer { | |
| 14 final String from; | |
| 15 final String to; | |
| 16 | |
| 17 SyncRewriteTransformer(this.from, this.to); | |
| 18 | |
| 19 bool isPrimary(AssetId id) => id.extension == ".$from"; | |
| 20 | |
| 21 void apply(Transform transform) { | |
| 22 for (var extension in to.split(" ")) { | |
| 23 var id = transform.primaryInput.id.changeExtension(".$extension"); | |
| 24 transform.addOutput(new Asset.fromString(id, "new.$extension")); | |
| 25 } | |
| 26 } | |
| 27 | |
| 28 void declareOutputs(DeclaringTransform transform) { | |
| 29 for (var extension in to.split(" ")) { | |
| 30 var id = transform.primaryId.changeExtension(".$extension"); | |
| 31 transform.declareOutput(id); | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 String toString() => "$from->$to"; | |
| 36 } | |
| OLD | NEW |