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

Unified 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: "transformer" -> "configuration". Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/barback/lib/barback.dart ('k') | pkg/barback/test/barback_mode_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/barback_settings.dart
diff --git a/pkg/barback/lib/src/barback_settings.dart b/pkg/barback/lib/src/barback_settings.dart
new file mode 100644
index 0000000000000000000000000000000000000000..80c276e3f2b7170f4a755db8da2f348fe8e6b67e
--- /dev/null
+++ b/pkg/barback/lib/src/barback_settings.dart
@@ -0,0 +1,61 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library barback.barback_settings;
+
+/// A generic settings object for providing configuration details to
+/// [Transformer]s.
+///
+/// Barback does not specify *how* this is provided to transformers. It is up
+/// to a host application to handle this. (For example, pub passes this to the
+/// transformer's constructor.)
+class BarbackSettings {
+ /// An open-ended map of configuration properties specific to this
+ /// transformer.
+ ///
+ /// The contents of the map should be serializable across isolates, but
+ /// otherwise can contain whatever you want.
+ final Map configuration;
+
+ /// The mode that user is running Barback in.
+ ///
+ /// This will be the same for all transformers in a running instance of
+ /// Barback.
+ final BarbackMode mode;
+
+ BarbackSettings(this.configuration, this.mode);
+}
+
+/// Enum-like class for specifying a mode that transformers may be run in.
+///
+/// Note that this is not a *closed* set of enum values. Host applications may
+/// define their own values for this, so a transformer relying on it should
+/// ensure that it behaves sanely with unknown values.
+class BarbackMode {
+ /// The normal mode used during development.
+ static const DEBUG = const BarbackMode._("debug");
+
+ /// The normal mode used to build an application for deploying to production.
+ static const RELEASE = const BarbackMode._("release");
+
+ /// The name of the mode.
+ ///
+ /// By convention, this is a lowercase string.
+ final String name;
+
+ /// Create a mode named [name].
+ factory BarbackMode(String name) {
+ // Use canonical instances of known names.
+ switch (name) {
+ case "debug": return BarbackMode.DEBUG;
+ case "release": return BarbackMode.RELEASE;
+ default:
+ return new BarbackMode._(name);
+ }
+ }
+
+ const BarbackMode._(this.name);
+
+ String toString() => name;
+}
« no previous file with comments | « pkg/barback/lib/barback.dart ('k') | pkg/barback/test/barback_mode_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698