OLD | NEW |
1 library pub.source.hosted; | 1 library pub.source.hosted; |
2 import 'dart:async'; | 2 import 'dart:async'; |
3 import 'dart:io' as io; | 3 import 'dart:io' as io; |
4 import "dart:convert"; | 4 import "dart:convert"; |
5 import 'package:http/http.dart' as http; | 5 import 'package:http/http.dart' as http; |
6 import 'package:path/path.dart' as path; | 6 import 'package:path/path.dart' as path; |
| 7 import 'package:pub_semver/pub_semver.dart'; |
7 import '../exceptions.dart'; | 8 import '../exceptions.dart'; |
8 import '../http.dart'; | 9 import '../http.dart'; |
9 import '../io.dart'; | 10 import '../io.dart'; |
10 import '../log.dart' as log; | 11 import '../log.dart' as log; |
11 import '../package.dart'; | 12 import '../package.dart'; |
12 import '../pubspec.dart'; | 13 import '../pubspec.dart'; |
13 import '../utils.dart'; | 14 import '../utils.dart'; |
14 import '../version.dart'; | |
15 import 'cached.dart'; | 15 import 'cached.dart'; |
16 class HostedSource extends CachedSource { | 16 class HostedSource extends CachedSource { |
17 final name = "hosted"; | 17 final name = "hosted"; |
18 final hasMultipleVersions = true; | 18 final hasMultipleVersions = true; |
19 static String get defaultUrl { | 19 static String get defaultUrl { |
20 var url = io.Platform.environment["PUB_HOSTED_URL"]; | 20 var url = io.Platform.environment["PUB_HOSTED_URL"]; |
21 if (url != null) return url; | 21 if (url != null) return url; |
22 return "https://pub.dartlang.org"; | 22 return "https://pub.dartlang.org"; |
23 } | 23 } |
24 Future<List<Version>> getVersions(String name, description) { | 24 Future<List<Version>> getVersions(String name, description) { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 throw new FormatException("The description map must contain a 'name' key."); | 229 throw new FormatException("The description map must contain a 'name' key."); |
230 } | 230 } |
231 var name = description["name"]; | 231 var name = description["name"]; |
232 if (name is! String) { | 232 if (name is! String) { |
233 throw new FormatException("The 'name' key must have a string value."); | 233 throw new FormatException("The 'name' key must have a string value."); |
234 } | 234 } |
235 var url = description["url"]; | 235 var url = description["url"]; |
236 if (url == null) url = HostedSource.defaultUrl; | 236 if (url == null) url = HostedSource.defaultUrl; |
237 return new Pair<String, String>(name, url); | 237 return new Pair<String, String>(name, url); |
238 } | 238 } |
OLD | NEW |