Chromium Code Reviews| Index: sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart |
| diff --git a/sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart b/sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..28710840d42cc1a15be585f5afa7e8e2a4a11500 |
| --- /dev/null |
| +++ b/sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart |
| @@ -0,0 +1,27 @@ |
| +// Copyright (c) 2013, 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.pub_package_provider; |
| + |
| +import 'dart:async'; |
| + |
| +import 'package:barback/barback.dart'; |
| +import 'package:path/path.dart' as path; |
| + |
| +import '../package_graph.dart'; |
| + |
| +/// An implementation of barback's [PackageProvider] interface so that barback |
| +/// can assets within pub packages. |
|
Bob Nystrom
2013/08/27 22:12:30
"can assets" -> "can find assets", though the form
|
| +class PubPackageProvider implements PackageProvider { |
| + final PackageGraph _graph; |
| + |
| + PubPackageProvider(this._graph); |
| + |
| + Iterable<String> get packages => _graph.packages.keys; |
| + |
| + Future<Asset> getAsset(AssetId id) { |
| + var file = path.join(_graph.packages[id.package].dir, id.path); |
| + return new Future.value(new Asset.fromPath(id, file)); |
| + } |
| +} |