Giter Club home page Giter Club logo

libraries's Introduction

This project is not maintained anymore. Please find the libraries in their respective repository.

Kotools

Kotlin Kotools Assert Kotools CSV Kotools Types

This project contains a set of libraries providing tools for expressive programming in Kotlin.

Libraries

Kotools Types

Versions 1, 2 and 3 are not maintained anymore. Please find the new one in this repository.

Kotools Types provides explicit types like NonZeroInt or NotBlankString for the following platforms: JVM, JS, Linux x64, macOS x64 and Windows x64.

import kotools.types.number.StrictlyPositiveInt
import kotools.types.number.toStrictlyPositiveInt
import kotools.types.text.NotBlankString
import kotools.types.text.toNotBlankString

data class Person(val name: NotBlankString, val age: StrictlyPositiveInt)

fun main() {
    val name: NotBlankString = "Somebody".toNotBlankString()
        .getOrThrow()
    val age: StrictlyPositiveInt = 42.toStrictlyPositiveInt()
        .getOrThrow()
    val somebody = Person(name, age)
    println(somebody) // Person(name=Somebody, age=42)
}

Kotools CSV

Kotools CSV is a JVM library for managing CSV files an expressive DSL.

data class Person(val name: String, val age: Int, val isAdmin: Boolean = false)

suspend fun main() {
    csvWriter<Person> {
        file = "people"
        records { +Person("Nobody", 25) }
    }
    val people: List<Person> = csvReader { file = "people" }
    println(people)
}

Kotools Assert

Kotools Assert provides additional assertions for the following platforms: JVM, JS, Linux x64, macOS x64 and Windows x64.

1 assertEquals 1
2 assertNotEquals 0

assertNull { null }
null.assertNull()

assertNotNull { 3 }
3.assertNotNull()

assertPass { println("Hello") }
assertFails { throw Exception() }
assertFailsWith<RuntimeException> { throw RuntimeException() }

Installation

Gradle

Kotlin DSL

implementation("io.github.kotools:csv:2.2.1")
implementation("io.github.kotools:types:3.2.0")
testImplementation("io.github.kotools:assert:3.0.2")

Groovy DSL

implementation "io.github.kotools:csv:2.2.1"
implementation "io.github.kotools:types:3.2.0"
testImplementation "io.github.kotools:assert:3.0.2"

Maven

<dependencies>
    <dependency>
        <groupId>io.github.kotools</groupId>
        <artifactId>csv</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>io.github.kotools</groupId>
        <artifactId>types</artifactId>
        <version>3.2.0</version>
    </dependency>
    <dependency>
        <groupId>io.github.kotools</groupId>
        <artifactId>assert</artifactId>
        <version>3.0.2</version>
        <scope>test</scope>
    </dependency>
</dependencies>

Documentation

Latest documentation of those libraries is available here.

Contributing

Feel free to contribute to this project with issues and pull requests.

This project follows the Conventional Commits guidelines for committing with Git. Please read the specifications before committing to this project.

License

All libraries are licensed under the MIT License.

libraries's People

Contributors

lvmvrquxl avatar

libraries's Issues

Release Assert v3.1.0

Dependencies

Issues of this new version should be done before resolving this issue.

Checklist

  • Upgrade the application's version.
  • Add a new version in changelog.
  • Create a release on the repository.

Libraries relocation

Description

Relocate the different libraries from io.github.kotools group to a new org.kotools group.

Checklist

  • Implement.
  • Test.
  • Refactor.
  • Update Work in progress section in changelog.

Kotlin 1.6.21 - CSV

Description

Migrate to Kotlin Kotlin 1.6.21.

Checklist

  • #38.
  • Test.
  • Refactor.
  • Update badge in the README file.
  • Update Work in progress section in changelog.

New `assertNotEquals` function variant

Description

Create a new T.assertNotEquals(block: () -> T) function asserting that this value is not equal to the result of calling the block function.

Checklist

  • Implement.
  • Test.
  • Refactor.
  • Update Work in progress section in changelog.

`IntRange` creation from `AnyInt`

Description

Users should be able to create an IntRange using the rangeTo or rangeUntil functions from the following combinations:

  • Int and AnyInt
  • AnyInt and Int.

Checklist

  • Implement.
  • Test.
  • Refactor.
  • Update Work in progress section in changelog.

CSV path extensions

Description

Implement a csv extension property/function returning the path of the file represented by the given string.
Here's an example (needs improvments):

data class CsvPath(val value: String)

val String.csv: CsvPath get() = takeIf { it.endsWith(".csv") }
	?.let(::CsvPath)
    ?: CsvPath("$this.csv")

fun main(): Unit = println("file-name".csv) // CsvPath(value=file-name.csv)

Checklist

  • Implement the extensions on NotBlankString.
  • Refactor code.
  • Update Work in progress section in changelog.

Typeful reader API

Description

Based on #14, introduce a new reader API in the kotools.csv package for reading CSV files and deprecate the old one in the io.github.kotools.csv package.

Declarations in kotools.csv should use explicit types from Kotools Types for having a typeful design.

Dependencies

This issue needs the following ones to be done:

Checklist

  • Implement and test a basic reader API.
  • Improve the reader for filtering returned records.
  • Improve the reader for paginating returned records.
  • Improve the reader for returning a custom type.
  • Deprecate the old reader.
  • Refactor.
  • Update Work in progress section in changelog.

Dependency caching

Description

Update the different workflows for speeding up their execution by caching dependencies (see the documentation).

Checklist

  • Update the Assert integration and delivery workflow.
  • Update the CSV integration and delivery workflow.
  • Update the Types integration and delivery workflow.
  • Update the deployment workflow.

Centralize versioning management

Description

Centralize the versioning management of components by creating a shared multiplatform module.

Checklist

  • Create module.
  • Add SinceKotools annotation.

DSL for `NotBlankString`

Description

Create a new DSL for building an instance of NotBlankString.

Should be introduced as an alpha feature!

Checklist

  • Implement.
  • Test.
  • Refactor.
  • Update Work in progress section in changelog.

`NotBlankString` members as extensions

Description

The problem

Extending the NotBlankString type with an operator like plus is impossible because this operator is shadowed by its function member plus(Any?).

The solution

Declare the operators of the NotBlankString type as extension functions for allowing to extend it with new operators.

Code example

import kotools.types.NotBlankString

val csvExtension = FileExtension.Csv

sealed class FileExtension(private val value: NotBlankString) {
    fun toNotBlankString(): NotBlankString = toString()
    	.toNotBlankString()

    override fun toString(): String = ".$value"
    
    object Csv : FileExtension("csv".toNotBlankString())
}

// This function is shadowed by the NotBlankString.plus(Any?) function.
/** Returns this string suffixed by the [extension]. */
operator fun NotBlankString.plus(extension: FileExtension): NotBlankString = TODO()

fun main(): Unit = println(NotBlankString("file") + csvExtension) // file.csv

Checklist

  • Convert query operations members to extensions.
  • Convert positional access operations to extensions.
  • Convert binary operations to extensions.
  • Test.
  • Refactor.
  • Update Work in progress section in changelog.

Release CSV v2.0.2

Dependencies

Issues of this new version should be done before resolving this issue.

Checklist

  • Upgrade the application's version.
  • Add a new version in changelog.
  • Create a release on the repository.

Release CSV v2.3.0

Dependencies

Issues of this new version should be done before resolving this issue.

Checklist

  • Upgrade the application's version.
  • Add a new version in changelog.
  • Create a release on the repository.

Release CSV v2.1.2

Dependencies

Issues of this new version should be done before resolving this issue.

Checklist

  • Upgrade the application's version.
  • Add a new version in changelog.
  • Create a release on the repository.

Extension functions for `Pair`

Description

Introduce useful extensions for manipulating the Pair type.

May be introduced as an alpha feature...

Checklist

  • Implement.
  • Test.
  • Refactor.
  • Update Work in progress section in changelog.

Filter and pagination ordering

Description

We should apply the filter before the pagination.

This bug was introduced in v2.1.1 and its fix should be included in the v2.1.2 and the v2.2.1!

Checklist

  • Fix.
  • Update Work in progress section in changelog.
  • Include this fix in Kotools CSV v2.1.2.
  • Include this fix in Kotools CSV v2.2.1.

Missing `csvWriterAsync` function

Description

Implement the missing csvWriterAsync function in the io.github.kotools.csv package (see the following screenshot).

This is a regression from v2.0 of this library because this function was present on v1.0.
This issue should fix the following versions : v2.0, v2.1 and v2.2.

image

Checklist

  • Fix.
  • Include this fix in Kotools CSV v2.0.2.
  • Include this fix in Kotools CSV v2.1.2.
  • Include this fix in Kotools CSV v2.2.1.
  • Update Work in progress section in changelog.

Required `file` property

Description

Change the design of DSL for forcing users to define a file property instead of setting it in the builder. This allows to check the requirements in compile time instead of runtime.
Here's an example of what a user should do:

data class Person(val name: String, val age: Int, val isAdmin: Boolean = false)

suspend fun main() {
    csvWriter<Person>(file = "people") {
        records { +Person("Nobody", 25) }
    }
    val people: List<Person> = csvReader(file = "people")
    println(people)
}

This is a breaking change! ๐Ÿ”ฅ

Checklist

  • Implement.
  • Test.
  • Refactor.
  • Update Work in progress section in changelog.

New DSL for numbers

Description

Introduce a new experimental DSL for building a holder from a number.

Checklist

  • Implement.
  • Test.
  • Refactor.
  • Update Work in progress section in changelog.

Release CSV v2.2.1

Dependencies

Issues of this new version should be done before resolving this issue.

Checklist

  • Upgrade the application's version.
  • Add a new version in changelog by indicating that this is a release containing fixes from v2.0.2 and v2.1.2.
  • Create a release on the repository.

Typeful design of the API

Description

Migrate the API to a typeful design by using the types provided by the Kotools Types library.

This is a breaking change! ๐Ÿ”ฅ
This new API should be introduced in the kotools.csv package.

Checklist

  • Implement.
  • Test.
  • Refactor.
  • Update Work in progress section in changelog.

Deprecations from v3

Description

Remove deprecated declarations from Kotools Types v3.

Checklist

  • Remove deprecated declarations.
  • Test.
  • Update Work in progress section in changelog.

Explicit versions in workflows

Description

Use actions with explicit versions in workflows.

Checklist

  • Update the Assert integration and delivery workflow.
  • Update the CSV integration and delivery workflow.
  • Update the Types integration and delivery workflow.
  • Update the deployment workflow.

Typeful writer API

Description

Based on #14, introduce a new writer API in the kotools.csv package for writing records in CSV files and deprecate the old one in the io.github.kotools.csv package.

Declarations in kotools.csv should use explicit types from Kotools Types for having a typeful design.

Dependencies

This issue needs the following ones to be done:

Checklist

  • Implement and test a basic writer API.
  • Improve the writer for accepting custom types as records.
  • Deprecate the old writer.
  • Refactor.
  • Update Work in progress section in changelog.

New random API for integers

Description

Implement a new random API that should have the following name pattern: randomType() where Type is an explicit type.
Here is an example:

val x: NonZeroInt = randomNonZeroInt()

Deprecate the old API.

Checklist

  • Implement it for the NonZeroInt type.
  • Implement it for the PositiveInt type.
  • Implement it for the StrictlyPositiveInt type.
  • Implement it for the NegativeInt type.
  • Implement it for the StrictlyNegativeInt type.
  • Refactor code.
  • Update Work in progress section in changelog.

Explicit DSL for numbers

Description

Introduce a new DSL with explicit builders for numbers.

Replace the IntHolderDsl type by a new IntBuilder type representing the context for building an IntHolder type.
This new DSL should be introduced as an alpha feature.

Checklist

  • Create the IntBuilder type.
  • Create the NonZeroBuilder type.
  • Create the PositiveBuilder type.
  • Create the StrictlyPositiveBuilder type.
  • Create the NegativeBuilder type.
  • Create the StrictlyNegativeBuilder type.
  • Remove the IntHolderDsl type.
  • Refactor.
  • Update Work in progress section in changelog.

Qodana

Description

Integrate Qodana in the CI workflow for analyzing the code quality of the library.

Checklist

  • Implement.
  • Test.

Release Types v3.2.0

Dependencies

Issues of this new version should be done before resolving this issue.

Checklist

  • Upgrade the application's version.
  • Add a new version in changelog.
  • Create a release on the repository.

Unseal the `NotBlankString` interface

Description

The problem

Extending the NotBlankString type is impossible by inheriting because of it's a sealed interface.

The solution

Unseal the NotBlankString type for allowing inheriting from it.

Code example

import kotools.types.NotBlankString

class Title(value: String) : NotBlankString by value.toNotBlankString()

fun main(): Unit = println(Title("Hello World")) // Hello World

Dependencies

  • Because the NotBlankString type will be open for extension by inheriting but closed for modification, its final operations should be provided as extensions (see #48).

Checklist

  • Implement.
  • Test.
  • Refactor.
  • Update Work in progress section in changelog.

Numbers DSL deprecation

Description

Deprecate the DSL for building numbers in the kotools.types.number package.

Checklist

  • Deprecate the DSL.
  • Test.
  • Refactor.
  • Update Work in progress section in changelog.

Kotlin 1.6.21

Description

Migrate incrementally to Kotlin 1.6.21.

All libraries will be impacted by this change!

Checklist

  • Migrate to Kotlin 1.5.32.
  • Migrate to Kotlin 1.6.0.
  • Migrate to Kotlin 1.6.10.
  • Migrate to Kotlin 1.6.20.
  • Migrate to Kotlin 1.6.21.
  • Update Kotlin badge in the README.

Workflow improvements

Description

Improve the integration & delivery workflow and the deployment workflow by splitting jobs for each platforms.
For example, in the integration & delivery workflow, we should have a job for integrating changes targetting the JVM platform, then another job for integrating changes targetting the JS platform...

Checklist

  • Improve the integration & delivery workflow.

Explicit builders for all types

Description

Deprecate some builders in favor of new explicit ones for all types in Kotools Types.
Builders should follow this pattern:

fun <T> typeOrNull(value: Any): T? = TODO() // should return `null` if the value is invalid
fun <T> typeOrThrow(value: Any): T = TODO() // should throw an error if the value is invalid

Checklist

  • Implement for NonZeroInt.
  • Implement for PositiveInt.
  • Implement for StrictlyPositiveInt.
  • Implement for NegativeInt.
  • Implement for StrictlyNegativeInt.
  • Implement for NotBlankString.
  • Implement for NotEmptyList.
  • Implement for NotEmptySet.
  • Implement for NotEmptyMap.
  • Refactor.
  • Update Work in progress section in changelog.

Internal code to functional programming

Description

Make the internal code mode functional (the target is functional programming, and not only functional style).

Checklist

  • Refactor tests.
  • Refactor implementations.

New `assertEquals` function variant

Description

Create a new T.assertEquals(block: () -> T) function asserting that this value equals the result of calling the block function.

Checklist

  • Implement.
  • Test.
  • Refactor.
  • Update Work in progress section in changelog.

Typeful API in `kotools.csv`

Description

Create a package kotools.csv containing all declarations of the package io.github.kotools.csv.
Then, deprecate all declarations of the old package.

Declarations in kotools.csv should use explicit types from Kotools Types for having a typeful design.

Also, the file property should be required in this new API for avoiding runtime checks in favor of compile-time checks.
Here is an exemple using the old API:

data class Person(val name: NotBlankString, val age: StrictlyPositiveInt, val isAdmin: Boolean = false)

suspend fun main() {
    csvWriter<Person>(file = "people".toNotBlankString()) {
        records { +Person("Nobody".toNotBlankString(), 25.toStrictlyPositiveInt()) }
    }
    val people: List<Person> = csvReader(file = "people".toNotBlankString())
    println(people)
}

Checklist

  • Implement a basic CSV reader.
  • Implement a reader that returns a custom type.
  • Deprecate the old reader.
  • Implement a basic CSV writer.
  • Implement a writer that takes a custom type.
  • Deprecate the old writer.
  • Update Work in progress section in changelog.

`SinceKotoolsCsv` annotation

Description

Implement a new SinceKotoolsCsv annotation for documenting the version and the stability of a declaration.

Checklist

  • Create the annotation.
  • Apply it on every declaration.

Explicit dependency versions

Description

Use explicit dependency version instead of ranges in Gradle build scripts.

Checklist

  • Set explicit dependency versions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.