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

Side by Side Diff: pkg/barback/test/transformer/declare_assets.dart

Issue 299833003: Expose aggregate transformers in barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 6 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 | Annotate | Revision Log
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.declare_asset; 5 library barback.test.transformer.declare_asset;
6 6
7 import 'package:barback/barback.dart'; 7 import 'package:barback/barback.dart';
8 8
9 import 'mock.dart'; 9 import 'mock.dart';
10 10
11 /// A transformer that declares some outputs and emits others. 11 /// A transformer that declares some outputs and emits others.
12 class DeclareAssetsTransformer extends MockTransformer 12 class DeclareAssetsTransformer extends MockTransformer
13 implements DeclaringTransformer { 13 implements DeclaringTransformer {
14 /// The assets that the transformer declares that it will emit. 14 /// The assets that the transformer declares that it will emit.
15 final List<AssetId> declared; 15 final List<AssetId> declared;
16 16
17 /// The assets that the transformer actually emits. 17 /// The assets that the transformer actually emits.
18 /// 18 ///
19 /// These assets' contents will be identical to their ids. 19 /// These assets' contents will be identical to their ids.
20 final List<AssetId> emitted; 20 final List<AssetId> emitted;
21 21
22 DeclareAssetsTransformer(Iterable<String> declared, [Iterable<String> emitted] ) 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})
23 : this.declared = declared.map((id) => new AssetId.parse(id)).toList(), 27 : this.declared = declared.map((id) => new AssetId.parse(id)).toList(),
24 this.emitted = (emitted == null ? declared : emitted) 28 this.emitted = (emitted == null ? declared : emitted)
25 .map((id) => new AssetId.parse(id)).toList(); 29 .map((id) => new AssetId.parse(id)).toList(),
30 this.input = input == null ? null : new AssetId.parse(input);
26 31
27 bool doIsPrimary(AssetId id) => true; 32 bool doIsPrimary(AssetId id) => input == null || id == input;
28 33
29 void doApply(Transform transform) { 34 void doApply(Transform transform) {
30 for (var id in emitted) { 35 for (var id in emitted) {
31 transform.addOutput(new Asset.fromString(id, id.toString())); 36 transform.addOutput(new Asset.fromString(id, id.toString()));
32 } 37 }
33 } 38 }
34 39
35 void declareOutputs(DeclaringTransform transform) { 40 void declareOutputs(DeclaringTransform transform) {
36 declared.forEach(transform.declareOutput); 41 declared.forEach(transform.declareOutput);
37 } 42 }
38 } 43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698