Skip to content

Commit

Permalink
update codegen formatting functions
Browse files Browse the repository at this point in the history
update gradlew to v4.7
  • Loading branch information
akolomentsev committed May 7, 2018
1 parent 454b151 commit 01670da
Show file tree
Hide file tree
Showing 16 changed files with 126 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ModelsCodeGen(val cfg: ModelsCodeGenConfig) {

for ((tname, tdef) in schema.types()) {
if (ignore.contains(tname)) continue
val className = "${cfg.classPrefix}${tname.pascal()}"
val className = "${cfg.classPrefix}${tname.pascalCase()}"
val filePath = path(pckg, "$className.java")

typeMap[tname] = ClassName.get(pckg, className)
Expand Down Expand Up @@ -84,7 +84,7 @@ class ModelsCodeGen(val cfg: ModelsCodeGenConfig) {

val pckg = "${cfg.pckg}.apis"

val className = "I${cfg.classPrefix}${tdef.name.pascal()}Fetcher"
val className = "I${cfg.classPrefix}${tdef.name.pascalCase()}Fetcher"
val filePath = path(pckg, "$className.java")

FILE(filePath) {
Expand Down
27 changes: 15 additions & 12 deletions codegen/utils/src/com/satori/codegen/utils/ICodeFormatter.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.satori.codegen.utils

interface ICodeFormatter {
fun constName(name: String) = name.underscore(true)
fun fieldName(name: String) = name.camel()
fun methodName(name: String) = name.camel()
fun varName(name: String) = name.camel()
fun className(name: String) = name.pascal()
fun getterName(name: String) = "get${name.pascal()}"
fun setterName(name: String) = "set${name.pascal()}"
fun camel(name: String) = name.camel()
fun pascal(name: String) = name.pascal()
fun underscore(name: String) = name.underscore(false)
fun underscore(name: String, uppercase: Boolean) = name.underscore(uppercase)
//fun elvis(name: String)
fun constName(name: String) = name.snakeCase(true)
fun fieldName(name: String) = name.camelCase()
fun methodName(name: String) = name.camelCase()
fun varName(name: String) = name.camelCase()
fun className(name: String) = name.pascalCase()
fun getterName(name: String) = "get${name.pascalCase()}"
fun setterName(name: String) = "set${name.pascalCase()}"
fun packageName(name: String) = name.dotsCase()

fun camel(name: String) = name.camelCase()
fun pascal(name: String) = name.pascalCase()
fun snake(name: String) = name.snakeCase(false)
fun snake(name: String, uppercase: Boolean) = name.snakeCase(uppercase)
fun kebab(name: String) = name.kebabCase(false)
fun kebab(name: String, uppercase: Boolean) = name.kebabCase(uppercase)
}
38 changes: 25 additions & 13 deletions codegen/utils/src/com/satori/codegen/utils/Lib.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ val javaKeywords = hashSetOf(
"const", "float", "native", "super", "while"
)

fun String.pascal(): String = let { str ->
fun String.pascalCase(): String = let { str ->
var capitalize = true
val builder = StringBuilder()
for (i in 0 until str.length) {
Expand Down Expand Up @@ -41,7 +41,7 @@ fun String.pascal(): String = let { str ->
return builder.toString()
}

fun String.camel(): String = let { str ->
fun String.camelCase(): String = let { str ->
var capitalize = true
val builder = StringBuilder()
for (i in 0 until str.length) {
Expand Down Expand Up @@ -71,41 +71,53 @@ fun String.camel(): String = let { str ->
return builder.toString()
}

fun String.underscore(uppercase: Boolean = false): String {
var underScoreNeeded = false
fun String.snakeCase(uppercase: Boolean = false): String {
return sepCase("_", uppercase)
}

fun String.kebabCase(uppercase: Boolean = false): String {
return sepCase("-", uppercase)
}

fun String.dotsCase(uppercase: Boolean = false): String {
return sepCase(".", uppercase)
}

fun String.sepCase(sep: String, uppercase: Boolean = false): String {
var sepNeeded = false
val builder = StringBuilder()
forEach { ch ->
when (Character.getType(ch).toByte()) {
Character.DECIMAL_DIGIT_NUMBER -> {
if (!builder.isEmpty()) {
if (underScoreNeeded) {
builder.append("_")
underScoreNeeded = false
if (sepNeeded) {
builder.append(sep)
sepNeeded = false
}
builder.append(ch)
}
}
Character.LOWERCASE_LETTER -> {
if (underScoreNeeded) {
builder.append("_")
underScoreNeeded = false
if (sepNeeded) {
builder.append(sep)
sepNeeded = false
}
builder.append(
if (uppercase) ch.toUpperCase() else ch
)
}
Character.UPPERCASE_LETTER -> {
if (!builder.isEmpty()) {
builder.append("_")
builder.append(sep)
}
underScoreNeeded = false
sepNeeded = false
builder.append(
if (!uppercase) ch.toLowerCase() else ch
)
}
else -> {
if (!builder.isEmpty()) {
underScoreNeeded = true
sepNeeded = true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,48 @@ package com.satori.gradle.composer.plugin
import org.gradle.api.*

open class ComposerPluginConvention(val project: Project) {
val satoriComposerVersion = "0.5.72-SNAPSHOT"
val satoriComposerVersion = "0.5.73-SNAPSHOT"

fun satoriGradleComposerPlugin() = "com.satori:satori-gradle-composer-plugin:0.5.72-SNAPSHOT"
fun satoriGradleComposerPlugin() = "com.satori:satori-gradle-composer-plugin:0.5.73-SNAPSHOT"

fun satoriComposer() = "com.satori:satori-composer:0.5.72-SNAPSHOT"
fun satoriComposer() = "com.satori:satori-composer:0.5.73-SNAPSHOT"

fun satoriMods() = "com.satori:satori-mods:0.5.72-SNAPSHOT"
fun satoriMods() = "com.satori:satori-mods:0.5.73-SNAPSHOT"

fun satoriModsSuite() = "com.satori:satori-mods-suite:0.5.72-SNAPSHOT"
fun satoriModsSuite() = "com.satori:satori-mods-suite:0.5.73-SNAPSHOT"

fun satoriLibsAsyncApi() = "com.satori:satori-libs-async-api:0.5.72-SNAPSHOT"
fun satoriLibsAsyncApi() = "com.satori:satori-libs-async-api:0.5.73-SNAPSHOT"

fun satoriLibsAsyncCore() = "com.satori:satori-libs-async-core:0.5.72-SNAPSHOT"
fun satoriLibsAsyncCore() = "com.satori:satori-libs-async-core:0.5.73-SNAPSHOT"

fun satoriLibsAsyncKotlin() = "com.satori:satori-libs-async-kotlin:0.5.72-SNAPSHOT"
fun satoriLibsAsyncKotlin() = "com.satori:satori-libs-async-kotlin:0.5.73-SNAPSHOT"

fun satoriLibsCommonKotlin() = "com.satori:satori-libs-common-kotlin:0.5.72-SNAPSHOT"
fun satoriLibsCommonKotlin() = "com.satori:satori-libs-common-kotlin:0.5.73-SNAPSHOT"

fun satoriLibsVertxKotlin() = "com.satori:satori-libs-vertx-kotlin:0.5.72-SNAPSHOT"
fun satoriLibsVertxKotlin() = "com.satori:satori-libs-vertx-kotlin:0.5.73-SNAPSHOT"

fun satoriLibsGtfs() = "com.satori:satori-libs-gtfs:0.5.72-SNAPSHOT"
fun satoriLibsGtfs() = "com.satori:satori-libs-gtfs:0.5.73-SNAPSHOT"

fun satoriLibsCompositionDrawer() = "com.satori:satori-libs-composition-drawer:0.5.72-SNAPSHOT"
fun satoriLibsCompositionDrawer() = "com.satori:satori-libs-composition-drawer:0.5.73-SNAPSHOT"

fun satoriLibsTestlib() = "com.satori:satori-libs-testlib:0.5.72-SNAPSHOT"
fun satoriLibsTestlib() = "com.satori:satori-libs-testlib:0.5.73-SNAPSHOT"

fun satoriLibsGradleUtils() = "com.satori:satori-libs-gradle-utils:0.5.72-SNAPSHOT"
fun satoriLibsGradleUtils() = "com.satori:satori-libs-gradle-utils:0.5.73-SNAPSHOT"

fun satoriLibsGradleTransform() = "com.satori:satori-libs-gradle-transform:0.5.72-SNAPSHOT"
fun satoriLibsGradleTransform() = "com.satori:satori-libs-gradle-transform:0.5.73-SNAPSHOT"

fun satoriLibsGradleGithub() = "com.satori:satori-libs-gradle-github:0.5.72-SNAPSHOT"
fun satoriLibsGradleGithub() = "com.satori:satori-libs-gradle-github:0.5.73-SNAPSHOT"

fun satoriLibsGradleDocker() = "com.satori:satori-libs-gradle-docker:0.5.72-SNAPSHOT"
fun satoriLibsGradleDocker() = "com.satori:satori-libs-gradle-docker:0.5.73-SNAPSHOT"

fun satoriLibsGradleCodegen() = "com.satori:satori-libs-gradle-codegen:0.5.72-SNAPSHOT"
fun satoriLibsGradleCodegen() = "com.satori:satori-libs-gradle-codegen:0.5.73-SNAPSHOT"

fun satoriCodegenUtils() = "com.satori:satori-codegen-utils:0.5.72-SNAPSHOT"
fun satoriCodegenUtils() = "com.satori:satori-codegen-utils:0.5.73-SNAPSHOT"

fun satoriCodegenCodemodelDsl() = "com.satori:satori-codegen-codemodel-dsl:0.5.72-SNAPSHOT"
fun satoriCodegenCodemodelDsl() = "com.satori:satori-codegen-codemodel-dsl:0.5.73-SNAPSHOT"

fun satoriCodegenMustacheBuilder() = "com.satori:satori-codegen-mustache-builder:0.5.72-SNAPSHOT"
fun satoriCodegenMustacheBuilder() = "com.satori:satori-codegen-mustache-builder:0.5.73-SNAPSHOT"

fun satoriCodegenYamlFileMerger() = "com.satori:satori-codegen-yaml-file-merger:0.5.72-SNAPSHOT"
fun satoriCodegenYamlFileMerger() = "com.satori:satori-codegen-yaml-file-merger:0.5.73-SNAPSHOT"

}
48 changes: 24 additions & 24 deletions gradle-composer-plugin/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Maven](https://img.shields.io/nexus/s/https/oss.sonatype.org/com.satori/satori-gradle-composer-plugin.svg)](https://oss.sonatype.org/content/repositories/snapshots/com/satori/satori-gradle-composer-plugin/0.5.72-SNAPSHOT/)
[![Maven](https://img.shields.io/nexus/s/https/oss.sonatype.org/com.satori/satori-gradle-composer-plugin.svg)](https://oss.sonatype.org/content/repositories/snapshots/com/satori/satori-gradle-composer-plugin/0.5.73-SNAPSHOT/)

## Comoser Gradle plugin

Expand All @@ -13,7 +13,7 @@ buildscript{
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
classpath "com.satori:satori-gradle-composer-plugin:0.5.72-SNAPSHOT"
classpath "com.satori:satori-gradle-composer-plugin:0.5.73-SNAPSHOT"
}
}
apply plugin: "com.satori.composer"
Expand All @@ -22,47 +22,47 @@ apply plugin: "com.satori.composer"
### project extensions


- `satoriGradleComposerPlugin()` - returns `"com.satori:satori-gradle-composer-plugin:0.5.72-SNAPSHOT"`
- `satoriGradleComposerPlugin()` - returns `"com.satori:satori-gradle-composer-plugin:0.5.73-SNAPSHOT"`

- `satoriComposer()` - returns `"com.satori:satori-composer:0.5.72-SNAPSHOT"`
- `satoriComposer()` - returns `"com.satori:satori-composer:0.5.73-SNAPSHOT"`

- `satoriMods()` - returns `"com.satori:satori-mods:0.5.72-SNAPSHOT"`
- `satoriMods()` - returns `"com.satori:satori-mods:0.5.73-SNAPSHOT"`

- `satoriModsSuite()` - returns `"com.satori:satori-mods-suite:0.5.72-SNAPSHOT"`
- `satoriModsSuite()` - returns `"com.satori:satori-mods-suite:0.5.73-SNAPSHOT"`

- `satoriLibsAsyncApi()` - returns `"com.satori:satori-libs-async-api:0.5.72-SNAPSHOT"`
- `satoriLibsAsyncApi()` - returns `"com.satori:satori-libs-async-api:0.5.73-SNAPSHOT"`

- `satoriLibsAsyncCore()` - returns `"com.satori:satori-libs-async-core:0.5.72-SNAPSHOT"`
- `satoriLibsAsyncCore()` - returns `"com.satori:satori-libs-async-core:0.5.73-SNAPSHOT"`

- `satoriLibsAsyncKotlin()` - returns `"com.satori:satori-libs-async-kotlin:0.5.72-SNAPSHOT"`
- `satoriLibsAsyncKotlin()` - returns `"com.satori:satori-libs-async-kotlin:0.5.73-SNAPSHOT"`

- `satoriLibsCommonKotlin()` - returns `"com.satori:satori-libs-common-kotlin:0.5.72-SNAPSHOT"`
- `satoriLibsCommonKotlin()` - returns `"com.satori:satori-libs-common-kotlin:0.5.73-SNAPSHOT"`

- `satoriLibsVertxKotlin()` - returns `"com.satori:satori-libs-vertx-kotlin:0.5.72-SNAPSHOT"`
- `satoriLibsVertxKotlin()` - returns `"com.satori:satori-libs-vertx-kotlin:0.5.73-SNAPSHOT"`

- `satoriLibsGtfs()` - returns `"com.satori:satori-libs-gtfs:0.5.72-SNAPSHOT"`
- `satoriLibsGtfs()` - returns `"com.satori:satori-libs-gtfs:0.5.73-SNAPSHOT"`

- `satoriLibsCompositionDrawer()` - returns `"com.satori:satori-libs-composition-drawer:0.5.72-SNAPSHOT"`
- `satoriLibsCompositionDrawer()` - returns `"com.satori:satori-libs-composition-drawer:0.5.73-SNAPSHOT"`

- `satoriLibsTestlib()` - returns `"com.satori:satori-libs-testlib:0.5.72-SNAPSHOT"`
- `satoriLibsTestlib()` - returns `"com.satori:satori-libs-testlib:0.5.73-SNAPSHOT"`

- `satoriLibsGradleUtils()` - returns `"com.satori:satori-libs-gradle-utils:0.5.72-SNAPSHOT"`
- `satoriLibsGradleUtils()` - returns `"com.satori:satori-libs-gradle-utils:0.5.73-SNAPSHOT"`

- `satoriLibsGradleTransform()` - returns `"com.satori:satori-libs-gradle-transform:0.5.72-SNAPSHOT"`
- `satoriLibsGradleTransform()` - returns `"com.satori:satori-libs-gradle-transform:0.5.73-SNAPSHOT"`

- `satoriLibsGradleGithub()` - returns `"com.satori:satori-libs-gradle-github:0.5.72-SNAPSHOT"`
- `satoriLibsGradleGithub()` - returns `"com.satori:satori-libs-gradle-github:0.5.73-SNAPSHOT"`

- `satoriLibsGradleDocker()` - returns `"com.satori:satori-libs-gradle-docker:0.5.72-SNAPSHOT"`
- `satoriLibsGradleDocker()` - returns `"com.satori:satori-libs-gradle-docker:0.5.73-SNAPSHOT"`

- `satoriLibsGradleCodegen()` - returns `"com.satori:satori-libs-gradle-codegen:0.5.72-SNAPSHOT"`
- `satoriLibsGradleCodegen()` - returns `"com.satori:satori-libs-gradle-codegen:0.5.73-SNAPSHOT"`

- `satoriCodegenUtils()` - returns `"com.satori:satori-codegen-utils:0.5.72-SNAPSHOT"`
- `satoriCodegenUtils()` - returns `"com.satori:satori-codegen-utils:0.5.73-SNAPSHOT"`

- `satoriCodegenCodemodelDsl()` - returns `"com.satori:satori-codegen-codemodel-dsl:0.5.72-SNAPSHOT"`
- `satoriCodegenCodemodelDsl()` - returns `"com.satori:satori-codegen-codemodel-dsl:0.5.73-SNAPSHOT"`

- `satoriCodegenMustacheBuilder()` - returns `"com.satori:satori-codegen-mustache-builder:0.5.72-SNAPSHOT"`
- `satoriCodegenMustacheBuilder()` - returns `"com.satori:satori-codegen-mustache-builder:0.5.73-SNAPSHOT"`

- `satoriCodegenYamlFileMerger()` - returns `"com.satori:satori-codegen-yaml-file-merger:0.5.72-SNAPSHOT"`
- `satoriCodegenYamlFileMerger()` - returns `"com.satori:satori-codegen-yaml-file-merger:0.5.73-SNAPSHOT"`



Expand All @@ -76,6 +76,6 @@ apply plugin: "com.satori.composer"
<dependency>
<groupId>com.satori</groupId>
<artifactId>satori-gradle-composer-plugin</artifactId>
<version>0.5.72-SNAPSHOT</version>
<version>0.5.73-SNAPSHOT</version>
</dependency>
```
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
group=com.satori
version=0.5.72-SNAPSHOT
version=0.5.73-SNAPSHOT

scaffoldingVersion=0.5.71-SNAPSHOT
scaffoldingVersion=0.5.72-SNAPSHOT

#nexusUsername=
#nexusPassword=
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
10 changes: 5 additions & 5 deletions libs/composition-drawer/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ buildscript{
maven {url "https://oss.sonatype.org/content/repositories/snapshots"}
}
dependencies {
classpath "com.satori:satori-libs-composition-drawer:0.5.72-SNAPSHOT"
classpath "com.satori:satori-libs-composition-drawer:0.5.73-SNAPSHOT"
}
}
apply plugin: "com.satori.composition.drawer"
Expand All @@ -43,7 +43,7 @@ buildscript{
maven { url "https://oss.sonatype.org/content/repositories/snapshots"}
}
dependencies {
classpath "com.satori:satori-libs-composition-drawer:0.5.72-SNAPSHOT"
classpath "com.satori:satori-libs-composition-drawer:0.5.73-SNAPSHOT"
}
}
Expand Down Expand Up @@ -72,7 +72,7 @@ repositories {
configurations{compositionDrawer}
dependencies {
compositionDrawer "com.satori:satori-libs-composition-drawer:0.5.72-SNAPSHOT"
compositionDrawer "com.satori:satori-libs-composition-drawer:0.5.73-SNAPSHOT"
}
task generateCompositionDiagram(type: JavaExec) {
Expand Down Expand Up @@ -110,13 +110,13 @@ task generateCompositionDiagram(type: JavaExec) {
<dependency>
<groupId>com.satori</groupId>
<artifactId>satori-libs-composition-drawer</artifactId>
<version>0.5.72-SNAPSHOT</version>
<version>0.5.73-SNAPSHOT</version>
</dependency>
```


### Download
[satori-libs-composition-drawer.v0.5.72-SNAPSHOT.zip](https://github.com/satori-com/satori-composer/releases/download/v0.5.72-SNAPSHOT/satori-libs-composition-drawer.v0.5.72-SNAPSHOT.zip)<br/>
[satori-libs-composition-drawer.v0.5.73-SNAPSHOT.zip](https://github.com/satori-com/satori-composer/releases/download/v0.5.73-SNAPSHOT/satori-libs-composition-drawer.v0.5.73-SNAPSHOT.zip)<br/>
[or see latest releases](https://github.com/satori-com/satori-composer/releases/latest)

### Example of generated diagram
Expand Down
6 changes: 3 additions & 3 deletions libs/gradle/codegen/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Maven](https://img.shields.io/nexus/s/https/oss.sonatype.org/com.satori/satori-libs-gradle-codegen.svg)](https://oss.sonatype.org/content/repositories/snapshots/com/satori/satori-libs-gradle-codegen/0.5.72-SNAPSHOT/)
[![Maven](https://img.shields.io/nexus/s/https/oss.sonatype.org/com.satori/satori-libs-gradle-codegen.svg)](https://oss.sonatype.org/content/repositories/snapshots/com/satori/satori-libs-gradle-codegen/0.5.73-SNAPSHOT/)

## 'codegen' gradle plugin

Expand All @@ -13,7 +13,7 @@ buildscript{
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
classpath "com.satori:satori-libs-gradle-codegen:0.5.72-SNAPSHOT"
classpath "com.satori:satori-libs-gradle-codegen:0.5.73-SNAPSHOT"
}
}
apply plugin: "com.satori.codegen"
Expand Down Expand Up @@ -128,6 +128,6 @@ codeFormatter.camel(project.name)
<dependency>
<groupId>com.satori</groupId>
<artifactId>satori-libs-gradle-codegen</artifactId>
<version>0.5.72-SNAPSHOT</version>
<version>0.5.73-SNAPSHOT</version>
</dependency>
```
Loading

0 comments on commit 01670da

Please sign in to comment.