OLD | NEW |
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.transformer.transformer; | 5 library barback.transformer.transformer; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import '../asset/asset_id.dart'; | 9 import '../asset/asset_id.dart'; |
10 import '../utils.dart'; | 10 import '../utils.dart'; |
(...skipping 15 matching lines...) Expand all Loading... |
26 /// Each extension must begin with a leading `.`. | 26 /// Each extension must begin with a leading `.`. |
27 /// | 27 /// |
28 /// If you don't override [isPrimary] yourself, it defaults to allowing any | 28 /// If you don't override [isPrimary] yourself, it defaults to allowing any |
29 /// asset whose extension matches one of the ones returned by this. If you | 29 /// asset whose extension matches one of the ones returned by this. If you |
30 /// don't override [isPrimary] *or* this, it allows all files. | 30 /// don't override [isPrimary] *or* this, it allows all files. |
31 String get allowedExtensions => null; | 31 String get allowedExtensions => null; |
32 | 32 |
33 Transformer() { | 33 Transformer() { |
34 if (allowedExtensions == null) return; | 34 if (allowedExtensions == null) return; |
35 | 35 |
36 var invalidExtensions = allowedExtensions.split(" ") | 36 var invalidExtensions = allowedExtensions |
| 37 .split(" ") |
37 .where((extension) => !extension.startsWith(".")) | 38 .where((extension) => !extension.startsWith(".")) |
38 .map((extension) => '"$extension"'); | 39 .map((extension) => '"$extension"'); |
39 if (invalidExtensions.isEmpty) return; | 40 if (invalidExtensions.isEmpty) return; |
40 | 41 |
41 throw new FormatException('Each extension in $this.allowedExtensions ' | 42 throw new FormatException('Each extension in $this.allowedExtensions ' |
42 'must begin with a ".", but ${toSentence(invalidExtensions)} ' | 43 'must begin with a ".", but ${toSentence(invalidExtensions)} ' |
43 '${pluralize("doesn't", invalidExtensions.length, plural: "don't")}.'); | 44 '${pluralize("doesn't", invalidExtensions.length, plural: "don't")}.'); |
44 } | 45 } |
45 | 46 |
46 /// Returns `true` if [id] can be a primary input for this transformer. | 47 /// Returns `true` if [id] can be a primary input for this transformer. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 /// In other words, a Transformer's job is to find all inputs for a | 85 /// In other words, a Transformer's job is to find all inputs for a |
85 /// transform, starting at the primary input, then generate all output assets | 86 /// transform, starting at the primary input, then generate all output assets |
86 /// and yield them back to the transform. | 87 /// and yield them back to the transform. |
87 /// | 88 /// |
88 /// If this does asynchronous work, it should return a [Future] that completes | 89 /// If this does asynchronous work, it should return a [Future] that completes |
89 /// once it's finished. | 90 /// once it's finished. |
90 apply(Transform transform); | 91 apply(Transform transform); |
91 | 92 |
92 String toString() => runtimeType.toString().replaceAll("Transformer", ""); | 93 String toString() => runtimeType.toString().replaceAll("Transformer", ""); |
93 } | 94 } |
OLD | NEW |