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

Unified Diff: sdk/lib/_internal/pub/lib/src/source/unknown.dart

Issue 243683002: Refactor Source. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise all the things. Created 6 years, 8 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
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/source/path.dart ('k') | sdk/lib/_internal/pub/lib/src/source_registry.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/source/unknown.dart
diff --git a/sdk/lib/_internal/pub/lib/src/source/unknown.dart b/sdk/lib/_internal/pub/lib/src/source/unknown.dart
new file mode 100644
index 0000000000000000000000000000000000000000..40cd11118ba359b811728598ba2cb5810b2579d5
--- /dev/null
+++ b/sdk/lib/_internal/pub/lib/src/source/unknown.dart
@@ -0,0 +1,47 @@
+// Copyright (c) 2014, 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.
+
+library pub.source.unknown;
+
+import 'dart:async';
+
+import '../package.dart';
+import '../pubspec.dart';
+import '../source.dart';
+
+/// A [Null Object] that represents a source not recognized by pub.
+///
+/// It provides some default behavior so that pub can work with sources it
+/// doesn't recognize.
+///
+/// [null object]: http://en.wikipedia.org/wiki/Null_Object_pattern
+class UnknownSource extends Source {
+ final String name;
+
+ UnknownSource(this.name);
+
+ /// Two unknown sources are the same if their names are the same.
+ bool operator==(other) =>
+ other is UnknownSource &&
+ other.name == name;
+
+ int get hashCode => name.hashCode;
+
+ Future<Pubspec> onDescribe(PackageId id) => throw new UnsupportedError(
+ "Cannot describe a package from unknown source '$name'.");
+
+ Future<bool> get(PackageId id, String path) => throw new UnsupportedError(
+ "Cannot get a package from an unknown source '$name'.");
+
+ /// Returns the directory where this package can be found locally.
+ Future<String> getDirectory(PackageId id) => throw new UnsupportedError(
+ "Cannot find a package from an unknown source '$name'.");
+
+ bool descriptionsEqual(description1, description2) =>
+ description1 == description2;
+
+ /// Unknown sources do no validation.
+ dynamic parseDescription(String containingPath, description,
+ {bool fromLockFile: false}) => description;
+}
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/source/path.dart ('k') | sdk/lib/_internal/pub/lib/src/source_registry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698