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

Unified Diff: lib/src/utils.dart

Issue 1649663003: Add basic support for a configuration file. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 4 years, 11 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: lib/src/utils.dart
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 4b554ee53ecb93b01f83a3f231b7d42b29b43168..74675907fe92db84d07a21e0ee368e8f0c9616f3 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -34,6 +34,9 @@ final lineSplitter = UTF8.decoder.fuse(const LineSplitter());
/// [Object.toString] values contain.
final _exceptionPrefix = new RegExp(r'^([A-Z][a-zA-Z]*)?(Exception|Error): ');
+/// A regular expression matching a single vowel.
+final _vowel = new RegExp('[aeiou]');
+
/// Directories that are specific to OS X.
///
/// This is used to try to distinguish OS X and Linux in [currentOSGuess].
@@ -118,6 +121,10 @@ String pluralize(String name, int number, {String plural}) {
return '${name}s';
}
+/// Returns [noun] with an indefinite article ("a" or "an") added, based on
+/// whether its first letter is a vowel.
+String a(String noun) => noun.startsWith(_vowel) ? "an $noun" : "a $noun";
+
/// Wraps [text] so that it fits within [lineLength], which defaults to 100
/// characters.
///

Powered by Google App Engine
This is Rietveld 408576698