Skip to content

Commit

Permalink
Merge pull request #8 from darkredz/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
darkredz committed Apr 5, 2020
2 parents 3ccdc3e + 31616b7 commit 588770f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 49 deletions.
58 changes: 48 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@

<groupId>com.github.darkredz</groupId>
<artifactId>zeko-data-mapper</artifactId>
<version>1.5.1-SNAPSHOT</version>
<version>1.5.10-SNAPSHOT</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
<description>
A lightweight, fast and simple data mapper library in Kotlin that
helps to map the result of queries from your normalized dataset(from RDBMS, SQLite, CSV or any source)
back into relational mapped Hash maps
</description>
<url>https://github.com/darkredz/Zeko-Data-Mapper</url>

<!-- License for the project, pick a License from opensource.org -->
Expand Down Expand Up @@ -37,7 +42,7 @@
<connection>scm:git:https://github.com/darkredz/Zeko-Data-Mapper.git</connection>
<developerConnection>scm:git:ssh://github.com/darkredz/Zeko-Data-Mapper.git</developerConnection>
<url>https://github.com/darkredz/Zeko-Data-Mapper</url>
<tag>HEAD</tag>
<tag>1.5.8</tag>
</scm>

<distributionManagement>
Expand Down Expand Up @@ -67,6 +72,14 @@
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>jcenter</id>
<name>JCenter</name>
<url>https://jcenter.bintray.com/</url>
</pluginRepository>
</pluginRepositories>

<properties>
<kotlin.version>1.3.60</kotlin.version>
<vertx.version>3.8.5</vertx.version>
Expand Down Expand Up @@ -122,11 +135,6 @@
<artifactId>vertx-core</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>com.caucho</groupId>
<artifactId>quercus</artifactId>
<version>4.0.45</version>
</dependency>
<dependency>
<groupId>com.github.jasync-sql</groupId>
<artifactId>jasync-common</artifactId>
Expand Down Expand Up @@ -197,6 +205,16 @@
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>

<resources>
<resource>
<directory>${project.basedir}</directory>
<excludes>
<exclude>docs</exclude>
<exclude>examples</exclude>
</excludes>
</resource>
</resources>

<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down Expand Up @@ -279,6 +297,11 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${version.maven-source-plugin}</version>
<configuration>
<excludes>
<exclude>**/*.jar</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -304,6 +327,24 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>0.10.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>javadocJar</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceDirectories>
<dir>src/main/kotlin</dir>
</sourceDirectories>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>${version.maven-deploy-plugin}</version>
Expand Down Expand Up @@ -333,9 +374,6 @@
<artifactId>maven-release-plugin</artifactId>
<version>${version.maven-release-plugin}</version>
<configuration>
<checkModificationExcludes>
<checkModificationExclude>pom.xml</checkModificationExclude>
</checkModificationExcludes>
<localCheckout>true</localCheckout>
<pushChanges>false</pushChanges>
<mavenExecutorId>forked-path</mavenExecutorId>
Expand Down
12 changes: 0 additions & 12 deletions src/main/kotlin/io/zeko/model/DataHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,12 @@

package io.zeko.model

import com.caucho.quercus.env.ArrayValue
import com.caucho.quercus.env.ArrayValueImpl
import com.caucho.quercus.env.Env
import io.vertx.core.json.JsonArray
import io.vertx.core.json.JsonObject
import java.util.LinkedHashMap

class DataHelper {

companion object {
fun toPhpArray(env: Env, rs: List<LinkedHashMap<String, Any>>): ArrayValue {
val arr = ArrayValueImpl()
for (map in rs) {
arr.append(env.wrapJava(map))
}
return arr
}

fun toJsonArray(rs: List<LinkedHashMap<String, Any>>): JsonArray {
val arr = JsonArray()
for (map in rs) {
Expand Down
27 changes: 0 additions & 27 deletions src/test/kotlin/io/zeko/model/DataHelperSpec.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package io.zeko.model

import com.caucho.quercus.env.Env
import com.caucho.quercus.QuercusContext
import com.caucho.quercus.env.ArrayValue
import java.util.LinkedHashMap
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
Expand Down Expand Up @@ -43,29 +40,5 @@ class DataHelperSpec : Spek({
assertEquals(856.87, result.getJsonObject(0).getDouble("credit"))
}
}

context("convert result to PHP array") {
val quercusContext = QuercusContext()
val env = Env(quercusContext)
val result = DataHelper.toPhpArray(env, all)

it("should not be null") {
assertEquals(false, result == null)
}
it("should not be empty") {
assertEquals(false, result.isEmpty)
}
it("should have 2 element") {
assertEquals(2, result.size, "Got " + result.size)
}
it("and should object with field id, name, age") {
val obj = result.get(0) as ArrayValue
val map = obj.toJavaMap(env, HashMap::class.java)
assertEquals(123, map.get("id"))
assertEquals("Leng", map.get("name"))
assertEquals(12, map.get("age"))
assertEquals(856.87, map.get("credit"))
}
}
}
})

0 comments on commit 588770f

Please sign in to comment.