Skip to content

Commit

Permalink
Merge pull request #15 from fleeksoft/develop
Browse files Browse the repository at this point in the history
Release 0.1.0
  • Loading branch information
itboy87 authored Dec 8, 2023
2 parents 4afd7d2 + 465234c commit 911a3cf
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 19 deletions.
37 changes: 37 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Contributing Guidelines

You can contribute to this project by reporting issues or submitting changes via a pull request.

## Reporting issues

For filing feature requests and bug reports, please use our [GitHub issues](https://github.com/fleeksoft/ksoup/issues).

For questions about usage and general inquiries, consider asking on StackOverflow or participating in
our [GitHub Discussions](https://github.com/fleeksoft/ksoup/discussions).

## Submitting changes

To submit pull requests, please visit [this page](https://github.com/fleeksoft/ksoup/pulls).
Keep in mind that maintainers will have to support the code resulting from your contribution. Therefore, please
familiarize yourself with the following guidelines:

* All development (both new features and bug fixes) should be performed in the `develop` branch.
* The `master` branch hosts the sources of the most recently released version.
* Base your pull requests against the `develop` branch.
* The `develop` branch is merged into the `master` branch during releases.
* Ensure to [Build the project](#building) to verify that everything works and passes the tests.
* If you are fixing a bug:
* Write the test that reproduces the bug.
* Fixes without tests are accepted only under exceptional circumstances, such as when writing a corresponding test
is too hard or impractical.
* Follow the project's style for writing tests: name test functions as testXxx. Avoid using backticks in test names.
* If you wish to work on an existing issue, comment on it first. Ensure that the issue clearly describes a problem and a
solution that has received positive feedback. Propose a solution if none is suggested.

## Building

This library is built with Gradle.

* Run `./gradlew build` to build the entire project. It also runs all the tests.
* Run `./gradlew <module>:check` to test only the module you are working on.
* Run `./gradlew <module>:jvmTest` to perform only the fast JVM tests of a multiplatform module.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ Ksoup is an open source project, a Kotlin Multiplatform port of jsoup, distribut


## Development and Support
For questions, ideas, or contributions regarding Ksoup, please contact us via [email](mailto:fleeksoft@gmail.com) or create new pull requests.
For questions about usage and general inquiries, please refer to [GitHub Discussions](https://github.com/fleeksoft/ksoup/discussions).

Report any issues on [our GitHub page](https://github.com/fleeksoft/ksoup/issues), ensuring to check for duplicates beforehand.
If you wish to contribute, please read the [Contributing Guidelines](CONTRIBUTING.md).

To report any issues, visit our [GitHub issues](https://github.com/fleeksoft/ksoup/issues), Please ensure to check for duplicates before submitting a new issue.

## Library Status

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ agp = "8.1.3"
kotlin = "1.9.21"
compileSdk = "34"
minSdk = "21"
libraryVersion = "0.0.9"
libraryVersion = "0.1.0"
junitJupiter = "5.10.0"
compose = "1.5.4"
compose-compiler = "1.5.4"
Expand Down
1 change: 1 addition & 0 deletions ksoup-network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ publishing {
developer {
name.set("Sabeeh Ul Hussnain")
email.set("[email protected]")
organization.set("Fleek Soft")
}
}
}
Expand Down
38 changes: 34 additions & 4 deletions ksoup/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ plugins {
group = "com.fleeksoft.ksoup"
version = libs.versions.libraryVersion.get()

val rootPath = "generated/kotlin"

kotlin {
explicitApi()

Expand Down Expand Up @@ -51,10 +53,13 @@ kotlin {
implementation(libs.codepoints)
api(libs.okio)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
implementation(libs.gson)
implementation(projects.ksoupNetwork)
commonTest {
this.kotlin.srcDir(layout.buildDirectory.file(rootPath))
dependencies {
implementation(libs.kotlin.test)
implementation(libs.gson)
implementation(projects.ksoupNetwork)
}
}

jvmMain.dependencies {
Expand Down Expand Up @@ -153,6 +158,7 @@ publishing {
developer {
name.set("Sabeeh Ul Hussnain")
email.set("[email protected]")
organization.set("Fleek Soft")
}
}
}
Expand All @@ -173,3 +179,27 @@ signing {
project.tasks.withType(AbstractPublishToMaven::class.java).configureEach {
dependsOn(project.tasks.withType(Sign::class.java))
}

val generateRootPathSource: Task by tasks.creating {
group = "build setup"
val file = layout.buildDirectory.file("$rootPath/BuildConfig.kt")
outputs.file(file)

doLast {
val content =
"""
package com.fleeksoft.ksoup
object BuildConfig {
const val PROJECT_ROOT: String = "${rootProject.rootDir.absolutePath.replace("\\", "\\\\")}"
}
""".trimIndent()
file.get().asFile.writeText(content)
}
}

tasks.all {
if (name != "generateRootPathSource") {
dependsOn("generateRootPathSource")
}
}
3 changes: 2 additions & 1 deletion ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/GzipTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class GzipTest {
@Test
fun testReadGzipFile() {
val gzipFileStr =
readGzipFile(TestHelper.getResourceAbsolutePath("htmltests/gzip.html.gz").toPath()).readByteString().utf8()
readGzipFile(TestHelper.getResourceAbsolutePath("htmltests/gzip.html.gz").toPath())
.readByteString().utf8()
val expected = """<title>Gzip test</title>
<p>This is a gzipped HTML file.</p>
Expand Down
23 changes: 15 additions & 8 deletions ksoup/src/commonTest/kotlin/com/fleeksoft/ksoup/TestHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ import okio.Path.Companion.toPath

object TestHelper {
fun getResourceAbsolutePath(resourceName: String): String {
// return "/Users/sabeeh/AndroidStudioProjects/ksoup/ksoup/src/commonTest/resources/$resourceName"
val rootPath =
if (Platform.current == PlatformType.IOS) {
"/Users/runner/work/ksoup/ksoup/ksoup"
} else {
"/home/runner/work/ksoup/ksoup/ksoup"
return "${BuildConfig.PROJECT_ROOT}/ksoup/src/commonTest/resources/$resourceName"
/*return when (Platform.current) {
PlatformType.JVM, PlatformType.ANDROID -> {
"src/commonTest/resources/$resourceName"
}
PlatformType.JS -> {
"../../../../ksoup/src/commonTest/resources/$resourceName"
}
return "$rootPath/src/commonTest/resources/$resourceName"
// return "../ksoup/src/commonTest/resources/$resourceName"
PlatformType.IOS -> {
"/Users/runner/work/ksoup/ksoup/ksoup/src/commonTest/resources/$resourceName"
}
else -> "src/commonTest/resources/$resourceName"
}*/
}

fun getFileAsString(file: Path): String {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.fleeksoft.ksoup.parser

import com.fleeksoft.ksoup.Platform
import com.fleeksoft.ksoup.PlatformType
import com.fleeksoft.ksoup.ported.System
import kotlin.test.Ignore
import kotlin.test.Test
Expand Down Expand Up @@ -27,6 +29,10 @@ class ParserIT {

@Test
fun handlesDeepStack() {
if (Platform.current == PlatformType.IOS) {
// The GitHub action is taking too much time.
return
}
// inspired by http://sv.stargate.wikia.com/wiki/M2J and https://github.com/jhy/jsoup/issues/955
// I didn't put it in the integration tests, because explorer and intellij kept dieing trying to preview/index it

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DataUtilTestJvm {
}

@Test
fun parseSequenceBufferReader() {
fun testParseSequenceBufferReader() {
// https://github.com/jhy/jsoup/pull/1671
val bufferReader: BufferReader = TestHelper.resourceFilePathToBufferReader("htmltests/medium.html")
val fileContent = String(bufferReader.readByteArray())
Expand Down Expand Up @@ -52,7 +52,7 @@ class DataUtilTestJvm {
}

@Test
fun handlesChunkedInputStream() {
fun testHandlesChunkedInputStream() {
val file = File(TestHelper.getResourceAbsolutePath("htmltests/large.html"))
val input = getFileAsString(file)
val expected =
Expand Down Expand Up @@ -80,7 +80,7 @@ class DataUtilTestJvm {
}

@Test
fun handlesUnlimitedRead() {
fun testHandlesUnlimitedRead() {
val file = File(TestHelper.getResourceAbsolutePath("htmltests/large.html"))
val input: String = getFileAsString(file)

Expand Down

0 comments on commit 911a3cf

Please sign in to comment.