diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 26d3352..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index e310056..7d0d0ad 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -2,22 +2,18 @@
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/.idea/copyright/Erik_s_Copyright_Notice.xml b/.idea/copyright/Erik_s_Copyright_Notice.xml
new file mode 100644
index 0000000..df1b749
--- /dev/null
+++ b/.idea/copyright/Erik_s_Copyright_Notice.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..1419e40
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index f243f08..562d6ca 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -30,7 +30,14 @@
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 46f5ce8..cfd3ca8 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -1,21 +1,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -27,9 +12,14 @@
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/kotlinScripting.xml b/.idea/kotlinScripting.xml
deleted file mode 100644
index bc444de..0000000
--- a/.idea/kotlinScripting.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml
deleted file mode 100644
index 9fa3156..0000000
--- a/.idea/libraries-with-intellij-classes.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 65b80ca..cbfe0de 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,16 +1,5 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/LICENSE.txt b/LICENSE.txt
index bab61e8..ab5f3ce 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2021, Erik C. Thauvin (erik@thauvin.net)
+Copyright (c) 2021-2022, Erik C. Thauvin (erik@thauvin.net)
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/build.gradle.kts b/build.gradle.kts
index 008cf81..0b183a6 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,19 +1,21 @@
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
+
plugins {
id("application")
- id("com.github.ben-manes.versions") version "0.39.0"
- id("io.gitlab.arturbosch.detekt") version "1.19.0-RC1"
+ id("com.github.ben-manes.versions") version "0.40.0"
+ id("io.gitlab.arturbosch.detekt") version "1.19.0"
id("java")
id("maven-publish")
- id("org.jetbrains.dokka") version "1.5.31"
- id("org.jetbrains.kotlinx.kover") version "0.4.2"
+ id("org.jetbrains.dokka") version "1.6.10"
+ id("org.jetbrains.kotlinx.kover") version "0.4.4"
id("org.sonarqube") version "3.3"
id("signing")
- kotlin("jvm") version "1.6.0"
+ kotlin("jvm") version "1.6.10"
}
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
@@ -27,6 +29,13 @@ val gitHub = "ethauvin/$name"
val mavenUrl = "https://github.com/$gitHub"
val publicationName = "mavenJava"
+fun isNonStable(version: String): Boolean {
+ val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
+ val regex = "^[0-9,.v-]+(-r)?$".toRegex()
+ val isStable = stableKeyword || regex.matches(version)
+ return isStable.not()
+}
+
repositories {
mavenCentral()
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
@@ -36,8 +45,8 @@ dependencies {
implementation(platform(kotlin("bom")))
implementation(kotlin("stdlib-jdk8"))
- implementation("com.squareup.okhttp3:okhttp:4.9.1")
- implementation("org.json:json:20210307")
+ implementation("com.squareup.okhttp3:okhttp:4.9.3")
+ implementation("org.json:json:20211205")
testImplementation(kotlin("test"))
}
@@ -63,7 +72,6 @@ sonarqube {
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.sourceEncoding", "UTF-8")
property("sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/kover/report.xml")
-
}
}
@@ -78,6 +86,12 @@ tasks {
args = listOf("BTC","ETH","LTC")
}
+ withType {
+ rejectVersionIf {
+ isNonStable(candidate.version)
+ }
+ }
+
withType().configureEach {
kotlinOptions.jvmTarget = java.targetCompatibility.toString()
}
diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts
index 18c85ce..d0439f0 100644
--- a/examples/build.gradle.kts
+++ b/examples/build.gradle.kts
@@ -2,8 +2,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("application")
- id("com.github.ben-manes.versions") version "0.39.0"
- kotlin("jvm") version "1.6.0"
+ id("com.github.ben-manes.versions") version "0.40.0"
+ kotlin("jvm") version "1.6.10"
}
// ./gradlew run
diff --git a/examples/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/wrapper/gradle-wrapper.properties
index e750102..2e6e589 100644
--- a/examples/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index e750102..2e6e589 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/pom.xml b/pom.xml
index e2c4f1d..ae483a1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,7 +40,7 @@
org.jetbrains.kotlinkotlin-bom
- 1.5.31
+ 1.6.10pomimport
@@ -50,19 +50,19 @@
org.jetbrains.kotlinkotlin-stdlib-jdk8
- 1.5.31
+ 1.6.10runtimecom.squareup.okhttp3okhttp
- 4.9.1
+ 4.9.3runtimeorg.jsonjson
- 20210307
+ 20211205runtime
diff --git a/src/main/kotlin/net/thauvin/erik/crypto/CryptoException.kt b/src/main/kotlin/net/thauvin/erik/crypto/CryptoException.kt
index 583c872..b5303df 100644
--- a/src/main/kotlin/net/thauvin/erik/crypto/CryptoException.kt
+++ b/src/main/kotlin/net/thauvin/erik/crypto/CryptoException.kt
@@ -1,7 +1,7 @@
/*
* CryptoException.kt
*
- * Copyright (c) 2021, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2021-2022, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/main/kotlin/net/thauvin/erik/crypto/CryptoPrice.kt b/src/main/kotlin/net/thauvin/erik/crypto/CryptoPrice.kt
index 399c8fa..7ba8c8c 100644
--- a/src/main/kotlin/net/thauvin/erik/crypto/CryptoPrice.kt
+++ b/src/main/kotlin/net/thauvin/erik/crypto/CryptoPrice.kt
@@ -1,7 +1,7 @@
/*
* CryptoPrice.kt
*
- * Copyright (c) 2021, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2021-2022, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/kotlin/net/thauvin/erik/crypto/CryptoPriceTest.kt b/src/test/kotlin/net/thauvin/erik/crypto/CryptoPriceTest.kt
index d85318a..6d7d95b 100644
--- a/src/test/kotlin/net/thauvin/erik/crypto/CryptoPriceTest.kt
+++ b/src/test/kotlin/net/thauvin/erik/crypto/CryptoPriceTest.kt
@@ -1,8 +1,41 @@
+/*
+ * CryptoPriceTest.kt
+ *
+ * Copyright (c) 2021-2022, Erik C. Thauvin (erik@thauvin.net)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of this project nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
package net.thauvin.erik.crypto
import net.thauvin.erik.crypto.CryptoPrice.Companion.apiCall
import net.thauvin.erik.crypto.CryptoPrice.Companion.spotPrice
import net.thauvin.erik.crypto.CryptoPrice.Companion.toPrice
+import org.json.JSONObject
import java.time.LocalDate
import java.util.Locale
import kotlin.test.Test
@@ -61,6 +94,10 @@ class CryptoPriceTest {
assertEquals("BTC", price.base, "buy BTC")
assertEquals("USD", price.currency, "buy BTC is USD")
assertTrue(price.amount.signum() > 0, "buy BTC > 0")
+
+ val response = apiCall(listOf("exchange-rates"), mapOf("currency" to "usd"))
+ val rates = JSONObject(response).getJSONObject("data").getJSONObject("rates")
+ assertEquals("1.0", rates.getString("USD"), "usd rate")
}
@Test
@@ -81,7 +118,7 @@ class CryptoPriceTest {
try {
spotPrice("FOOBAR")
} catch (e: CryptoException) {
- assertTrue(e.statusCode != 400, "FOOBAR status code is not 400")
+ assertNotEquals(400, e.statusCode, "FOOBAR status code is not 400")
}
}