Verified Commit e7b17d08 authored by AtjonTV's avatar AtjonTV

Release 3.0.0

* IMPORTANT NOTICE
  * kLib is now licensed under the OSPL20 (a MPL 2.0 Fork), kLib prior to 3.0 will stay MIT!

* Added
  * 'smartMerge' extension to MutableMap
  * 'fullMerge' extension to MutableMap
  * 'mergeArrays' extension to MutableMap
  * 'openIfExist' parameter for ZipFile.open
  * 'reset' extension to File
  * 'kSock' object class
  * 'every' extension to Function '() -> Unit'

* Removed
  * 'version' property of kLibInf (Replaced with semver)
  * 'versionId' property of kLibInf (Replaced with semver)
  * 'klibRequire' for versionId (Replaced with semver)
  * 'klibRequire' for versionId range (Replaced with semver)

* Fixed
  * Fixed bug in SemVer parsing crashing when preRelease and buildMetadata was not given
Signed-off-by: AtjonTV's avatarAtjonTV <thomas.obernosterer@atvg-studios.com>
parent 9adfe382
Pipeline #1973 passed with stages
in 4 minutes and 7 seconds
......@@ -7,15 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Added
* `smartMerge` extension to MutableMap
* `fullMerge` extension to MutableMap
* `mergeArrays` extension to MutableMap
### Changed
### Deprecated
### Removed
### Fixed
### Security
## 3.0.0 - 08.06.2019
### IMPORTANT NOTICE
- kLib is now licensed under the OSPL20 (a MPL 2.0 Fork), kLib prior to 3.0 will stay MIT!
### Added
- `smartMerge` extension to MutableMap
- `fullMerge` extension to MutableMap
- `mergeArrays` extension to MutableMap
- `openIfExist` parameter for ZipFile.open
- `reset` extension to File
- `kSock` object class
- `every` extension to Function `() -> Unit`
### Removed
- `version` property of kLibInf (Replaced with semver)
- `versionId` property of kLibInf (Replaced with semver)
- `klibRequire` for versionId (Replaced with semver)
- `klibRequire` for versionId range (Replaced with semver)
### Fixed
- Fixed bug in SemVer parsing crashing when preRelease and buildMetadata was not given
## 2.1.1 - 01.06.2019
### Fixed
......@@ -245,7 +265,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Overview
* Unreleased - [Diff 1.4.0 to master](https://gitlab.atvg-studios.at/atvg-studios/kLib/compare/1.4.0...master)
* Unreleased - [Diff 3.0.0 to master](https://gitlab.atvg-studios.at/atvg-studios/kLib/compare/3.0.0...master)
* 3.0.0 - [Diff 2.1.1 to 3.0.0](https://gitlab.atvg-studios.at/atvg-studios/kLib/compare/2.1.1...3.0.0)
* 2.1.1 - [Diff 2.1.0 to 2.1.1](https://gitlab.atvg-studios.at/atvg-studios/kLib/compare/2.1.0...2.1.1)
* 2.1.0 - [Diff 2.0.0 to 2.1.0](https://gitlab.atvg-studios.at/atvg-studios/kLib/compare/2.0.0...2.1.0)
* 2.0.0 - [Diff 1.4.0 to 2.0.0](https://gitlab.atvg-studios.at/atvg-studios/kLib/compare/1.4.0...2.0.0)
* 1.4.0 - [Diff 1.3.0 to 1.4.0](https://gitlab.atvg-studios.at/atvg-studios/kLib/compare/1.3.0...1.4.0)
* 1.3.0 - [Diff 1.2.0 to 1.3.0](https://gitlab.atvg-studios.at/atvg-studios/kLib/compare/1.2.0...1.3.0)
* 1.2.0 - [Diff 1.1.0 to 1.2.0](https://gitlab.atvg-studios.at/atvg-studios/kLib/compare/1.1.0...1.2.0)
......
......@@ -12,6 +12,7 @@ Breaking versions must be in a new row!
| 7 | 0.1.6 |
| 8 - 15| 0.2.0 - 1.4.0 |
|16 - 19| 2.0.0 - 2.1.1|
|20 | 3.0.0 |
This means: `0.1.2` **IS** compatible with `0.1.3` but **NOT** compatible with `0.1.0` and `0.1.1`.
......@@ -34,6 +35,10 @@ Table created from APIs removed.
| 0.1.6 | Removal of deprecated API `Base58` (`objects.base.Base58`) | Was replaced with `Base58e` which bases on code from Google (Supports encode+decode) |
| 0.2.0 | Rename package from `com.atvgstudios.klib.*` to `klib.*` | Making the use of kLib simpler and pulling it of from ATVG-Studios |
| 2.0.0 | Removal of `exceptions.KonfParseException` | Replaced with `KonfigParseException` for ease |
| 3.0.0 | Removal of `kLibInf.version` | Replaced with `kLibInf.semver` using `types.SemVer` |
| 3.0.0 | Removal of `kLibInf.versionId` | Replaced with `kLibInf.semver` using `types.SemVer` |
| 3.0.0 | Removal of `kLibRequire` | Replaced with `kLibRequire` using `types.SemVer` |
| 3.0.0 | Removal of `kLibRequire` (min,max) | Replaced with `kLibRequire` (min,max) using `types.SemVer` |
## Upcoming Breaking Changes
......@@ -41,7 +46,6 @@ Table created from APIs marked as Deprecated.
| Since | Change | Reason |
|-------|--------|--------|
| 2.1.0 | Removal of `kLibInf.version` | Replaced with `kLibInf.semver` using `types.SemVer` |
## Experimental APIs
......
This diff is collapsed.
......@@ -6,6 +6,7 @@
| release/1.4.x | [![pipeline status](https://gitlab.atvg-studios.at/atvg-studios/kLib/badges/release/1.4.x/pipeline.svg)](https://gitlab.atvg-studios.at/atvg-studios/kLib/commits/release/1.4.x) |
| release/2.0.x | [![pipeline status](https://gitlab.atvg-studios.at/atvg-studios/kLib/badges/release/2.0.x/pipeline.svg)](https://gitlab.atvg-studios.at/atvg-studios/kLib/commits/release/2.0.x) |
| release/2.1.x | [![pipeline status](https://gitlab.atvg-studios.at/atvg-studios/kLib/badges/release/2.1.x/pipeline.svg)](https://gitlab.atvg-studios.at/atvg-studios/kLib/commits/release/2.1.x) |
| release/3.0.x | [![pipeline status](https://gitlab.atvg-studios.at/atvg-studios/kLib/badges/release/3.0.x/pipeline.svg)](https://gitlab.atvg-studios.at/atvg-studios/kLib/commits/release/3.0.x) |
kLib is a in Kotlin written Library by ATVG-Studios containing a set of useful Functions,
Extensions and Types.
......@@ -74,10 +75,6 @@ All versions before 1.4.0 are considered Legacy and are no longer developed or s
# License
kLib is distributed under the [MIT](LICENSE) License and available for everyone at any time.
kLib is distributed under the [OSPL 20](LICENSE) License (a MPL 2.0 Fork).
The usage of kLib however, may be written in a "Open-Source Licenses" section of a Legal Notice or a End User License Agreement (EULA).
Users may be informed about the Usage of kLib in your product.
This is **NOT** a strict requirement, but a helpful feature for both ATVG-Studios and the User.
The usage of kLib may be written in a "Open-Source Licenses" section of a Legal Notice or a End User License Agreement (EULA). (This is **NOT** a strict requirement.)
......@@ -6,8 +6,8 @@ plugins {
id 'signing'
}
group 'com.atvgstudios'
version '2.1.1'
group 'klib'
version '3.0.0'
repositories {
mavenCentral()
......
#!/bin/bash
VERSION="2.1.1"
VERSION="3.0.0"
mvn gpg:sign-and-deploy-file \
-DrepositoryId=atvg-studios \
......
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.atvgstudios</groupId>
<artifactId>klib</artifactId>
<version>2.1.1</version>
<version>3.0.0</version>
<name>kLib</name>
<description>kLib is a in Kotlin written Library by ATVG-Studios containing a set of useful Functions, Extensions and Types.</description>
<url>https://klib.atvg-studios.com/</url>
......
......@@ -95,4 +95,19 @@ fun File.Sha256Checksum(): String {
*/
fun File.Sha1Checksum(): String {
return Sha1.hash(this.readBytes()).checksum
}
/**
* Reset a file (delete if exist; create if not)
*
* @since 3.0.0
* @author Thomas Obernosterer
*/
fun File.reset() {
if (this.exists()) {
this.delete()
this.createNewFile()
} else {
this.createNewFile()
}
}
\ No newline at end of file
package klib.extensions
import java.util.Timer
import java.util.TimerTask
/**
* Execute function every x milliseconds
*
* @param delay Every x millis
*
* @since 3.0.0
* @author Thomas Obernosterer
*/
infix fun (() -> Unit).every(delay: Long) {
val timer = Timer()
timer.scheduleAtFixedRate(
object : TimerTask() {
override fun run() {
try {
this@every()
} catch (e: Exception) {
e.printStackTrace()
}
}
}, 0, delay
)
}
\ No newline at end of file
......@@ -5,30 +5,32 @@ package klib.extensions
*
* @param other The map to merge
*
* @since <NEXT_VERSION>
* @since 3.0.0
* @author Thomas Obernosterer
*/
fun <K,V> MutableMap<K,V>.smartMerge(other: Map<K,V>) {
fun <K, V> MutableMap<K, V>.smartMerge(other: Map<K, V>) {
other.forEach { (key, value) ->
if(key !in this) {
if (key !in this) {
this[key] = value
}
}
}
/**
* Merge a Key and a Value Array into a MutableMap
* Merge a Key and a Value Array into a MutableMap; Duplicate keys will be ignored
*
* @param keys The Keys
* @param values The Values
*
* @since <NEXT_VERSION>
* @since 3.0.0
* @author Thomas Obernosterer
*/
fun <K,V> MutableMap<K,V>.mergeArrays(keys: Array<K>, values: Array<V>) {
if(keys.size == values.size) {
for(i in 0 until keys.size) {
this[keys[i]] = values[i]
fun <K, V> MutableMap<K, V>.mergeArrays(keys: Array<K>, values: Array<V>) {
if (keys.size == values.size) {
for (i in 0 until keys.size) {
if (keys[i] !in this) {
this[keys[i]] = values[i]
}
}
}
}
......@@ -38,10 +40,10 @@ fun <K,V> MutableMap<K,V>.mergeArrays(keys: Array<K>, values: Array<V>) {
*
* @param other The map to merge
*
* @since <NEXT_VERSION>
* @since 3.0.0
* @author Thomas Obernosterer
*/
fun <K,V> MutableMap<K,V>.fullMerge(other: Map<K,V>) {
fun <K, V> MutableMap<K, V>.fullMerge(other: Map<K, V>) {
other.forEach { (key, value) ->
this[key] = value
}
......
......@@ -7,24 +7,7 @@ import klib.types.SemVer
* Check if the used kLib is the required version (Dependency Check)
* If not, kLibInf.exit() is called
*
* @param version
* @see kLibInf.exit
*
* @since 0.1.3
* @author Thomas Obernosterer
*/
fun kLibRequire(version: Int) {
if (kLibInf.versionId != version) {
println("This application requires kLib release $version! (Release ${kLibInf.versionId} not Compatible)")
kLibInf.exit(1)
}
}
/**
* Check if the used kLib is the required version (Dependency Check)
* If not, kLibInf.exit() is called
*
* @param version
* @param version Required Version
* @see kLibInf.exit
*
* @since 2.1.0
......@@ -38,19 +21,19 @@ fun kLibRequire(version: SemVer) {
}
/**
* Check if the used kLib is in the required version range (Dependency Check)
* Check if the used kLib is the required version (Dependency Check)
* If not, kLibInf.exit() is called
*
* @param minVersion
* @param maxVersion
* @param min Minimum Version
* @param max Maximum Version
* @see kLibInf.exit
*
* @since 0.1.3
* @since 3.0.0
* @author Thomas Obernosterer
*/
fun kLibRequire(minVersion: Int, maxVersion: Int) {
if (kLibInf.versionId < minVersion || kLibInf.versionId > maxVersion) {
println("This application requires at least kLib release $minVersion and at most kLib release $maxVersion! (Release ${kLibInf.versionId} not Compatible)")
fun kLibRequire(min: SemVer, max: SemVer) {
if (kLibInf.semver < min || kLibInf.semver > max) {
println("This application requires kLib a version between $min and $max! (Version ${kLibInf.semver} not Compatible)")
kLibInf.exit(1)
}
}
\ No newline at end of file
......@@ -19,30 +19,13 @@ object kLibInf {
*/
const val name = "kLib"
/**
* Unique Version ID (Used to identify versions; Not for humans)
*
* @since 0.1.0
* @author Thomas Obernosterer
*/
const val versionId = 19 // A unique version number used to identify releases and to make easy requirement checks
/**
* Version String (For humans; SemVer)
*
* @since 0.1.0
* @author Thomas Obernosterer
*/
@Deprecated("The simple Version String was deprecated, and replaced with the semver property", level = DeprecationLevel.ERROR)
const val version = "2.1.1"
/**
* Version String (For computers; SemVer)
*
* @since 2.0.0
* @author Thomas Obernosterer
*/
val semver = SemVer(2, 1, 1, "r$versionId")
val semver = SemVer(3, 0, 0)
/**
* Company creating kLib
......@@ -58,7 +41,7 @@ object kLibInf {
* @since 0.1.0
* @author Thomas Obernosterer
*/
const val license = "MIT"
const val license = "OSPL20/MPL2.0"
/**
* List of Authors
......
package klib.objects
import klib.extensions.reset
import klib.functions.currentMillis
import java.io.File
import java.io.InputStreamReader
import java.util.Timer
import java.util.TimerTask
/**
* Simple but useful one-way IPC socket
*
* @since 3.0.0
* @author Thomas Obernosterer
*/
object kSock {
private var id = 0L
/**
* Open a timed one-way connection
*
* @param name File path of socket
* @param timed Refresh seconds
* @param block Refresh-Listener (Based on modify date)
*
* @since 3.0.0
* @author Thomas Obernosterer
*/
fun open(name: String = "/tmp/ksock-$id.sock", timed: Long = 100, block: (InputStreamReader) -> Unit) {
id++
// Store last modified date of file
var lastTime = currentMillis()
val file = File(name)
// Reset the file
file.reset()
// Create and start Timer
val timer = Timer()
timer.scheduleAtFixedRate(object : TimerTask() {
override fun run() {
val lastMod = file.lastModified()
if (lastMod != lastTime) {
lastTime = lastMod
block(file.reader())
file.reset()
}
}
}, timed, timed)
}
}
\ No newline at end of file
......@@ -46,12 +46,18 @@ class SemVer(
val pattern = Regex("""(0|[1-9]\d*)?(?:\.)?(0|[1-9]\d*)?(?:\.)?(0|[1-9]\d*)?(?:-([\dA-z\-]+(?:\.[\dA-z\-]+)*))?(?:\+([\dA-z\-]+(?:\.[\dA-z\-]+)*))?""")
val result = pattern.matchEntire(version) ?: throw InvalidTypeException(version, "SemVer Version String")
var preRelease: String? = result.groupValues[4]
var buildMetadata: String? = result.groupValues[5]
if (preRelease != null && preRelease.isEmpty()) preRelease = null
if (buildMetadata != null && buildMetadata.isEmpty()) buildMetadata = null
return SemVer(
major = result.groupValues[1].toIntOrNull() ?: 0,
minor = result.groupValues[2].toIntOrNull() ?: 0,
patch = result.groupValues[3].toIntOrNull() ?: 0,
preRelease = result.groupValues[4],
buildMetadata = result.groupValues[5]
preRelease = preRelease,
buildMetadata = buildMetadata
)
}
}
......
......@@ -31,11 +31,11 @@ class ZipFile(private val fileName: String, private val safeMode: Boolean = true
* @since 1.2.0
* @author Thomas Obernosterer
*/
fun open() {
fun open(openIfExist: Boolean = false) {
if (fileOpen) return
val file = File(fileName)
if (file.exists()) {
if (!openIfExist && file.exists()) {
throw FileAlreadyExistsException(file)
}
......
package devtests
import klib.extensions.every
fun main() {
{
println("hi")
} every 10_000
}
\ No newline at end of file
package devtests
import klib.types.SemVer
fun main() {
val semver1 = SemVer.parse("1.0.0")
println(semver1)
val semver2 = SemVer.parse("1.0.0-beta")
println(semver2)
val semver3 = SemVer.parse("1.0.0-beta+4")
println(semver3)
}
\ No newline at end of file
package devtests
import klib.objects.kSock
fun main() {
kSock.open {
println(it.readText().trim())
}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment