{"id":13482554,"url":"https://github.com/vsfedorenko/kotidgy","last_synced_at":"2025-03-27T13:32:12.437Z","repository":{"id":84711065,"uuid":"160176578","full_name":"vsfedorenko/kotidgy","owner":"vsfedorenko","description":"Kotidgy aka \"Kotlin Text Indexed Data Generator\" is an index-based text data generator written in Kotlin","archived":false,"fork":false,"pushed_at":"2018-12-05T00:56:16.000Z","size":102,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-22T12:12:14.638Z","etag":null,"topics":["bash","data-generator","kotlin","library","text-generator"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vsfedorenko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md"}},"created_at":"2018-12-03T10:53:11.000Z","updated_at":"2022-01-25T00:08:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"8fc06470-e751-4a8d-bf39-ecef32a7ba46","html_url":"https://github.com/vsfedorenko/kotidgy","commit_stats":null,"previous_names":["vsfedorenko/kotidgy"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsfedorenko%2Fkotidgy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsfedorenko%2Fkotidgy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsfedorenko%2Fkotidgy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsfedorenko%2Fkotidgy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vsfedorenko","download_url":"https://codeload.github.com/vsfedorenko/kotidgy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":212674793,"owners_count":15476273,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","data-generator","kotlin","library","text-generator"],"created_at":"2024-07-31T17:01:03.194Z","updated_at":"2024-07-31T17:08:57.306Z","avatar_url":"https://github.com/vsfedorenko.png","language":"Kotlin","funding_links":[],"categories":["函式庫"],"sub_categories":["書籍"],"readme":"Kotidgy\n===\n[![Build Status](https://travis-ci.org/meiblorn/kotidgy.svg?branch=master)](https://travis-ci.org/meiblorn/kotidgy)\n\nKotidgy _aka_ \"**Ko**tlin **T**ext **I**ndexed **D**ata **G**enerator\" \nis an index-based text data generator written in [Kotlin](http://kotlinlang.org).\n\nWrite **this**\n```kotlin\nkotidgy {\n    templates {\n          t { +\"Hello\" }\n          t { +\"Hi\" / \"Aloha\" + \", man !\" }\n          t { +f { any { 2..100 } } + \" apples \" + \"on the \" + \"plate\" / \"table\" }\n          t { +f { all { 2..3 } } + \" apples \" + \"on the \" + \"plate\" / \"table\" }\n    }\n}\n```\nGet **that**\n```text\nHello\nHi, man !\nAloha, man !\n2 apples on the plate\n3 apples on the plate\n2 apples on the table\n3 apples on the table\n...\n... skipped 194 other lines\n...\n100 apples on the table\n100 apples on the table\n23 apples on the plate\n23 apples on the table\n```\n\n## Use it as a library\n\n### Declare dependency\n\n#### Maven\n\nAdd dependencies (you can also add other modules that you need):\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.meiblorn\u003c/groupId\u003e\n    \u003cartifactId\u003ekotidgy\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0.RELEASE\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n#### Gradle\n\nAdd dependencies (you can also add other modules that you need):\n\nGroovy DSL\n```groovy\ndependencies {\n    implementation 'com:meiblorn:kotidgy:1.0.0.RELEASE'\n}\n```\n\nMake sure that you have either `jcenter()` or `mavenCentral()` in the list of repositories:\n\n```\nrepository {\n    jcenter()\n}\n```\n\n#### Gradle Kotlin DSL\n\nAdd dependencies (you can also add other modules that you need):\n\n```groovy\ndependencies {\n    implementation(\"com.meiblorn:kotidgy:1.0.0.RELEASE\")\n}\n```\n\nMake sure that you have either `jcenter()` or `mavenCentral()` in the list of repositories.\n\n### Write the code\n\nKotlin example:\n```kotlin\nval engine = KotidgyEngine()\n\nval project = kotidgy {\n  templates {\n      t { +\"Hello\" }\n      t { +\"Hi\" / \"Aloha\" }\n      t { +f { 2..3 } + \" apples\" }\n  }\n}\n\nval samples = engone.generate(project)\n// Assert here is just for an illustration\nassert(samples.toList() == listOf(\n    Sample(IndexId(0), \"Hello\"),\n    Sample(IndexId(0), \"Hi\"),\n    Sample(IndexId(1), \"Aloha\"),\n    Sample(\n        IndexId(0),\n        \"2\",\n        Sample(IndexId(0), \" apples\")\n    ),\n    Sample(\n        IndexId(1),\n        \"3\",\n        Sample(IndexId(0), \" apples\")\n    )\n))\n\nfor (sample in samples) {\n    println(sample)\n}\n```\n\nOutput will be:\n```bash\nHello\nHi\nAloha\n2 apples\n3 apples\n```\n\n## Use it as a script\n\n- Provide jar directly:\n\n```bash\njava -jar \u003c%path_to%\u003e/kotidgy.jar \u003c%path_to%\u003e/examples/kotlin/script/index.kotidgy.kts\n```\n\n- Or use it via [kscript](https://github.com/holgerbrandl/kscript)\n```bash\n#!/usr/bin/env kscript\n\n// Declare dependencies\n@file:DependsOn(\"com.meiblorn:kotidgy:1.0.0.RELEASE\")\n\nimport com.meiblorn.kotidgy.dsl.*\n\nkotidgy {\n    templates {\n        t { +\"hi\" }\n        t { +\"hello\" / \"aloha\" }\n    }\n}\n``` \n\n## Use it as a docker container\n```bash\ndocker run \\\n    -v $(pwd)/examples/kotlin/script:/data \\ \n    meiblorn/kotidgy \\\n    /data/index.kotidgy.kts\n```\n\n## Kotidgy DSL \n\nProject definition:\n\n- `kotidgy` / `project` — kotidgy project definition wrappers\n  - `templates` — templates definitions wrapper\n    - `t` / `template` — template definition\n\nTemplate definition:\n- Every template must start from the `+` sign. \n  It is mandatory cast to the Kotlin [Type-Safe Builders DSL](http://kotlinlang.org/docs/reference/type-safe-builders.html#type-safe-builders).\n- Template operators:\n  - unary `+` — start of the template\n  - binary `+` — concatenation \n  - `/` — alternative operator\n  - `all` and `any` - collection/iterable wrapper operators.\n    - `any` — converts collection items to alternatives (like it is written using `/` operator: e.g. `item1 / item2 / ...`)\n    - `all` — concatenates collection items (e.g. `item1.toString() + item2.toString() + ...`)\n  - `f` or `lambda` or `call` — kotlin call operator. \n    - All return types are accepted\n    - If `call` operator returns instance of `list` or `iterable` types \n      then instance will be automatically converted to `any` collection\n    - `.toString()` is called for the object rendering.\n \n## Why Kotlin ?\n1) Kotlin is a [mature](https://en.wiktionary.org/wiki/mature) programming language\n2) Kotlin is a type safe language\n3) Kotlin has a native DSL builder support.\n4) Writing a new own programming language is a very expensive operation both in time and effort.\n5) Kotlin can do much more than own language and has less bugs.\n6) It has an amazing huge community: Java + Kotlin\n7) Kotlin can be used to write Bash scripts\n8) Native IDE support and highlighting: [Intellij Idea](https://www.jetbrains.com/idea) (it is also available for Free)\n \n## Contributing\n\nYou are welcome to contribute ! Just submit your PR and become a part of Kotidgy community!\n\nPlease read [contributing.md](contributing.md) for details on our code of conduct, and the process for submitting pull requests to us.\n\n## Versioning\n\nWe use [SemVer](http://semver.org) for versioning. For the versions available, see the [tags on this repository](https://github.com/meiblorn/kotidgy/tags). \n\n## Authors\n\n* **Vadim Fedorenko** - [Meiblorn](https://github.com/meiblorn) -*Initial work*\n\nSee also the list of [authors](authors.md) who participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n\n## Acknowledgments\n\n* Your questions will appear here. Feel free to ask me.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsfedorenko%2Fkotidgy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvsfedorenko%2Fkotidgy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsfedorenko%2Fkotidgy/lists"}