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

Side by Side Diff: pkg/barback/lib/src/barback_settings.dart

Issue 52853004: Pass in "mode" to transformer plugins. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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) 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_settings;
6
7 /// A generic settings object for providing configuration details to
8 /// [Transformer]s.
9 ///
10 /// Barback does not specify *how* this is provided to transformers. It is up
11 /// to a host application to handle this. (For example, pub passes this to the
12 /// transformer's constructor.)
13 class BarbackSettings {
14 /// An open-ended map of configuration properties specific to this
15 /// transformer.
16 ///
17 /// Aside from requiring to be serializable across isolates, Barback places
nweiz 2013/10/31 00:24:41 "requiring to be" -> "requiring that this be" or "
Bob Nystrom 2013/10/31 01:51:19 Reworded.
18 /// no restrictions on what this should contain.
19 final Map transformer;
nweiz 2013/10/31 00:24:41 I agree with Siggi that this reads awkwardly. What
Bob Nystrom 2013/10/31 01:51:19 I think that's worse. I can do "transformerConfigu
nweiz 2013/10/31 18:47:56 "fromUser"? "fromPubspec"? "pubspec"? "transforme
Bob Nystrom 2013/10/31 20:04:08 Changed to "configuration".
20
21 /// The overall development mode that user is running Barback in. This will
nweiz 2013/10/31 00:24:41 Paragraph break. "development mode" is confusing
Bob Nystrom 2013/10/31 01:51:19 Removed "overall" too.
22 /// be the same for all transformers in a running instance of Barback.
23 final BarbackMode mode;
24
25 BarbackSettings(this.transformer, this.mode);
26 }
27
28 /// Enum-like class for specifying a mode that transformers may be run in.
29 ///
30 /// Note that this is not a *closed* set of enum values. Host applications may
31 /// define their own values for this, so a transformer relying on it should
32 /// ensure that it behaves sanely with unknown values.
33 class BarbackMode {
34 /// The normal mode used during development.
35 static const DEBUG = const BarbackMode("debug");
36
37 /// The normal mode used to build an application for deploying to production.
38 static const RELEASE = const BarbackMode("release");
39
40 /// The name of the mode.
41 ///
42 /// By convention, this is a lowercase string.
43 final String name;
44
45 const BarbackMode(this.name);
46
47 /// Create a mode named [name].
48 factory BarbackMode.fromString(String name) {
nweiz 2013/10/31 00:24:41 It's confusing for this to be a different construc
Bob Nystrom 2013/10/31 01:51:19 Done. Not sure what I was thinking here.
49 // Use canonical instances of known names.
50 switch (name) {
51 case "debug": return BarbackMode.DEBUG;
52 case "release": return BarbackMode.RELEASE;
53 default:
54 return new BarbackMode(name);
55 }
56 }
57
58 String toString() => name;
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698