mirror of
https://github.com/GayPizzaSpecifications/darwin-apk.git
synced 2025-08-03 21:41:31 +00:00
Implement dependency wrapping & version spec
This commit is contained in:
46
Sources/apk/Common/ApkVersionSpecification.swift
Normal file
46
Sources/apk/Common/ApkVersionSpecification.swift
Normal file
@ -0,0 +1,46 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
enum ApkVersionSpecification: Equatable {
|
||||
case any
|
||||
case constraint(op: Operator, version: String)
|
||||
case conflict
|
||||
}
|
||||
|
||||
extension ApkVersionSpecification: CustomStringConvertible {
|
||||
var description: String {
|
||||
switch self {
|
||||
case .any: ""
|
||||
case .conflict: "!"
|
||||
case .constraint(let op, let version): "\(op)\(version)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ApkVersionSpecification {
|
||||
enum Operator: Equatable {
|
||||
case equals
|
||||
case fuzzyEquals
|
||||
case greater
|
||||
case less
|
||||
case greaterEqual
|
||||
case lessEqual
|
||||
case greaterFuzzy
|
||||
case lessFuzzy
|
||||
}
|
||||
}
|
||||
|
||||
extension ApkVersionSpecification.Operator: CustomStringConvertible {
|
||||
var description: String {
|
||||
switch self {
|
||||
//case .checksum: "><"
|
||||
case .lessEqual: "<="
|
||||
case .greaterEqual: ">="
|
||||
case .lessFuzzy: "<~"
|
||||
case .greaterFuzzy: ">~"
|
||||
case .equals: "="
|
||||
case .less: "<"
|
||||
case .greater: ">"
|
||||
case .fuzzyEquals: "~"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user