-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
161 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
heylogs-api/src/main/java/internal/heylogs/semver/SemVer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package internal.heylogs.semver; | ||
|
||
import lombok.NonNull; | ||
import nbbrd.design.DirectImpl; | ||
import nbbrd.heylogs.spi.Versioning; | ||
import nbbrd.service.ServiceProvider; | ||
import org.semver4j.Semver; | ||
|
||
@DirectImpl | ||
@ServiceProvider | ||
public final class SemVer implements Versioning { | ||
|
||
@Override | ||
public @NonNull String getVersioningId() { | ||
return "semver"; | ||
} | ||
|
||
@Override | ||
public @NonNull String getVersioningName() { | ||
return "Semantic Versioning"; | ||
} | ||
|
||
@Override | ||
public boolean isValidVersion(@NonNull CharSequence text) { | ||
return Semver.isValid(text.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
heylogs-api/src/main/java/nbbrd/heylogs/spi/Versioning.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package nbbrd.heylogs.spi; | ||
|
||
import lombok.NonNull; | ||
import nbbrd.service.Quantifier; | ||
import nbbrd.service.ServiceDefinition; | ||
import nbbrd.service.ServiceId; | ||
|
||
@ServiceDefinition( | ||
quantifier = Quantifier.MULTIPLE | ||
) | ||
public interface Versioning { | ||
|
||
@ServiceId(pattern = ServiceId.KEBAB_CASE) | ||
@NonNull String getVersioningId(); | ||
|
||
@NonNull String getVersioningName(); | ||
|
||
boolean isValidVersion(@NonNull CharSequence text); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
heylogs-api/src/test/java/internal/heylogs/semver/SemVerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package internal.heylogs.semver; | ||
|
||
import nbbrd.heylogs.spi.VersioningLoader; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class SemVerTest { | ||
|
||
@Test | ||
void getVersioningId() { | ||
assertThat(new SemVer().getVersioningId()) | ||
.matches(VersioningLoader.ID_PATTERN); | ||
} | ||
|
||
@Test | ||
void getVersioningName() { | ||
assertThat(new SemVer().getVersioningName()) | ||
.isNotBlank(); | ||
} | ||
|
||
@Test | ||
void isValidVersion() { | ||
SemVer x = new SemVer(); | ||
assertThat(x.isValidVersion("1.1.0")).isTrue(); | ||
assertThat(x.isValidVersion(".1.0")).isFalse(); | ||
} | ||
} |
Oops, something went wrong.