Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Side by Side Diff: test/transformer/many_to_one.dart

Issue 1947773002: Fix all strong-mode warnings. (Closed) Base URL: git@github.com:dart-lang/barback@master
Patch Set: Code review changes Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/transformer/lazy_check_content_and_rename.dart ('k') | test/transformer/mock.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library barback.test.transformer.many_to_one; 5 library barback.test.transformer.many_to_one;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
10 10
11 import 'mock.dart'; 11 import 'mock.dart';
12 12
13 /// A transformer that uses the contents of a file to define the other inputs. 13 /// A transformer that uses the contents of a file to define the other inputs.
14 /// 14 ///
15 /// Outputs a file with the same name as the primary but with an "out" 15 /// Outputs a file with the same name as the primary but with an "out"
16 /// extension containing the concatenated contents of all non-primary inputs. 16 /// extension containing the concatenated contents of all non-primary inputs.
17 class ManyToOneTransformer extends MockTransformer { 17 class ManyToOneTransformer extends MockTransformer {
18 final String extension; 18 final String extension;
19 19
20 /// Creates a transformer that consumes assets with [extension]. 20 /// Creates a transformer that consumes assets with [extension].
21 /// 21 ///
22 /// That file contains a comma-separated list of paths and it will input 22 /// That file contains a comma-separated list of paths and it will input
23 /// files at each of those paths. 23 /// files at each of those paths.
24 ManyToOneTransformer(this.extension); 24 ManyToOneTransformer(this.extension);
25 25
26 bool doIsPrimary(AssetId id) => id.extension == ".$extension"; 26 bool doIsPrimary(AssetId id) => id.extension == ".$extension";
27 27
28 Future doApply(Transform transform) { 28 Future doApply(Transform transform) async {
29 return getPrimary(transform) 29 var primary = await getPrimary(transform);
30 .then((primary) => primary.readAsString()) 30 var contents = await primary.readAsString();
31 .then((contents) { 31
32 // Get all of the included inputs. 32 // Get all of the included inputs.
33 return Future.wait(contents.split(",").map((path) { 33 var outputs = await Future.wait(contents.split(",").map((path) {
34 var id; 34 var id;
35 if (path.contains("|")) { 35 if (path.contains("|")) {
36 id = new AssetId.parse(path); 36 id = new AssetId.parse(path);
37 } else { 37 } else {
38 id = new AssetId(transform.primaryInput.id.package, path); 38 id = new AssetId(transform.primaryInput.id.package, path);
39 } 39 }
40 return getInput(transform, id).then((input) => input.readAsString()); 40 return getInput(transform, id).then((input) => input.readAsString());
41 })); 41 }));
42 }).then((outputs) { 42
43 var id = transform.primaryInput.id.changeExtension(".out"); 43 var id = transform.primaryInput.id.changeExtension(".out");
44 transform.addOutput(new Asset.fromString(id, outputs.join())); 44 transform.addOutput(new Asset.fromString(id, outputs.join()));
45 });
46 } 45 }
47 46
48 String toString() => "many->1 $extension"; 47 String toString() => "many->1 $extension";
49 } 48 }
OLDNEW
« no previous file with comments | « test/transformer/lazy_check_content_and_rename.dart ('k') | test/transformer/mock.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698