From 3a56d6d79275f4ccecfc299fe078b215ce558609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Ferreira?= Date: Mon, 5 Sep 2016 11:38:45 +0100 Subject: [PATCH 01/12] Update build.gradle --- android-sample/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/android-sample/build.gradle b/android-sample/build.gradle index fa4a664..747a86d 100644 --- a/android-sample/build.gradle +++ b/android-sample/build.gradle @@ -15,7 +15,6 @@ android { compileSdkVersion 24 buildToolsVersion "24.0.2" defaultConfig { - applicationId "com.cesarferreira.supposedlibrary" minSdkVersion 16 targetSdkVersion 24 versionCode 1 From 091e16a697d2a3646813df4756b2c8c326200707 Mon Sep 17 00:00:00 2001 From: cesarferreira Date: Mon, 5 Sep 2016 14:51:55 +0100 Subject: [PATCH 02/12] few tweaks and package name change --- android-sample/build.gradle | 2 +- .../com/cesarferreira/pluralize/Pluralize.kt | 22 +++++++++---------- .../pluralize/utils/Plurality.kt | 0 3 files changed, 11 insertions(+), 13 deletions(-) rename library/src/main/{java => kotlin}/com/cesarferreira/pluralize/Pluralize.kt (91%) rename library/src/main/{java => kotlin}/com/cesarferreira/pluralize/utils/Plurality.kt (100%) diff --git a/android-sample/build.gradle b/android-sample/build.gradle index 747a86d..18bffd7 100644 --- a/android-sample/build.gradle +++ b/android-sample/build.gradle @@ -23,7 +23,7 @@ android { lintOptions { abortOnError false } - + buildTypes { release { minifyEnabled false diff --git a/library/src/main/java/com/cesarferreira/pluralize/Pluralize.kt b/library/src/main/kotlin/com/cesarferreira/pluralize/Pluralize.kt similarity index 91% rename from library/src/main/java/com/cesarferreira/pluralize/Pluralize.kt rename to library/src/main/kotlin/com/cesarferreira/pluralize/Pluralize.kt index db1d4cc..fffb0af 100644 --- a/library/src/main/java/com/cesarferreira/pluralize/Pluralize.kt +++ b/library/src/main/kotlin/com/cesarferreira/pluralize/Pluralize.kt @@ -25,7 +25,7 @@ fun String.singularize(plurality: Plurality = Plurality.Plural): String { if (this.pluralizer() != this && this + "s" != this.pluralizer() && this.pluralizer().singularize() == this && this.singularizer() != this) - return this; + return this return this.singularize() } @@ -34,10 +34,10 @@ private fun String.pluralizer(): String { if (unCountable().contains(this)) 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()) } - if (endswith != null) found = this.replace(endswith.component1(), endswith.component2()) - val excep = exceptions().firstOrNull() { this.equals(it.component1()) } - if (excep != null) found = excep.component2() + val endsWith = exceptions().firstOrNull { this.endsWith(it.component1()) } + if (endsWith != null) found = this.replace(endsWith.component1(), endsWith.component2()) + val exception = exceptions().firstOrNull() { this.equals(it.component1()) } + if (exception != null) found = exception.component2() return found } @@ -45,14 +45,14 @@ private fun String.singularizer(): String { if (unCountable().contains(this)) { return this } - val excepions = exceptions().firstOrNull() { this.equals(it.component2()) } + val exceptions = exceptions().firstOrNull() { this.equals(it.component2()) } - if (excepions != null) { - return excepions.component1() + if (exceptions != null) { + return exceptions.component1() } - val endswith = exceptions().firstOrNull { this.endsWith(it.component2()) } + val endsWith = exceptions().firstOrNull { this.endsWith(it.component2()) } - if (endswith != null) return this.replace(endswith.component2(), endswith.component1()) + if (endsWith != null) return this.replace(endsWith.component2(), endsWith.component1()) try { if (singularizeRules().count { @@ -200,5 +200,3 @@ fun singularizeRules(): List> { "i$" to "us", "ae$" to "a") } - - diff --git a/library/src/main/java/com/cesarferreira/pluralize/utils/Plurality.kt b/library/src/main/kotlin/com/cesarferreira/pluralize/utils/Plurality.kt similarity index 100% rename from library/src/main/java/com/cesarferreira/pluralize/utils/Plurality.kt rename to library/src/main/kotlin/com/cesarferreira/pluralize/utils/Plurality.kt From 46ece47676b879f0c03dc6860379808bfdb07b3f Mon Sep 17 00:00:00 2001 From: cesarferreira Date: Mon, 5 Sep 2016 16:46:17 +0100 Subject: [PATCH 03/12] fixed typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c41a94..6f488dc 100644 --- a/README.md +++ b/README.md @@ -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) [ ![bintray](https://api.bintray.com/packages/cesarferreira/maven/kotlin-pluralizer/images/download.svg) ](https://bintray.com/cesarferreira/maven/kotlin-pluralizer/_latestVersion) +[![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) [ ![bintray](https://api.bintray.com/packages/cesarferreira/maven/kotlin-pluralizer/images/download.svg) ](https://bintray.com/cesarferreira/maven/kotlin-pluralizer/_latestVersion) ## Usage From dd093535925a75d08f1d642c879d3b63480e4071 Mon Sep 17 00:00:00 2001 From: cesarferreira Date: Mon, 5 Sep 2016 20:33:38 +0100 Subject: [PATCH 04/12] updated readme --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f750bae..8413d7a 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { ext { ext_groupId = 'com.cesarferreira' ext_artifactId = 'kotlin-pluralizer' - ext_version = '0.2.4' + ext_version = '0.2.5' 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' From 0cf3c54ae2d88e65f6154778357c975dab293f78 Mon Sep 17 00:00:00 2001 From: cesarferreira Date: Mon, 5 Sep 2016 21:21:59 +0100 Subject: [PATCH 05/12] update readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6f488dc..3e29bc5 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # kotlin-pluralizer -**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/kotlin-pluralizer) [ ![bintray](https://api.bintray.com/packages/cesarferreira/maven/kotlin-pluralizer/images/download.svg) ](https://bintray.com/cesarferreira/maven/kotlin-pluralizer/_latestVersion) +> **kotlin extension** to **pluralize** and **singularize** strings + ## Usage **Pluralization:** @@ -33,7 +33,7 @@ repositories { maven { url "https://jitpack.io" } } dependencies { - compile 'com.github.cesarferreira:kotlin-pluralizer:0.2.4' + compile 'com.github.cesarferreira:kotlin-pluralizer:0.2.5' } ``` From af2a59e3ec0db341621eb0e186fceb2cdcd7f9d6 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 5 Sep 2016 20:22:42 -0700 Subject: [PATCH 06/12] Added pluralize/singularize functions based on an int count. --- .../com/cesarferreira/pluralize/Pluralize.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/library/src/main/kotlin/com/cesarferreira/pluralize/Pluralize.kt b/library/src/main/kotlin/com/cesarferreira/pluralize/Pluralize.kt index fffb0af..b9cbc59 100644 --- a/library/src/main/kotlin/com/cesarferreira/pluralize/Pluralize.kt +++ b/library/src/main/kotlin/com/cesarferreira/pluralize/Pluralize.kt @@ -30,6 +30,20 @@ fun String.singularize(plurality: Plurality = Plurality.Plural): String { return this.singularize() } +fun String.pluralize(count: Int): String { + if (count > 1) + return this.pluralize(Plurality.Plural) + else + return this.pluralize(Plurality.Singular) +} + +fun String.singularize(count: Int): String { + if (count > 1) + return this.singularize(Plurality.Plural) + else + return this.singularize(Plurality.Singular) +} + private fun String.pluralizer(): String { if (unCountable().contains(this)) return this val rule = pluralizeRules().last { Pattern.compile(it.component1(), Pattern.CASE_INSENSITIVE).matcher(this).find() } From 322fdd6d0e3e3da1bf59657a4e64bda8acc79ad5 Mon Sep 17 00:00:00 2001 From: Cesar Ferreira Date: Sat, 10 Sep 2016 12:56:41 +0100 Subject: [PATCH 07/12] updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index efae377..4c94366 100644 --- a/README.md +++ b/README.md @@ -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) From 3177a1ff16e726f5b91c9279bdda1134446612bc Mon Sep 17 00:00:00 2001 From: Marwan Date: Sun, 29 Jan 2017 12:58:39 -0500 Subject: [PATCH 08/12] check uncountables against the lower-cased string --- .../src/main/kotlin/com/cesarferreira/pluralize/Pluralize.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/src/main/kotlin/com/cesarferreira/pluralize/Pluralize.kt b/library/src/main/kotlin/com/cesarferreira/pluralize/Pluralize.kt index b9cbc59..159c823 100644 --- a/library/src/main/kotlin/com/cesarferreira/pluralize/Pluralize.kt +++ b/library/src/main/kotlin/com/cesarferreira/pluralize/Pluralize.kt @@ -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()) } From 6fc79f6a945c415e1639c1b87252805a349f9581 Mon Sep 17 00:00:00 2001 From: Cesar Ferreira Date: Mon, 30 Jan 2017 10:47:08 +0000 Subject: [PATCH 09/12] bump version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c94366..603be44 100644 --- a/README.md +++ b/README.md @@ -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.8' } ``` From 4b1cdffa7ec4a809fe651c8f3ad10afe7fff797b Mon Sep 17 00:00:00 2001 From: Cesar Ferreira Date: Mon, 30 Jan 2017 11:04:06 +0000 Subject: [PATCH 10/12] bumped versions --- android-sample/build.gradle | 10 +++++----- build.gradle | 6 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/android-sample/build.gradle b/android-sample/build.gradle index 18bffd7..c3e679e 100644 --- a/android-sample/build.gradle +++ b/android-sample/build.gradle @@ -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() diff --git a/build.gradle b/build.gradle index 8413d7a..dc8c0f7 100644 --- a/build.gradle +++ b/build.gradle @@ -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" } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e58f963..3fb1e18 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 From 0afabd8a4e698874e1b56234a06f171f8b0f51e1 Mon Sep 17 00:00:00 2001 From: Cesar Ferreira Date: Mon, 30 Jan 2017 11:21:04 +0000 Subject: [PATCH 11/12] updated travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index db37ec3..fad41d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 From 6b65d56b198bd6f6c0d108e689a8942bf7f26602 Mon Sep 17 00:00:00 2001 From: Cesar Ferreira Date: Mon, 30 Jan 2017 11:52:35 +0000 Subject: [PATCH 12/12] bumped version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 603be44..a5a0e89 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ repositories { maven { url "https://jitpack.io" } } dependencies { - compile 'com.github.cesarferreira:kotlin-pluralizer:0.2.8' + compile 'com.github.cesarferreira:kotlin-pluralizer:0.2.9' } ```