| OLD | NEW |
| 1 library pub.utils; | 1 library pub.utils; |
| 2 import 'dart:async'; | 2 import 'dart:async'; |
| 3 import "dart:convert"; | 3 import "dart:convert"; |
| 4 import 'dart:io'; | 4 import 'dart:io'; |
| 5 @MirrorsUsed(targets: const ['pub.io', 'test_pub']) | 5 @MirrorsUsed(targets: const ['pub.io', 'test_pub']) |
| 6 import 'dart:mirrors'; | 6 import 'dart:mirrors'; |
| 7 import "package:crypto/crypto.dart"; | 7 import "package:crypto/crypto.dart"; |
| 8 import 'package:path/path.dart' as path; | 8 import 'package:path/path.dart' as path; |
| 9 import "package:stack_trace/stack_trace.dart"; | 9 import "package:stack_trace/stack_trace.dart"; |
| 10 import 'exceptions.dart'; | 10 import 'exceptions.dart'; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 }); | 95 }); |
| 96 } | 96 } |
| 97 String padRight(String source, int length) { | 97 String padRight(String source, int length) { |
| 98 final result = new StringBuffer(); | 98 final result = new StringBuffer(); |
| 99 result.write(source); | 99 result.write(source); |
| 100 while (result.length < length) { | 100 while (result.length < length) { |
| 101 result.write(' '); | 101 result.write(' '); |
| 102 } | 102 } |
| 103 return result.toString(); | 103 return result.toString(); |
| 104 } | 104 } |
| 105 String namedSequence(String name, Iterable iter, [String plural]) { |
| 106 if (iter.length == 1) return "$name ${iter.first}"; |
| 107 var sequence = iter.take(iter.length - 1).join(", ") + " and ${iter.last}"; |
| 108 if (plural == null) plural = "${name}s"; |
| 109 return "$plural $sequence"; |
| 110 } |
| 105 String toSentence(Iterable iter) { | 111 String toSentence(Iterable iter) { |
| 106 if (iter.length == 1) return iter.first.toString(); | 112 if (iter.length == 1) return iter.first.toString(); |
| 107 return iter.take(iter.length - 1).join(", ") + " and ${iter.last}"; | 113 return iter.take(iter.length - 1).join(", ") + " and ${iter.last}"; |
| 108 } | 114 } |
| 109 String pluralize(String name, int number, {String plural}) { | 115 String pluralize(String name, int number, {String plural}) { |
| 110 if (number == 1) return name; | 116 if (number == 1) return name; |
| 111 if (plural != null) return plural; | 117 if (plural != null) return plural; |
| 112 return '${name}s'; | 118 return '${name}s'; |
| 113 } | 119 } |
| 114 String quoteRegExp(String string) { | 120 String quoteRegExp(String string) { |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 return buffer.toString(); | 534 return buffer.toString(); |
| 529 } | 535 } |
| 530 void fail(String message, [innerError, StackTrace innerTrace]) { | 536 void fail(String message, [innerError, StackTrace innerTrace]) { |
| 531 if (innerError != null) { | 537 if (innerError != null) { |
| 532 throw new WrappedException(message, innerError, innerTrace); | 538 throw new WrappedException(message, innerError, innerTrace); |
| 533 } else { | 539 } else { |
| 534 throw new ApplicationException(message); | 540 throw new ApplicationException(message); |
| 535 } | 541 } |
| 536 } | 542 } |
| 537 void dataError(String message) => throw new DataException(message); | 543 void dataError(String message) => throw new DataException(message); |
| OLD | NEW |