| 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('version'); | 10 library version; |
| 11 | 11 |
| 12 #import('dart:math'); | 12 import 'dart:math'; |
| 13 | 13 |
| 14 #import('utils.dart'); | 14 import 'utils.dart'; |
| 15 | 15 |
| 16 /** A parsed semantic version number. */ | 16 /** A parsed semantic version number. */ |
| 17 class Version implements Comparable, VersionConstraint { | 17 class Version implements Comparable, VersionConstraint { |
| 18 /** No released version: i.e. "0.0.0". */ | 18 /** No released version: i.e. "0.0.0". */ |
| 19 static Version get none => new Version(0, 0, 0); | 19 static Version get none => new Version(0, 0, 0); |
| 20 | 20 |
| 21 static const _PARSE_REGEX = const RegExp( | 21 static const _PARSE_REGEX = const RegExp( |
| 22 r'^' // Start at beginning. | 22 r'^' // Start at beginning. |
| 23 r'(\d+).(\d+).(\d+)' // Version number. | 23 r'(\d+).(\d+).(\d+)' // Version number. |
| 24 r'(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?' // Pre-release. | 24 r'(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?' // Pre-release. |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 case '<': return new VersionRange(max: version, includeMax: false); | 420 case '<': return new VersionRange(max: version, includeMax: false); |
| 421 case '>=': return new VersionRange(min: version, includeMin: true); | 421 case '>=': return new VersionRange(min: version, includeMin: true); |
| 422 case '>': return new VersionRange(min: version, includeMin: false); | 422 case '>': return new VersionRange(min: version, includeMin: false); |
| 423 } | 423 } |
| 424 } | 424 } |
| 425 | 425 |
| 426 // Otherwise, it must be an explicit version. | 426 // Otherwise, it must be an explicit version. |
| 427 return new Version.parse(text); | 427 return new Version.parse(text); |
| 428 } | 428 } |
| 429 } | 429 } |
| OLD | NEW |