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

Side by Side Diff: pkg/barback/lib/src/transformer/aggregate_transformer.dart

Issue 808713003: Remove barback from the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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
(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.transformer.aggregate_transformer;
6
7 import '../asset/asset_id.dart';
8 import 'aggregate_transform.dart';
9
10 /// An alternate interface for transformers that want to perform aggregate
11 /// transformations on multiple inputs without any individual one of them being
12 /// considered "primary".
13 ///
14 /// This is useful for transformers like image spriting, where all the images in
15 /// a directory need to be combined into a single image. A normal [Transformer]
16 /// can't do this gracefully since when it's running on a single image, it has
17 /// no way of knowing what other images exist to request as secondary inputs.
18 ///
19 /// Aggregate transformers work by classifying assets into different groups
20 /// based on their ids in [classifyPrimary]. Then [apply] is run once for each
21 /// group. For example, a spriting transformer might put each image asset into a
22 /// group identified by its directory name. All images in a given directory will
23 /// end up in the same group, and they'll all be passed to one [apply] call.
24 ///
25 /// If possible, aggregate transformers should implement
26 /// [DeclaringAggregateTransformer] as well to help barback optimize the package
27 /// graph.
28 abstract class AggregateTransformer {
29 /// Classifies an asset id by returning a key identifying which group the
30 /// asset should be placed in.
31 ///
32 /// All assets for which [classifyPrimary] returns the same key are passed
33 /// together to the same [apply] call.
34 ///
35 /// This may return [Future<String>] or, if it's entirely synchronous,
36 /// [String]. Any string can be used to classify an asset. If possible,
37 /// though, this should return a path-like string to aid in logging.
38 ///
39 /// A return value of `null` indicates that the transformer is not interested
40 /// in an asset. Assets with a key of `null` will not be passed to any [apply]
41 /// call; this is equivalent to [Transformer.isPrimary] returning `false`.
42 classifyPrimary(AssetId id);
43
44 /// Runs this transformer on a group of primary inputs specified by
45 /// [transform].
46 ///
47 /// If this does asynchronous work, it should return a [Future] that completes
48 /// once it's finished.
49 ///
50 /// This may complete before [AggregateTransform.primarInputs] is closed. For
51 /// example, it may know that each key will only have two inputs associated
52 /// with it, and so use `transform.primaryInputs.take(2)` to access only those
53 /// inputs.
54 apply(AggregateTransform transform);
55
56 String toString() => runtimeType.toString().replaceAll("Transformer", "");
57 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/transformer/aggregate_transform.dart ('k') | pkg/barback/lib/src/transformer/barback_settings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698