OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Handles version numbers, following the [Semantic Versioning][semver] spec. | 5 /// Handles version numbers, following the [Semantic Versioning][semver] spec. |
6 /// | 6 /// |
7 /// [semver]: http://semver.org/ | 7 /// [semver]: http://semver.org/ |
8 library pub.version; | 8 library pub.version; |
9 | 9 |
10 import 'dart:math'; | 10 import 'dart:math'; |
11 | 11 |
12 import 'package:collection_helpers/equality.dart'; | 12 import 'package:collection/equality.dart'; |
13 | 13 |
14 /// Regex that matches a version number at the beginning of a string. | 14 /// Regex that matches a version number at the beginning of a string. |
15 final _START_VERSION = new RegExp( | 15 final _START_VERSION = new RegExp( |
16 r'^' // Start at beginning. | 16 r'^' // Start at beginning. |
17 r'(\d+).(\d+).(\d+)' // Version number. | 17 r'(\d+).(\d+).(\d+)' // Version number. |
18 r'(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?' // Pre-release. | 18 r'(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?' // Pre-release. |
19 r'(\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?'); // Build. | 19 r'(\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?'); // Build. |
20 | 20 |
21 /// Like [_START_VERSION] but matches the entire string. | 21 /// Like [_START_VERSION] but matches the entire string. |
22 final _COMPLETE_VERSION = new RegExp("${_START_VERSION.pattern}\$"); | 22 final _COMPLETE_VERSION = new RegExp("${_START_VERSION.pattern}\$"); |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 | 524 |
525 class _EmptyVersion implements VersionConstraint { | 525 class _EmptyVersion implements VersionConstraint { |
526 const _EmptyVersion(); | 526 const _EmptyVersion(); |
527 | 527 |
528 bool get isEmpty => true; | 528 bool get isEmpty => true; |
529 bool get isAny => false; | 529 bool get isAny => false; |
530 bool allows(Version other) => false; | 530 bool allows(Version other) => false; |
531 VersionConstraint intersect(VersionConstraint other) => this; | 531 VersionConstraint intersect(VersionConstraint other) => this; |
532 String toString() => '<empty>'; | 532 String toString() => '<empty>'; |
533 } | 533 } |
OLD | NEW |