Skip to content

Commit

Permalink
Update version identifier parsing (#10)
Browse files Browse the repository at this point in the history
* feat: add codecov.yml

* fix: typo in readme header

* fix: regex patterns

* style: cleanup

* chore: rm workflow

* docs: update description of raw values

* docs: update jazzy
  • Loading branch information
mflknr committed Mar 30, 2021
1 parent 912371c commit 0c9d67d
Show file tree
Hide file tree
Showing 40 changed files with 89 additions and 91 deletions.
26 changes: 26 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# For more configuration details:
# https://docs.codecov.io/docs/codecov-yaml
# Check if this file is valid by running in bash:
# curl -X POST --data-binary @.codecov.yml https://codecov.io/validate
# Coverage configuration
# ----------------------
coverage:
status:
patch: false
range: 70..90 # First number represents red, and second represents green

# (default is 70..100)
round: down # up, down, or nearest
precision: 2 # Number of decimal places, between 0 and 5

# Ignoring Paths
# --------------
# which folders/files to ignore
ignore:
- Tests/**/*

# Pull request comments:
# ----------------------
# Diff is the Coverage Diff of the pull request.
# Files are the files impacted by the pull request
comment: false
22 changes: 0 additions & 22 deletions .github/workflows/main-release.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SwiftVersionCheck
# SwiftVersionCompare

![platforms](https://img.shields.io/badge/platforms-macOS%20%7C%20iOS%20%7C%20tvOS%20%7C%20watchOS-lightgrey.svg)
![languages](https://img.shields.io/badge/swift-5.0%20%7C%205.1%20%7C%205.2%20%7C%205.3-orange.svg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ internal extension Character {
var isZero: Bool {
if self == "0" {
return true
} else {
return false
}
return false
}
}
4 changes: 2 additions & 2 deletions Sources/SwiftVersionCompare/Helper/String+Regex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ internal extension String {
}

var isAlphaNumericString: Bool {
matches("[a-zA-Z-][0-9a-zA-Z-]+")
matches("^[a-zA-Z0-9-]+$")
}

var isNumericString: Bool {
matches("[0-9]+")
matches("[0-9]+$")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Marius Hötten-Löns on 12.03.21.
//

/// Typed build-meta-data identifier.
/// Typed build-meta-data.
///
/// - Note: Identifier can be described using alphanumeric letters or digits.
///
Expand All @@ -32,6 +32,7 @@ public enum BuildMetaData: Comparable {
}

public extension BuildMetaData {
/// Raw string representation of a build-meta-data.
var value: String {
switch self {
case let .alphaNumeric(identifier):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public enum PrereleaseIdentifier: Comparable, Hashable {
}

public extension PrereleaseIdentifier {
/// Raw string representation of a pre-release identifier.
var value: String {
switch self {
case .alpha:
Expand Down
7 changes: 4 additions & 3 deletions Sources/SwiftVersionCompare/Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public struct Version: SemanticVersionComparable {
// check for non-empty or invalid version string e.g. "-alpha"
guard
!versionSplitPrerelease.isEmpty,
let versionStringElement = versionSplitPrerelease.first else {
let versionStringElement = versionSplitPrerelease.first,
!versionStringElement.isEmpty else {
return nil
}

Expand Down Expand Up @@ -165,9 +166,9 @@ public struct Version: SemanticVersionComparable {
.compactMap {
if let asInt = Int($0) {
return PrereleaseIdentifier.init(integerLiteral: asInt)
} else {
return PrereleaseIdentifier.init($0)
}

return PrereleaseIdentifier.init($0)
}
// if a pre-release identifier element is initialized as .unkown, we can savely assume that the given
// string is not a valid `SemVer` version string.
Expand Down
2 changes: 2 additions & 0 deletions SwiftVersionCompare.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
24322B402613C4EC0028E151 /* .codecov.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .codecov.yml; sourceTree = "<group>"; };
24828B612613B4EC00AF8BA2 /* Character+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Character+Extensions.swift"; sourceTree = "<group>"; };
24A6A24525A3DD3B00E12D71 /* Error.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Error.swift; sourceTree = "<group>"; };
24A6A25825A5198900E12D71 /* String+Regex.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Regex.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -191,6 +192,7 @@
OBJ_20 /* LICENSE */,
OBJ_21 /* README.md */,
24A6A2BB25A67D1200E12D71 /* .jazzy.yml */,
24322B402613C4EC0028E151 /* .codecov.yml */,
);
sourceTree = "<group>";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ final class SemanticVersionComparableTests: XCTestCase {
Version("13.1.1-alpha"): Version("13.1.1-beta"),
Version("5-h2o4hr"): Version("5"),
Version("5-alpha.1"): Version("5-alpha.2"),
Version("5-alpha.2"): Version("5-alpha.beta")
Version("5-alpha.2"): Version("5-alpha.beta"),
Version("5-alpha.23+500"): Version("5-alpha.beta+200")
]

testData.forEach { lhs, rhs in
Expand Down
4 changes: 3 additions & 1 deletion Tests/SwiftVersionCompareTests/VersionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ final class VersionTests: XCTestCase {
"1.1.4354vdf",
"18+123+something",
"1.2.3-test+123-123-123-123+",
"0000001.00000001.01111"
"0000001.00000001.01111",
"1.1.1-alpha%",
"2-beta+23$"
]

func testValidConstruction() {
Expand Down
4 changes: 2 additions & 2 deletions docs/Enums.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a title="Enumerations Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html"> Docs</a> (97% documented)</p>
<p><a href="index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
Expand Down Expand Up @@ -135,7 +135,7 @@ <h4>Declaration</h4>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Typed build-meta-data identifier.</p>
<p>Typed build-meta-data.</p>
<div class="aside aside-note">
<p class="aside-title">Note</p>
<p>Identifier can be described using alphanumeric letters or digits.</p>
Expand Down
6 changes: 3 additions & 3 deletions docs/Enums/BuildMetaData.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a title="BuildMetaData Enumeration Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html"> Docs</a> (97% documented)</p>
<p><a href="../index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
Expand Down Expand Up @@ -91,7 +91,7 @@ <h1>BuildMetaData</h1>

</div>
</div>
<p>Typed build-meta-data identifier.</p>
<p>Typed build-meta-data.</p>
<div class="aside aside-note">
<p class="aside-title">Note</p>
<p>Identifier can be described using alphanumeric letters or digits.</p>
Expand Down Expand Up @@ -278,7 +278,7 @@ <h4>Declaration</h4>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Undocumented</p>
<p>Raw string representation of a build-meta-data.</p>

</div>
<div class="declaration">
Expand Down
4 changes: 2 additions & 2 deletions docs/Enums/PrereleaseIdentifier.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a title="PrereleaseIdentifier Enumeration Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html"> Docs</a> (97% documented)</p>
<p><a href="../index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
Expand Down Expand Up @@ -445,7 +445,7 @@ <h4>Declaration</h4>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Undocumented</p>
<p>Raw string representation of a pre-release identifier.</p>

</div>
<div class="declaration">
Expand Down
2 changes: 1 addition & 1 deletion docs/Enums/VersionCompareResult.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a title="VersionCompareResult Enumeration Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html"> Docs</a> (97% documented)</p>
<p><a href="../index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
Expand Down
2 changes: 1 addition & 1 deletion docs/Extensions.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a title="Extensions Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html"> Docs</a> (97% documented)</p>
<p><a href="index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
Expand Down
2 changes: 1 addition & 1 deletion docs/Extensions/Bundle.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a title="Bundle Extension Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html"> Docs</a> (97% documented)</p>
<p><a href="../index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
Expand Down
2 changes: 1 addition & 1 deletion docs/Extensions/ProcessInfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a title="ProcessInfo Extension Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html"> Docs</a> (97% documented)</p>
<p><a href="../index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
Expand Down
2 changes: 1 addition & 1 deletion docs/Protocols.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a title="Protocols Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html"> Docs</a> (97% documented)</p>
<p><a href="index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
Expand Down
2 changes: 1 addition & 1 deletion docs/Protocols/SemanticVersionComparable.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a title="SemanticVersionComparable Protocol Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html"> Docs</a> (97% documented)</p>
<p><a href="../index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
Expand Down
2 changes: 1 addition & 1 deletion docs/Structs.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a title="Structures Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html"> Docs</a> (97% documented)</p>
<p><a href="index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
Expand Down
2 changes: 1 addition & 1 deletion docs/Structs/Version.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a title="Version Structure Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html"> Docs</a> (97% documented)</p>
<p><a href="../index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
Expand Down
16 changes: 8 additions & 8 deletions docs/badge.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/docsets/.docset/Contents/Resources/Documents/Enums.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a title="Enumerations Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html"> Docs</a> (97% documented)</p>
<p><a href="index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
Expand Down Expand Up @@ -135,7 +135,7 @@ <h4>Declaration</h4>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Typed build-meta-data identifier.</p>
<p>Typed build-meta-data.</p>
<div class="aside aside-note">
<p class="aside-title">Note</p>
<p>Identifier can be described using alphanumeric letters or digits.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a title="BuildMetaData Enumeration Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html"> Docs</a> (97% documented)</p>
<p><a href="../index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
Expand Down Expand Up @@ -91,7 +91,7 @@ <h1>BuildMetaData</h1>

</div>
</div>
<p>Typed build-meta-data identifier.</p>
<p>Typed build-meta-data.</p>
<div class="aside aside-note">
<p class="aside-title">Note</p>
<p>Identifier can be described using alphanumeric letters or digits.</p>
Expand Down Expand Up @@ -278,7 +278,7 @@ <h4>Declaration</h4>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Undocumented</p>
<p>Raw string representation of a build-meta-data.</p>

</div>
<div class="declaration">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a title="PrereleaseIdentifier Enumeration Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html"> Docs</a> (97% documented)</p>
<p><a href="../index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
Expand Down Expand Up @@ -445,7 +445,7 @@ <h4>Declaration</h4>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Undocumented</p>
<p>Raw string representation of a pre-release identifier.</p>

</div>
<div class="declaration">
Expand Down

0 comments on commit 0c9d67d

Please sign in to comment.