From 1a3c7fbac2ad6d340e8b5633e1823ca52df39ec3 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Wed, 31 Jan 2024 18:05:32 -0800 Subject: [PATCH 1/2] Minor cleanups --- pom.xml | 22 ++----------------- .../net/thauvin/erik/jokeapi/JokeApi.kt | 3 +++ .../net/thauvin/erik/jokeapi/JokeUtil.kt | 6 +++++ 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index f2be8ba..61f1be6 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 net.thauvin.erik jokeapi - 0.9.1 + 0.9.2-SNAPSHOT jokeapi Retrieve jokes from Sv443's JokeAPI https://github.com/ethauvin/jokeapi @@ -18,25 +18,7 @@ org.jetbrains.kotlin kotlin-stdlib - 1.9.21 - compile - - - org.jetbrains.kotlin - kotlin-stdlib-common - 1.9.21 - compile - - - org.jetbrains.kotlin - kotlin-stdlib-jdk7 - 1.9.21 - compile - - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - 1.9.21 + 1.9.22 compile diff --git a/src/main/kotlin/net/thauvin/erik/jokeapi/JokeApi.kt b/src/main/kotlin/net/thauvin/erik/jokeapi/JokeApi.kt index b4df9aa..a4dbda1 100644 --- a/src/main/kotlin/net/thauvin/erik/jokeapi/JokeApi.kt +++ b/src/main/kotlin/net/thauvin/erik/jokeapi/JokeApi.kt @@ -45,6 +45,9 @@ import java.util.stream.Collectors object JokeApi { private const val API_URL = "https://v2.jokeapi.dev/" + /** + * The logger instance. + */ @JvmStatic val logger: Logger by lazy { Logger.getLogger(JokeApi::class.java.simpleName) } diff --git a/src/main/kotlin/net/thauvin/erik/jokeapi/JokeUtil.kt b/src/main/kotlin/net/thauvin/erik/jokeapi/JokeUtil.kt index ff9f3e6..21006d5 100644 --- a/src/main/kotlin/net/thauvin/erik/jokeapi/JokeUtil.kt +++ b/src/main/kotlin/net/thauvin/erik/jokeapi/JokeUtil.kt @@ -123,6 +123,9 @@ private fun httpError(responseCode: Int): HttpErrorException { return httpException } +/** + * Parse Error. + */ internal fun parseError(json: JSONObject): JokeException { val causedBy = json.getJSONArray("causedBy") val causes = List(causedBy.length()) { i -> causedBy.getString(i) } @@ -136,6 +139,9 @@ internal fun parseError(json: JSONObject): JokeException { ) } +/** + * Parse Joke. + */ internal fun parseJoke(json: JSONObject, splitNewLine: Boolean): Joke { val jokes = mutableListOf() if (json.has("setup")) { From cdeb91c7d4f90f9b66fe0f46e5a67cfa75f87fac Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Wed, 31 Jan 2024 18:05:53 -0800 Subject: [PATCH 2/2] Added contributing section --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 869c58c..e2dbad4 100644 --- a/README.md +++ b/README.md @@ -165,3 +165,22 @@ error: false code: "fr" ``` - View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/ApiCallTest.kt#L48)... + +## Contributing + +If you want to contribute to this project, all you have to do is clone the GitHub +repository: + +```console +git clone git@github.com:ethauvin/jokeapi.git +``` + +Then use [bld](https://rife2.com/bld) to build: + +```console +cd jokeapi +./bld compile +``` + +The project has an [IntelliJ IDEA](https://www.jetbrains.com/idea/) project structure. You can just open it after all +the dependencies were downloaded and peruse the code.