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

Unified Diff: packages/barback/example/simple_transformer/lib/transformer.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 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
Index: packages/barback/example/simple_transformer/lib/transformer.dart
diff --git a/packages/barback/example/simple_transformer/lib/transformer.dart b/packages/barback/example/simple_transformer/lib/transformer.dart
new file mode 100644
index 0000000000000000000000000000000000000000..974a157241d662c90847c4e565faf41135158416
--- /dev/null
+++ b/packages/barback/example/simple_transformer/lib/transformer.dart
@@ -0,0 +1,25 @@
+// Copyright (c) 2012, 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.
+
+import 'package:barback/barback.dart';
+
+import 'dart:async';
+
+class InsertCopyright extends Transformer {
+ String copyright = "Copyright (c) 2014, the Example project authors.\n";
+
+ // A constructor named "asPlugin" is required. It can be empty, but
+ // it must be present. It is how pub determines that you want this
+ // class to be publicly available as a loadable transformer plugin.
+ InsertCopyright.asPlugin();
+
+ Future<bool> isPrimary(AssetId id) async => id.extension == '.txt';
+
+ Future apply(Transform transform) async {
+ var content = await transform.primaryInput.readAsString();
+ var id = transform.primaryInput.id;
+ var newContent = copyright + content;
+ transform.addOutput(new Asset.fromString(id, newContent));
+ }
+}
« no previous file with comments | « packages/barback/example/simple_transformer/lib/test.txt ('k') | packages/barback/example/simple_transformer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698