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

Side by Side Diff: pkg/barback/lib/src/barback.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
« no previous file with comments | « pkg/barback/lib/src/asset/internal_asset.dart ('k') | pkg/barback/lib/src/build_result.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library barback.barback;
6
7 import 'dart:async';
8
9 import 'asset/asset.dart';
10 import 'asset/asset_id.dart';
11 import 'asset/asset_set.dart';
12 import 'log.dart';
13 import 'build_result.dart';
14 import 'errors.dart';
15 import 'graph/package_graph.dart';
16 import 'package_provider.dart';
17 import 'transformer/transformer.dart';
18
19 /// A general-purpose asynchronous build dependency graph manager.
20 ///
21 /// It consumes source assets (including Dart files) in a set of packages,
22 /// runs transformations on them, and then tracks which sources have been
23 /// modified and which transformations need to be re-run.
24 ///
25 /// To do this, you give barback a [PackageProvider] which can yield a set of
26 /// [Transformer]s and raw source [Asset]s. Then you tell it which input files
27 /// have been added or modified by calling [updateSources]. Barback will
28 /// automatically wire up the appropriate transformers to those inputs and
29 /// start running them asynchronously. If a transformer produces outputs that
30 /// can be consumed by other transformers, they will automatically be pipelined
31 /// correctly.
32 ///
33 /// You can then request assets (either source or generated) by calling
34 /// [getAssetById]. This will wait for any necessary transformations and then
35 /// return the asset.
36 ///
37 /// When source files have been modified or removed, tell barback by calling
38 /// [updateSources] and [removeSources] as appropriate. Barback will
39 /// automatically track which transformations are affected by those changes and
40 /// re-run them as needed.
41 ///
42 /// Barback tries to be resilient to errors since assets are often in an
43 /// in-progress state. When errors occur, they will be captured and emitted on
44 /// the [errors] stream.
45 class Barback {
46 /// The graph managed by this instance.
47 final PackageGraph _graph;
48
49 /// A stream that emits a [BuildResult] each time the build is completed,
50 /// whether or not it succeeded.
51 ///
52 /// This will emit a result only once every package's [AssetCascade] has
53 /// finished building.
54 ///
55 /// If an unexpected error in barback itself occurs, it will be emitted
56 /// through this stream's error channel.
57 Stream<BuildResult> get results => _graph.results;
58
59 /// A stream that emits any errors from the graph or the transformers.
60 ///
61 /// This emits errors as they're detected. If an error occurs in one part of
62 /// the graph, unrelated parts will continue building.
63 ///
64 /// This will not emit programming errors from barback itself. Those will be
65 /// emitted through the [results] stream's error channel.
66 Stream get errors => _graph.errors;
67
68 /// The stream of [LogEntry] objects used to report transformer log entries.
69 ///
70 /// If this stream has listeners, then log entries will go to that.
71 /// Otherwise, a default logger will display them.
72 Stream<LogEntry> get log => _graph.log;
73
74 Barback(PackageProvider provider)
75 : _graph = new PackageGraph(provider);
76
77 /// Gets the asset identified by [id].
78 ///
79 /// If [id] is for a generated or transformed asset, this will wait until
80 /// it has been created and return it. If the asset cannot be found, throws
81 /// [AssetNotFoundException].
82 Future<Asset> getAssetById(AssetId id) {
83 return _graph.getAssetNode(id).then((node) {
84 if (node == null) throw new AssetNotFoundException(id);
85 return node.asset;
86 });
87 }
88
89 /// Adds [sources] to the graph's known set of source assets.
90 ///
91 /// Begins applying any transforms that can consume any of the sources. If a
92 /// given source is already known, it is considered modified and all
93 /// transforms that use it will be re-applied.
94 void updateSources(Iterable<AssetId> sources) =>
95 _graph.updateSources(sources);
96
97 /// Removes [removed] from the graph's known set of source assets.
98 void removeSources(Iterable<AssetId> removed) =>
99 _graph.removeSources(removed);
100
101 /// Gets all output assets.
102 ///
103 /// If a build is currently in progress, waits until it completes. The
104 /// returned future will complete with a [BarbackException] if the build is
105 /// not successful.
106 Future<AssetSet> getAllAssets() => _graph.getAllAssets();
107
108 /// Sets the transformer phases for [package]'s assets to [transformers].
109 ///
110 /// To the extent that [transformers] is similar to the previous transformer
111 /// phases for [package], the existing asset graph will be preserved.
112 ///
113 /// Elements of the inner iterable of [transformers] must be [Transformer]s,
114 /// [TransformerGroup]s, or [AggregateTransformer]s.
115 void updateTransformers(String package, Iterable<Iterable> transformers) =>
116 _graph.updateTransformers(package, transformers);
117 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/asset/internal_asset.dart ('k') | pkg/barback/lib/src/build_result.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698