-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Release/3.0.0 (#24) * fix * Feature/migrate gradle (#23) * change to gradle * change: action * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * .java を .kt に名前変更 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * release: 3.0.0 * .java を .kt に名前変更 * logger * .java を .kt に名前変更 * fix: compile err * fix: compile err * fix: compile warn * add test * add test * add test * add test
- Loading branch information
Showing
164 changed files
with
4,233 additions
and
1,681 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: run test | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Java | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
- name: Make gradlew executable | ||
run: chmod +x ./gradlew | ||
- name: Validate Gradle wrapper | ||
uses: gradle/wrapper-validation-action@v1 | ||
- name: run test | ||
uses: gradle/gradle-build-action@v2 | ||
with: | ||
arguments: allTests | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | ||
#### |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
## About | ||
|
||
* javaのutility | ||
* kotlinのutility | ||
|
||
## Use | ||
|
||
|
@@ -11,20 +11,20 @@ | |
<dependency> | ||
<groupId>net.kigawa.kutil</groupId> | ||
<artifactId>kutil</artifactId> | ||
<version>2.2.1</version> | ||
<version>3.0.0</version> | ||
</dependency> | ||
...... | ||
</dependencies> | ||
``` | ||
|
||
## Requirement | ||
|
||
* java | ||
* kotlin | ||
|
||
## Author | ||
|
||
* kigawa | ||
* kigawa.[email protected] | ||
* contact@kigawa.net | ||
|
||
# Making | ||
|
||
|
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 |
---|---|---|
|
@@ -3,4 +3,5 @@ plugins { | |
} | ||
|
||
dependencies { | ||
} | ||
commonMainImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") | ||
} |
10 changes: 10 additions & 0 deletions
10
api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/Func.kt
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,10 @@ | ||
package net.kigawa.kutil.kutil.api | ||
|
||
import kotlinx.coroutines.channels.Channel | ||
|
||
|
||
suspend inline fun <T> Channel<T>.forEach(func: (T) -> Unit) { | ||
for (item in this) { | ||
func(item) | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/Kutil.java
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/Kutil.kt
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,56 @@ | ||
@file:Suppress("unused") | ||
|
||
package net.kigawa.kutil.kutil.api | ||
|
||
import net.kigawa.kutil.kutil.api.io.KuCloseable | ||
import net.kigawa.kutil.kutil.api.io.SuspendCloseable | ||
import kotlin.contracts.ExperimentalContracts | ||
import kotlin.contracts.InvocationKind | ||
import kotlin.contracts.contract | ||
|
||
@Suppress("unused") | ||
object Kutil { | ||
fun fillStr(src: String, size: Int, fillChar: Char = ' '): String { | ||
val sb = StringBuilder(size) | ||
for (i in 0 until size) { | ||
sb.append(src.getOrNull(i) ?: fillChar) | ||
} | ||
return sb.toString() | ||
} | ||
|
||
} | ||
|
||
@OptIn(ExperimentalContracts::class) | ||
inline fun <T : KuCloseable, R> T.tryCatch( | ||
block: (self: T) -> R, | ||
): R { | ||
contract { | ||
callsInPlace(block, InvocationKind.EXACTLY_ONCE) | ||
} | ||
try { | ||
return block(this) | ||
} catch (e: Throwable) { | ||
throw e | ||
} finally { | ||
close() | ||
} | ||
} | ||
|
||
@OptIn(ExperimentalContracts::class) | ||
suspend inline fun <T : KuCloseable, R> T.tryCatchSuspend( | ||
block: (self: T) -> R, | ||
): R { | ||
contract { | ||
callsInPlace(block, InvocationKind.EXACTLY_ONCE) | ||
} | ||
try { | ||
return block(this) | ||
} catch (e: Throwable) { | ||
throw e | ||
} finally { | ||
when (this) { | ||
is SuspendCloseable -> suspendClose() | ||
else -> close() | ||
} | ||
} | ||
} |
39 changes: 0 additions & 39 deletions
39
api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/KutilArray.java
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/KutilArray.kt
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,7 @@ | ||
package net.kigawa.kutil.kutil.api | ||
|
||
/** | ||
* utilities about array | ||
*/ | ||
@Suppress("unused", "EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") | ||
expect object KutilArray |
45 changes: 0 additions & 45 deletions
45
api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/KutilFile.java
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/KutilFile.kt
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,9 @@ | ||
package net.kigawa.kutil.kutil.api | ||
|
||
/** | ||
* utilities about file | ||
*/ | ||
@Suppress("unused", "EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") | ||
expect object KutilFile { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/KutilPlatform.kt
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,7 @@ | ||
package net.kigawa.kutil.kutil.api | ||
|
||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") | ||
expect object KutilPlatform { | ||
fun getSystemProperty(name: String): String | ||
fun getEnv(name: String): String? | ||
} |
10 changes: 10 additions & 0 deletions
10
api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/Option.kt
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,10 @@ | ||
package net.kigawa.kutil.kutil.api | ||
|
||
@Suppress("unused") | ||
interface Option { | ||
val name: String | ||
val optName: String | ||
val shortName: String? | ||
val description: String | ||
val defaultValue: String | ||
} |
16 changes: 16 additions & 0 deletions
16
api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/OptionStore.kt
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,16 @@ | ||
package net.kigawa.kutil.kutil.api | ||
|
||
@Suppress("unused") | ||
class OptionStore { | ||
private val options = mutableMapOf<Option, String>() | ||
|
||
fun add(option: Option, value: String) { | ||
options[option] = value | ||
} | ||
|
||
|
||
fun get(option: Option): String = options[option] | ||
?: KutilPlatform.getEnv(option.name) | ||
?: option.defaultValue | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/Paths.kt
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,11 @@ | ||
package net.kigawa.kutil.kutil.api | ||
|
||
import net.kigawa.kutil.kutil.api.io.fs.KuPath | ||
|
||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") | ||
expect enum class Paths { | ||
JAVA | ||
; | ||
|
||
val path: KuPath | ||
} |
6 changes: 6 additions & 0 deletions
6
api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/PlatFormInstance.kt
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,6 @@ | ||
package net.kigawa.kutil.kutil.api | ||
|
||
@Suppress("unused") | ||
data class PlatFormInstance( | ||
val exitProcess: (Int) -> Nothing, | ||
) |
6 changes: 6 additions & 0 deletions
6
api/src/commonMain/kotlin/net/kigawa/kutil/kutil/api/SignalHandler.kt
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,6 @@ | ||
package net.kigawa.kutil.kutil.api | ||
|
||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") | ||
expect object SignalHandler { | ||
fun shutdownHook(hook: () -> Unit) | ||
} |
Oops, something went wrong.