Skip to content

Commit

Permalink
Cleanup before 0.9.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
ethauvin committed Sep 23, 2023
1 parent cd83485 commit 1c0b713
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
java-version: [ 11, 17, 18 ]
java-version: [ 11, 17, 20 ]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 9 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](https://opensource.org/licenses/BSD-3-Clause)
[![Kotlin](https://img.shields.io/badge/kotlin-1.8.22-7f52ff)](https://kotlinlang.org/)
[![Kotlin](https://img.shields.io/badge/kotlin-1.9.10-7f52ff)](https://kotlinlang.org/)
[![Nexus Snapshot](https://img.shields.io/nexus/s/net.thauvin.erik/jokeapi?label=snapshot&server=https%3A%2F%2Foss.sonatype.org%2F)](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/jokeapi/)
[![Release](https://img.shields.io/github/release/ethauvin/jokeapi.svg)](https://github.com/ethauvin/jokeapi/releases/latest)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/jokeapi/badge.svg?color=blue)](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/jokeapi)
[![Maven Central](https://img.shields.io/maven-central/v/net.thauvin.erik/jokeap)](https://central.sonatype.com/artifact/net.thauvin.erik/jokeapi)

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ethauvin_jokeapi&metric=alert_status)](https://sonarcloud.io/dashboard?id=ethauvin_jokeapi)
[![GitHub CI](https://github.com/ethauvin/jokeapi/actions/workflows/gradle.yml/badge.svg)](https://github.com/ethauvin/jokeapi/actions/workflows/gradle.yml)
Expand Down Expand Up @@ -36,7 +36,7 @@ data class Joke(
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:

Expand All @@ -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):
Expand All @@ -74,7 +74,7 @@ class HttpErrorException(
cause: Throwable? = null
) : 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

Expand All @@ -98,11 +98,11 @@ repositories {
}
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

Expand Down Expand Up @@ -130,7 +130,7 @@ safe: true
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
Expand All @@ -150,10 +150,4 @@ println(lang)
error: false
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)...
12 changes: 6 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

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("java")
id("maven-publish")
Expand All @@ -15,9 +15,9 @@ plugins {
kotlin("jvm") version "1.9.10"
}

description = "Wrapper for Sv443's JokeAPI"
description = "Retrieve jokes from Sv443's JokeAPI"
group = "net.thauvin.erik"
version = "0.9-SNAPSHOT"
version = "0.9.0"

val deployDir = "deploy"
val gitHub = "ethauvin/$name"
Expand All @@ -32,12 +32,12 @@ repositories {
dependencies {
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")

testImplementation(kotlin("test"))
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 {
Expand Down Expand Up @@ -126,7 +126,7 @@ tasks {
register("deploy") {
description = "Copies all needed files to the $deployDir directory."
group = PublishingPlugin.PUBLISH_TASK_GROUP
dependsOn(clean, wrapper, build, jar)
dependsOn(clean, build, jar)
outputs.dir(deployDir)
inputs.files(copyToDeploy)
mustRunAfter(clean)
Expand Down
1 change: 1 addition & 0 deletions detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
<ID>MagicNumber:JokeUtil.kt$500</ID>
<ID>MagicNumber:JokeUtil.kt$523</ID>
<ID>TooManyFunctions:JokeConfig.kt$JokeConfig$Builder</ID>
<ID>WildcardImport:JokeApi.kt$import net.thauvin.erik.jokeapi.models.*</ID>
</CurrentIssues>
</SmellBaseline>
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.thauvin.erik</groupId>
<artifactId>jokeapi</artifactId>
<version>0.9-SNAPSHOT</version>
<version>0.9.0</version>
<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>
<licenses>
<license>
Expand Down Expand Up @@ -40,7 +40,7 @@
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>1.8.22</version>
<version>1.9.10</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -50,13 +50,13 @@
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.8.22</version>
<version>1.9.10</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.thauvin.erik</groupId>
<artifactId>urlencoder</artifactId>
<version>1.3.0</version>
<groupId>net.thauvin.erik.urlencoder</groupId>
<artifactId>urlencoder-lib-jvm</artifactId>
<version>1.4.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
Expand Down
13 changes: 3 additions & 10 deletions src/main/kotlin/net/thauvin/erik/jokeapi/JokeApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,8 @@ package net.thauvin.erik.jokeapi

import net.thauvin.erik.jokeapi.exceptions.HttpErrorException
import net.thauvin.erik.jokeapi.exceptions.JokeException
import net.thauvin.erik.jokeapi.models.Category
import net.thauvin.erik.jokeapi.models.Flag
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 net.thauvin.erik.jokeapi.models.*
import net.thauvin.erik.urlencoder.UrlEncoderUtil
import org.json.JSONObject
import java.util.logging.Logger
import java.util.stream.Collectors
Expand Down Expand Up @@ -85,7 +78,7 @@ object JokeApi {
val param = it.next()
urlBuilder.append(param.key)
if (param.value.isNotEmpty()) {
urlBuilder.append("=").append(UrlEncoder.encode(param.value))
urlBuilder.append("=").append(UrlEncoderUtil.encode(param.value))
}
if (it.hasNext()) {
urlBuilder.append("&")
Expand Down
11 changes: 11 additions & 0 deletions src/test/kotlin/net/thauvin/erik/jokeapi/ApiCallTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import assertk.assertions.isGreaterThan
import assertk.assertions.startsWith
import net.thauvin.erik.jokeapi.JokeApi.apiCall
import net.thauvin.erik.jokeapi.models.Format
import net.thauvin.erik.jokeapi.models.Language
import net.thauvin.erik.jokeapi.models.Parameter
import org.json.JSONObject
import org.junit.jupiter.api.Assertions.assertFalse
Expand Down Expand Up @@ -73,4 +74,14 @@ internal class ApiCallTest {
val ping = apiCall(endPoint = "ping", params = mapOf(Parameter.FORMAT to Format.TXT.value))
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'?>")
}
}

0 comments on commit 1c0b713

Please sign in to comment.