Skip to content

Commit

Permalink
Add reloadDatabase function
Browse files Browse the repository at this point in the history
  • Loading branch information
sylux6 committed Dec 8, 2019
1 parent 070b927 commit 2c3e4bb
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,12 @@ dependencies {
```
</details>

## Example

```kotlin
val atago = Atago.getShipByName("atago")
println(atago.names.en)
```

## Support server
![Discord Banner 2](https://discordapp.com/api/guilds/648206344729526272/widget.png?style=banner2)
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "com.github.AzurApi"
version = "0.1.0"
version = "1.0.0"

java {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand Down
9 changes: 9 additions & 0 deletions src/main/kotlin/com/github/azurapi/azurapikotlin/api/Atago.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,13 @@ object Atago {
fun getVersion(): Version {
return Version(AtagoInfo.VERSION, database.lastUpdated, database.databaseVersion, database.lastUpdatedDatabase)
}

/**
* @since 1.0.0
*
* Reload database from remote json
*/
fun reloadDatabase() {
database.loadDatabase()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Takao {
private lateinit var jsonDatabase: JSONObject
private lateinit var jsonVersion: JSONObject

var lastUpdated: Date
lateinit var lastUpdated: Date
lateinit var lastUpdatedDatabase: Date
lateinit var databaseVersion: String

Expand All @@ -29,7 +29,6 @@ class Takao {

init {
loadDatabase()
lastUpdated = Date()
}

private fun loadJSON(url: String): JSONObject {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.azurapi.azurapikotlin.api

import io.kotlintest.TestCase
import io.kotlintest.matchers.boolean.shouldBeTrue
import io.kotlintest.matchers.types.shouldNotBeNull
import io.kotlintest.shouldBe
import io.kotlintest.specs.StringSpec
Expand Down Expand Up @@ -39,5 +40,11 @@ class AtagoTestCase : StringSpec() {
version.lastUpdatedDatabase.shouldNotBeNull()
version.apiVersion.shouldNotBeNull()
}

"it should update database" {
val oldDate = Atago.getVersion().lastUpdatedApi
Atago.reloadDatabase()
(Atago.getVersion().lastUpdatedApi > oldDate).shouldBeTrue()
}
}
}

0 comments on commit 2c3e4bb

Please sign in to comment.