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

Side by Side Diff: pkg/scheduled_test/lib/src/descriptor/entry.dart

Issue 12853005: Change the way Patterns work in scheduled_test/descriptor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 9 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 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 descriptor.entry;
6
7 import 'dart:async';
8
9 import '../utils.dart';
10 import 'utils.dart';
11
12 /// The base class for various declarative descriptions of filesystem entries.
13 /// All asynchronous operations on descriptors are [schedule]d unless otherwise
14 /// noted.
15 abstract class Entry {
16 /// The name of this entry. For most operations, this must be a [String];
17 /// however, if the entry will only be used for validation, it may be a
18 /// non-[String] [Pattern]. In this case, there must be only one entry
19 /// matching it in the physical filesystem for validation to succeed.
20 final Pattern name;
21
22 Entry(this.name);
23
24 /// Schedules the creation of the described entry within the [parent]
25 /// directory. Returns a [Future] that completes after the creation is done.
26 ///
27 /// [parent] defaults to [defaultRoot].
28 Future create([String parent]);
29
30 /// Schedules the validation of the described entry. This validates that the
31 /// physical file system under [parent] contains an entry that matches the one
32 /// described by [this]. Returns a [Future] that completes to `null` if the
33 /// entry is valid, or throws an error if it failed.
34 ///
35 /// [parent] defaults to [defaultRoot].
36 Future validate([String parent]);
37
38 /// Treats [this] as an in-memory filesystem and returns a stream of the
39 /// contents of the child entry located at [path]. This only works if [this]
40 /// is a directory entry. This operation is not [schedule]d.
41 ///
42 /// This method uses POSIX paths regardless of the underlying operating
43 /// system.
44 ///
45 /// All errors in loading the file will be passed through the returned
46 /// [Stream].
47 Stream<List<int>> load(String pathToLoad) => errorStream("Can't load "
48 "'$pathToLoad' from within $nameDescription: not a directory.");
49
50 /// Returns the contents of [this] as a stream. This only works if [this] is a
51 /// file entry. This operation is not [schedule]d.
52 ///
53 /// All errors in loading the file will be passed through the returned
54 /// [Stream].
55 Stream<List<int>> read();
56
57 /// Asserts that the name of the descriptor is a [String] and returns it.
58 String get stringName {
59 if (name is String) return name;
60 throw 'Pattern $nameDescription must be a string.';
61 }
62
63 /// Returns a human-readable description of [name], for error reporting. For
64 /// string names, this will just be the name in quotes; for regular
65 /// expressions, it will use JavaScript-style `/.../` notation.
66 String get nameDescription => describePattern(name);
67
68 /// Returns a detailed tree-style description of [this].
69 String describe();
70 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart ('k') | pkg/scheduled_test/lib/src/descriptor/file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698