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

Side by Side Diff: pkg/barback/example/lazy_transformer/lib/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 import 'package:barback/barback.dart';
6
7 import 'dart:async';
8
9 class CodedMessageConverter extends Transformer
10 implements LazyTransformer {
11
12 // A constructor named "asPlugin" is required. It can be empty, but
13 // it must be present.
14 CodedMessageConverter.asPlugin();
15
16 Future<bool> isPrimary(AssetId id) {
17 return new Future.value(id.extension == '.txt');
18 }
19
20 Future declareOutputs(DeclaringTransform transform) {
21 return new Future.value(transform.primaryId.changeExtension('.shhhhh'));
22 }
23
24 Future apply(Transform transform) {
25 return transform.primaryInput.readAsString().then((content) {
26
27 // The output file is created with the '.shhhhh' extension.
28 var id = transform.primaryInput.id.changeExtension('.shhhhh');
29
30 StringBuffer newContent = new StringBuffer();
31 for (int i = 0; i < content.length; i++ ) {
32 newContent.write(rot13(content[i]));
33 }
34 transform.addOutput(new Asset.fromString(id, newContent.toString()));
35 });
36 }
37
38 rot13(var ch) {
39 var c = ch.codeUnitAt(0);
40 if (c >= 'a'.codeUnitAt(0) && c <= 'm'.codeUnitAt(0)) c += 13;
41 else if (c >= 'A'.codeUnitAt(0) && c <= 'M'.codeUnitAt(0)) c += 13;
42 else if (c >= 'n'.codeUnitAt(0) && c <= 'z'.codeUnitAt(0)) c -= 13;
43 else if (c >= 'N'.codeUnitAt(0) && c <= 'Z'.codeUnitAt(0)) c -= 13;
44 return new String.fromCharCode(c);
45 }
46 }
OLDNEW
« no previous file with comments | « pkg/barback/example/lazy_transformer/lib/message.txt ('k') | pkg/barback/example/lazy_transformer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698