Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kuyucuburak authored Dec 2, 2023
1 parent ff57f8e commit 17a38d5
Showing 1 changed file with 46 additions and 11 deletions.
57 changes: 46 additions & 11 deletions reachard-namifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,74 +57,109 @@

This is very easy to use. All of details are explained below.

There are numerous casing type supported in this library.
### Supported Naming Conventions

### Camel Case
There are numerous casing types supported in this library.

#### Camel Case

```kotlin
val result = ReachardNamifier.convert(caseType = CaseTypeEnums.CAMEL, text = "TOTAL item count", separator = " ")
print(result == "totalItemCount") // prints true
```

### Dot Case
#### Dot Case

```kotlin
val result = ReachardNamifier.convert(caseType = CaseTypeEnums.DOT, text = "TOTAL item count", separator = " ")
print(result == "total.item.count") // prints true
```

### Kebab Case
#### Kebab Case

```kotlin
val result = ReachardNamifier.convert(caseType = CaseTypeEnums.KEBAB, text = "TOTAL item count", separator = " ")
print(result == "total-item-count") // prints true
```

### Pascal Case
#### Pascal Case

```kotlin
val result = ReachardNamifier.convert(caseType = CaseTypeEnums.PASCAL, text = "TOTAL item count", separator = " ")
print(result == "TotalItemCount") // prints true
```

### Pascal Snake Case
#### Pascal Snake Case

```kotlin
val result = ReachardNamifier.convert(caseType = CaseTypeEnums.PASCAL_SNAKE, text = "TOTAL item count", separator = " ")
print(result == "Total_Item_Count") // prints true
```

### Screaming Snake Case
#### Screaming Snake Case

```kotlin
val result = ReachardNamifier.convert(caseType = CaseTypeEnums.SCREAMING_SNAKE, text = "TOTAL item count", separator = " ")
print(result == "TOTAL_ITEM_COUNT") // prints true
```

### Sentence Case
#### Sentence Case

```kotlin
val result = ReachardNamifier.convert(caseType = CaseTypeEnums.SENTENCE, text = "TOTAL item count", separator = " ")
print(result == "Total item count") // prints true
```

### Snake Case
#### Snake Case

```kotlin
val result = ReachardNamifier.convert(caseType = CaseTypeEnums.SNAKE, text = "TOTAL item count", separator = " ")
print(result == "total_item_count") // prints true
```

### Title Case
#### Title Case

```kotlin
val result = ReachardNamifier.convert(caseType = CaseTypeEnums.TITLE, text = "TOTAL item count", separator = " ")
print(result == "Total Item Count") // prints true
```

### Train Case
#### Train Case

```kotlin
val result = ReachardNamifier.convert(caseType = CaseTypeEnums.TRAIN, text = "TOTAL item count", separator = " ")
print(result == "Total-Item-Count") // prints true
```

### Custom Naming Conventions

You can create your own naming conventions like below:

```kotlin
private object CustomNamifier : NamifierBase() {

override val replacingSeparator: String = "&"

override fun convertWord(totalWordCount: Int, wordIndex: Int, word: String): String {
return word
.lowercase()
.replaceFirstChar { it.uppercase() }
}
}
```

You can use your custom namifier like below:

```kotlin
val result = ReachardNamifier.convert(namifier = CustomNamifier, text = "TOTAL item count", separator = " ")
print(result == "Total&Item&Count") // prints true
```

### Converting From one Case Type to Another

If you know the casing type of the string, you can just do this:

```kotlin
ReachardNamifier.convert(from = CaseTypeEnums.CAMEL, to = CaseTypeEnums.SCREAMING_SNAKE, text = "totalItemCount")
print(result == "TOTAL_ITEM_COUNT") // prints true
```

0 comments on commit 17a38d5

Please sign in to comment.