1
0
Fork 0
mirror of https://github.com/ethauvin/kotlin-pluralizer.git synced 2025-04-25 00:37:12 -07:00

Compare commits

...

7 commits

Author SHA1 Message Date
Cesar Ferreira
6b65d56b19 bumped version 2017-01-30 11:52:35 +00:00
Cesar Ferreira
0afabd8a4e updated travis 2017-01-30 11:21:04 +00:00
Cesar Ferreira
4b1cdffa7e bumped versions 2017-01-30 11:04:06 +00:00
Cesar Ferreira
6fc79f6a94 bump version 2017-01-30 10:47:08 +00:00
César Ferreira
5af7c33746 Merge pull request #2 from marwanad/lower-case-check-for-uncountables
check uncountables against the lower-cased string
2017-01-30 10:45:24 +00:00
Marwan
3177a1ff16 check uncountables against the lower-cased string 2017-01-29 12:58:39 -05:00
Cesar Ferreira
322fdd6d0e updated readme 2016-09-10 12:56:41 +01:00
6 changed files with 15 additions and 15 deletions

View file

@ -4,9 +4,9 @@ android:
components:
- tools
- platform-tools
- build-tools-24.0.2
- build-tools-24.0.3
- extra-android-m2repository
- android-24
- android-25
jdk:
- oraclejdk8

View file

@ -3,7 +3,7 @@
**kotlin extension** to **pluralize** and **singularize** strings
[![Build Status](https://travis-ci.org/cesarferreira/kotlin-pluralizer.svg?branch=master)](https://travis-ci.org/cesarferreira/kotlin-pluralizer) [![Release](https://jitpack.io/v/cesarferreira/kotlin-pluralizer.svg)](https://jitpack.io/#cesarferreira/kkotlin-pluralizer)
[![Build Status](https://travis-ci.org/cesarferreira/kotlin-pluralizer.svg?branch=master)](https://travis-ci.org/cesarferreira/kotlin-pluralizer) [![Release](https://jitpack.io/v/cesarferreira/kotlin-pluralizer.svg)](https://jitpack.io/#cesarferreira/kotlin-pluralizer)
### Show some love
[![GitHub followers](https://img.shields.io/github/followers/cesarferreira.svg?style=social&label=Follow)](https://github.com/cesarferreira/kotlin-pluralizer) [![Twitter Follow](https://img.shields.io/twitter/follow/cesarmcferreira.svg?style=social)](https://twitter.com/cesarmcferreira)
@ -43,7 +43,7 @@ repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.github.cesarferreira:kotlin-pluralizer:0.2.7'
compile 'com.github.cesarferreira:kotlin-pluralizer:0.2.9'
}
```

View file

@ -12,11 +12,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
compileSdkVersion 25
buildToolsVersion "24.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 24
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
@ -38,8 +38,8 @@ android {
dependencies {
compile project(':library')
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
}
repositories {
mavenCentral()

View file

@ -1,12 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.0.3'
ext.kotlin_version = '1.0.6'
ext {
ext_groupId = 'com.cesarferreira'
ext_artifactId = 'kotlin-pluralizer'
ext_version = '0.2.5'
ext_version = '0.2.9'
ext_url = 'https://github.com/cesarferreira/kotlin-pluralizer'
ext_vcsUrl = 'https://github.com/cesarferreira/kotlin-pluralizer.git'
ext_description = 'Kotlin extension to pluralize and singularize strings'
@ -16,7 +16,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

View file

@ -45,7 +45,7 @@ fun String.singularize(count: Int): String {
}
private fun String.pluralizer(): String {
if (unCountable().contains(this)) return this
if (unCountable().contains(this.toLowerCase())) return this
val rule = pluralizeRules().last { Pattern.compile(it.component1(), Pattern.CASE_INSENSITIVE).matcher(this).find() }
var found = Pattern.compile(rule.component1(), Pattern.CASE_INSENSITIVE).matcher(this).replaceAll(rule.component2())
val endsWith = exceptions().firstOrNull { this.endsWith(it.component1()) }
@ -56,7 +56,7 @@ private fun String.pluralizer(): String {
}
private fun String.singularizer(): String {
if (unCountable().contains(this)) {
if (unCountable().contains(this.toLowerCase())) {
return this
}
val exceptions = exceptions().firstOrNull() { this.equals(it.component2()) }