Cleanup before 0.9.0 release
This commit is contained in:
parent
cd83485c64
commit
1c0b71373a
9 changed files with 40 additions and 41 deletions
2
.github/workflows/gradle.yml
vendored
2
.github/workflows/gradle.yml
vendored
|
@ -12,7 +12,7 @@ jobs:
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java-version: [ 11, 17, 18 ]
|
java-version: [ 11, 17, 20 ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
2
.idea/codeStyles/codeStyleConfig.xml
generated
2
.idea/codeStyles/codeStyleConfig.xml
generated
|
@ -1,5 +1,5 @@
|
||||||
<component name="ProjectCodeStyleConfiguration">
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
<state>
|
<state>
|
||||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Erik's Code Style" />
|
||||||
</state>
|
</state>
|
||||||
</component>
|
</component>
|
2
.idea/kotlinc.xml
generated
2
.idea/kotlinc.xml
generated
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="KotlinJpsPluginSettings">
|
<component name="KotlinJpsPluginSettings">
|
||||||
<option name="version" value="1.8.22" />
|
<option name="version" value="1.9.10" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
24
README.md
24
README.md
|
@ -1,8 +1,8 @@
|
||||||
[](https://opensource.org/licenses/BSD-3-Clause)
|
[](https://opensource.org/licenses/BSD-3-Clause)
|
||||||
[](https://kotlinlang.org/)
|
[](https://kotlinlang.org/)
|
||||||
[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/jokeapi/)
|
[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/jokeapi/)
|
||||||
[](https://github.com/ethauvin/jokeapi/releases/latest)
|
[](https://github.com/ethauvin/jokeapi/releases/latest)
|
||||||
[](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/jokeapi)
|
[](https://central.sonatype.com/artifact/net.thauvin.erik/jokeapi)
|
||||||
|
|
||||||
[](https://sonarcloud.io/dashboard?id=ethauvin_jokeapi)
|
[](https://sonarcloud.io/dashboard?id=ethauvin_jokeapi)
|
||||||
[](https://github.com/ethauvin/jokeapi/actions/workflows/gradle.yml)
|
[](https://github.com/ethauvin/jokeapi/actions/workflows/gradle.yml)
|
||||||
|
@ -36,7 +36,7 @@ data class Joke(
|
||||||
val lang: Language
|
val lang: Language
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetJokeTest.kt#L31)...
|
- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetJokeTest.kt#L64)...
|
||||||
|
|
||||||
To retrieve multiple jokes:
|
To retrieve multiple jokes:
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ frenchJokes.forEach {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetJokesTest.kt#L31)...
|
- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetJokesTest.kt#L52)...
|
||||||
|
|
||||||
|
|
||||||
If an error occurs, a `JokeException` is thrown, matching the [JokeAPI errors](https://sv443.net/jokeapi/v2/#errors):
|
If an error occurs, a `JokeException` is thrown, matching the [JokeAPI errors](https://sv443.net/jokeapi/v2/#errors):
|
||||||
|
@ -74,7 +74,7 @@ class HttpErrorException(
|
||||||
cause: Throwable? = null
|
cause: Throwable? = null
|
||||||
) : IOException(message, cause)
|
) : IOException(message, cause)
|
||||||
```
|
```
|
||||||
- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/ExceptionsTest.kt#L31)...
|
- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/ExceptionsTest.kt#L57)...
|
||||||
|
|
||||||
## Java
|
## Java
|
||||||
|
|
||||||
|
@ -98,11 +98,11 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("net.thauvin.erik:jokeapi:0.9-SNAPSHOT")
|
implementation("net.thauvin.erik:jokeapi:0.9.0")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Instructions for using with Maven, Ivy, etc. can be found on Maven Central.
|
Instructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://central.sonatype.com/artifact/net.thauvin.erik/jokeapi).
|
||||||
|
|
||||||
## Raw Jokes
|
## Raw Jokes
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ safe: true
|
||||||
lang: "en"
|
lang: "en"
|
||||||
|
|
||||||
```
|
```
|
||||||
- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetRawJokesTest.kt#L31)...
|
- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetRawJokesTest.kt#L46)...
|
||||||
|
|
||||||
## Extending
|
## Extending
|
||||||
|
|
||||||
|
@ -150,10 +150,4 @@ println(lang)
|
||||||
error: false
|
error: false
|
||||||
code: "fr"
|
code: "fr"
|
||||||
```
|
```
|
||||||
- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/ApiCallTest.kt#L31)...
|
- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/ApiCallTest.kt#L48)...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import org.jetbrains.dokka.gradle.DokkaTask
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.github.ben-manes.versions") version "0.47.0"
|
id("com.github.ben-manes.versions") version "0.48.0"
|
||||||
id("io.gitlab.arturbosch.detekt") version "1.23.1"
|
id("io.gitlab.arturbosch.detekt") version "1.23.1"
|
||||||
id("java")
|
id("java")
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
|
@ -15,9 +15,9 @@ plugins {
|
||||||
kotlin("jvm") version "1.9.10"
|
kotlin("jvm") version "1.9.10"
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "Wrapper for Sv443's JokeAPI"
|
description = "Retrieve jokes from Sv443's JokeAPI"
|
||||||
group = "net.thauvin.erik"
|
group = "net.thauvin.erik"
|
||||||
version = "0.9-SNAPSHOT"
|
version = "0.9.0"
|
||||||
|
|
||||||
val deployDir = "deploy"
|
val deployDir = "deploy"
|
||||||
val gitHub = "ethauvin/$name"
|
val gitHub = "ethauvin/$name"
|
||||||
|
@ -32,12 +32,12 @@ repositories {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(platform(kotlin("bom")))
|
implementation(platform(kotlin("bom")))
|
||||||
|
|
||||||
implementation("net.thauvin.erik:urlencoder:1.3.0")
|
implementation("net.thauvin.erik.urlencoder:urlencoder-lib:1.4.0")
|
||||||
implementation("org.json:json:20230618")
|
implementation("org.json:json:20230618")
|
||||||
|
|
||||||
testImplementation(kotlin("test"))
|
testImplementation(kotlin("test"))
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
|
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
|
||||||
testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.26.1")
|
testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.27.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
@ -126,7 +126,7 @@ tasks {
|
||||||
register("deploy") {
|
register("deploy") {
|
||||||
description = "Copies all needed files to the $deployDir directory."
|
description = "Copies all needed files to the $deployDir directory."
|
||||||
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
group = PublishingPlugin.PUBLISH_TASK_GROUP
|
||||||
dependsOn(clean, wrapper, build, jar)
|
dependsOn(clean, build, jar)
|
||||||
outputs.dir(deployDir)
|
outputs.dir(deployDir)
|
||||||
inputs.files(copyToDeploy)
|
inputs.files(copyToDeploy)
|
||||||
mustRunAfter(clean)
|
mustRunAfter(clean)
|
||||||
|
|
|
@ -18,5 +18,6 @@
|
||||||
<ID>MagicNumber:JokeUtil.kt$500</ID>
|
<ID>MagicNumber:JokeUtil.kt$500</ID>
|
||||||
<ID>MagicNumber:JokeUtil.kt$523</ID>
|
<ID>MagicNumber:JokeUtil.kt$523</ID>
|
||||||
<ID>TooManyFunctions:JokeConfig.kt$JokeConfig$Builder</ID>
|
<ID>TooManyFunctions:JokeConfig.kt$JokeConfig$Builder</ID>
|
||||||
|
<ID>WildcardImport:JokeApi.kt$import net.thauvin.erik.jokeapi.models.*</ID>
|
||||||
</CurrentIssues>
|
</CurrentIssues>
|
||||||
</SmellBaseline>
|
</SmellBaseline>
|
||||||
|
|
14
pom.xml
14
pom.xml
|
@ -8,9 +8,9 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>net.thauvin.erik</groupId>
|
<groupId>net.thauvin.erik</groupId>
|
||||||
<artifactId>jokeapi</artifactId>
|
<artifactId>jokeapi</artifactId>
|
||||||
<version>0.9-SNAPSHOT</version>
|
<version>0.9.0</version>
|
||||||
<name>jokeapi</name>
|
<name>jokeapi</name>
|
||||||
<description>Wrapper for Sv443's JokeAPI</description>
|
<description>Retrieve jokes from Sv443's JokeAPI</description>
|
||||||
<url>https://github.com/ethauvin/jokeapi</url>
|
<url>https://github.com/ethauvin/jokeapi</url>
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-bom</artifactId>
|
<artifactId>kotlin-bom</artifactId>
|
||||||
<version>1.8.22</version>
|
<version>1.9.10</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -50,13 +50,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||||
<version>1.8.22</version>
|
<version>1.9.10</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.thauvin.erik</groupId>
|
<groupId>net.thauvin.erik.urlencoder</groupId>
|
||||||
<artifactId>urlencoder</artifactId>
|
<artifactId>urlencoder-lib-jvm</artifactId>
|
||||||
<version>1.3.0</version>
|
<version>1.4.0</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -33,15 +33,8 @@ package net.thauvin.erik.jokeapi
|
||||||
|
|
||||||
import net.thauvin.erik.jokeapi.exceptions.HttpErrorException
|
import net.thauvin.erik.jokeapi.exceptions.HttpErrorException
|
||||||
import net.thauvin.erik.jokeapi.exceptions.JokeException
|
import net.thauvin.erik.jokeapi.exceptions.JokeException
|
||||||
import net.thauvin.erik.jokeapi.models.Category
|
import net.thauvin.erik.jokeapi.models.*
|
||||||
import net.thauvin.erik.jokeapi.models.Flag
|
import net.thauvin.erik.urlencoder.UrlEncoderUtil
|
||||||
import net.thauvin.erik.jokeapi.models.Format
|
|
||||||
import net.thauvin.erik.jokeapi.models.IdRange
|
|
||||||
import net.thauvin.erik.jokeapi.models.Joke
|
|
||||||
import net.thauvin.erik.jokeapi.models.Language
|
|
||||||
import net.thauvin.erik.jokeapi.models.Parameter
|
|
||||||
import net.thauvin.erik.jokeapi.models.Type
|
|
||||||
import net.thauvin.erik.urlencoder.UrlEncoder
|
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.util.logging.Logger
|
import java.util.logging.Logger
|
||||||
import java.util.stream.Collectors
|
import java.util.stream.Collectors
|
||||||
|
@ -85,7 +78,7 @@ object JokeApi {
|
||||||
val param = it.next()
|
val param = it.next()
|
||||||
urlBuilder.append(param.key)
|
urlBuilder.append(param.key)
|
||||||
if (param.value.isNotEmpty()) {
|
if (param.value.isNotEmpty()) {
|
||||||
urlBuilder.append("=").append(UrlEncoder.encode(param.value))
|
urlBuilder.append("=").append(UrlEncoderUtil.encode(param.value))
|
||||||
}
|
}
|
||||||
if (it.hasNext()) {
|
if (it.hasNext()) {
|
||||||
urlBuilder.append("&")
|
urlBuilder.append("&")
|
||||||
|
|
|
@ -36,6 +36,7 @@ import assertk.assertions.isGreaterThan
|
||||||
import assertk.assertions.startsWith
|
import assertk.assertions.startsWith
|
||||||
import net.thauvin.erik.jokeapi.JokeApi.apiCall
|
import net.thauvin.erik.jokeapi.JokeApi.apiCall
|
||||||
import net.thauvin.erik.jokeapi.models.Format
|
import net.thauvin.erik.jokeapi.models.Format
|
||||||
|
import net.thauvin.erik.jokeapi.models.Language
|
||||||
import net.thauvin.erik.jokeapi.models.Parameter
|
import net.thauvin.erik.jokeapi.models.Parameter
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import org.junit.jupiter.api.Assertions.assertFalse
|
import org.junit.jupiter.api.Assertions.assertFalse
|
||||||
|
@ -73,4 +74,14 @@ internal class ApiCallTest {
|
||||||
val ping = apiCall(endPoint = "ping", params = mapOf(Parameter.FORMAT to Format.TXT.value))
|
val ping = apiCall(endPoint = "ping", params = mapOf(Parameter.FORMAT to Format.TXT.value))
|
||||||
assertThat(ping, "apiCall(ping, txt)").startsWith("Pong!")
|
assertThat(ping, "apiCall(ping, txt)").startsWith("Pong!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Get Supported Language`() {
|
||||||
|
// See https://v2.jokeapi.dev/languages
|
||||||
|
val lang = apiCall(
|
||||||
|
endPoint = "languages",
|
||||||
|
params = mapOf(Parameter.FORMAT to Format.XML.value, Parameter.LANG to Language.FR.value)
|
||||||
|
)
|
||||||
|
assertThat(lang).startsWith("<?xml version='1.0'?>")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue