| 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 /** | 5 /** |
| 6 * Handles version numbers, following the [Semantic Versioning][semver] spec. | 6 * Handles version numbers, following the [Semantic Versioning][semver] spec. |
| 7 * | 7 * |
| 8 * [semver]: http://semver.org/ | 8 * [semver]: http://semver.org/ |
| 9 */ | 9 */ |
| 10 #library('pub_version'); | 10 #library('version'); |
| 11 | 11 |
| 12 #import('utils.dart'); | 12 #import('utils.dart'); |
| 13 | 13 |
| 14 /** A parsed semantic version number. */ | 14 /** A parsed semantic version number. */ |
| 15 class Version implements Comparable, Hashable, VersionConstraint { | 15 class Version implements Comparable, Hashable, VersionConstraint { |
| 16 static get none() => new Version(0, 0, 0); | 16 static get none() => new Version(0, 0, 0); |
| 17 | 17 |
| 18 static final _PARSE_REGEX = const RegExp( | 18 static final _PARSE_REGEX = const RegExp( |
| 19 @'^' // Start at beginning. | 19 @'^' // Start at beginning. |
| 20 @'(\d+).(\d+).(\d+)' // Version number. | 20 @'(\d+).(\d+).(\d+)' // Version number. |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 /** Tests if [other] matches falls within this version range. */ | 203 /** Tests if [other] matches falls within this version range. */ |
| 204 bool allows(Version other) { | 204 bool allows(Version other) { |
| 205 if (min != null && other < min) return false; | 205 if (min != null && other < min) return false; |
| 206 if (max != null && other >= max) return false; | 206 if (max != null && other >= max) return false; |
| 207 return true; | 207 return true; |
| 208 } | 208 } |
| 209 } | 209 } |
| OLD | NEW |