-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73802fd
commit e3fc630
Showing
3 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
## Pluralize Ballerina Connector | ||
|
||
The `pluralize` Ballerina Connector is designed to assist with the pluralization and singularization of English words. This can be particularly useful when generating dynamic strings based on numerical values. | ||
|
||
This module utilizes a predefined list of rules, applied sequentially, to singularize or pluralize a given word. This can be beneficial in many scenarios, such as automating tasks based on user input. For applications where the words are known in advance, a simple ternary (or function) can be used as a lighter alternative. | ||
|
||
This module is a migration of the [`pluralize`](https://www.npmjs.com/package/pluralize) library by [`Blake Embrey`](https://github.com/blakeembrey). All credit goes to him. | ||
|
||
### Quickstart | ||
|
||
To use the `pluralize` connector in your Ballerina application, modify the `.bal` file as follows: | ||
|
||
#### Step 1: Import the module | ||
|
||
Import the `pluralize` module. | ||
|
||
```ballerina | ||
import niveathika/pluralize; | ||
``` | ||
|
||
#### Step 2: Invoke the connector operation | ||
|
||
Now, utilize the available connector operations. | ||
|
||
```ballerina | ||
pluralize:pluralize('test'); //=> "tests" | ||
pluralize:pluralize('test', 0); //=> "tests" | ||
pluralize:pluralize('test', 1); //=> "test" | ||
pluralize:pluralize('test', 5); //=> "tests" | ||
pluralize:pluralize('test', 1, true); //=> "1 test" | ||
pluralize:pluralize('test', 5, true); //=> "5 tests" | ||
pluralize:pluralize('蘋果', 2, true); //=> "2 蘋果" | ||
pluralize:isPlural("test"); // false | ||
pluralize:isPlural("tests"); // true | ||
``` | ||
|
||
#### Step 3: Run the Ballerina application | ||
|
||
```bash | ||
bal run | ||
``` | ||
|
||
### Build from the source | ||
|
||
#### Prerequisites | ||
|
||
1. Download and install Java SE Development Kit (JDK) version 17. You can download it from either of the following sources: | ||
|
||
* [Oracle JDK](https://www.oracle.com/java/technologies/downloads/) | ||
* [OpenJDK](https://adoptium.net/) | ||
|
||
> **Note:** After installation, remember to set the `JAVA_HOME` environment variable to the directory where JDK was installed. | ||
2. Download and install [Ballerina Swan Lake](https://ballerina.io/). | ||
|
||
3. Download and install [Docker](https://www.docker.com/get-started). | ||
|
||
> **Note**: Ensure that the Docker daemon is running before executing any tests. | ||
#### Build options | ||
|
||
Execute the commands below to build from the source. | ||
|
||
1. To build the package: | ||
|
||
```bash | ||
./gradlew clean build | ||
``` | ||
|
||
2. To run the tests: | ||
|
||
```bash | ||
./gradlew clean test | ||
``` | ||
|
||
3. To build the without the tests: | ||
|
||
```bash | ||
./gradlew clean build -x test | ||
``` | ||
|
||
4. To debug package with a remote debugger: | ||
|
||
```bash | ||
./gradlew clean build -Pdebug=<port> | ||
``` | ||
|
||
5. Publish the generated artifacts to the local Ballerina Central repository: | ||
|
||
```bash | ||
./gradlew clean build -PpublishToLocalCentral=true | ||
``` | ||
|
||
6. Publish the generated artifacts to the Ballerina Central repository: | ||
|
||
```bash | ||
./gradlew clean build -PpublishToCentral=true | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
## Overview | ||
|
||
The `pluralize` Ballerina Connector is designed to assist with the pluralization and singularization of English words. This can be particularly useful when generating dynamic strings based on numerical values. | ||
|
||
This module utilizes a predefined list of rules, applied sequentially, to singularize or pluralize a given word. This can be beneficial in many scenarios, such as automating tasks based on user input. For applications where the words are known in advance, a simple ternary (or function) can be used as a lighter alternative. | ||
|
||
This module is a migration of the [`pluralize`](https://www.npmjs.com/package/pluralize) library by [`Blake Embrey`](https://github.com/blakeembrey). All credit goes to him. | ||
|
||
### Quickstart | ||
|
||
To use the `pluralize` connector in your Ballerina application, modify the `.bal` file as follows: | ||
|
||
#### Step 1: Import the module | ||
|
||
Import the `pluralize` module. | ||
|
||
```ballerina | ||
import niveathika/pluralize; | ||
``` | ||
|
||
#### Step 2: Invoke the connector operation | ||
|
||
Now, utilize the available connector operations. | ||
|
||
```ballerina | ||
pluralize:pluralize('test'); //=> "tests" | ||
pluralize:pluralize('test', 0); //=> "tests" | ||
pluralize:pluralize('test', 1); //=> "test" | ||
pluralize:pluralize('test', 5); //=> "tests" | ||
pluralize:pluralize('test', 1, true); //=> "1 test" | ||
pluralize:pluralize('test', 5, true); //=> "5 tests" | ||
pluralize:pluralize('蘋果', 2, true); //=> "2 蘋果" | ||
pluralize:isPlural("test"); // false | ||
pluralize:isPlural("tests"); // true | ||
``` | ||
|
||
#### Step 3: Run the Ballerina application | ||
|
||
```bash | ||
bal run | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
## Overview | ||
|
||
The `pluralize` Ballerina Connector is designed to assist with the pluralization and singularization of English words. This can be particularly useful when generating dynamic strings based on numerical values. | ||
|
||
This module utilizes a predefined list of rules, applied sequentially, to singularize or pluralize a given word. This can be beneficial in many scenarios, such as automating tasks based on user input. For applications where the words are known in advance, a simple ternary (or function) can be used as a lighter alternative. | ||
|
||
This module is a migration of the [`pluralize`](https://www.npmjs.com/package/pluralize) library by [`Blake Embrey`](https://github.com/blakeembrey). All credit goes to him. | ||
|
||
### Quickstart | ||
|
||
To use the `pluralize` connector in your Ballerina application, modify the `.bal` file as follows: | ||
|
||
#### Step 1: Import the module | ||
|
||
Import the `pluralize` module. | ||
|
||
```ballerina | ||
import niveathika/pluralize; | ||
``` | ||
|
||
#### Step 2: Invoke the connector operation | ||
|
||
Now, utilize the available connector operations. | ||
|
||
```ballerina | ||
pluralize:pluralize('test'); //=> "tests" | ||
pluralize:pluralize('test', 0); //=> "tests" | ||
pluralize:pluralize('test', 1); //=> "test" | ||
pluralize:pluralize('test', 5); //=> "tests" | ||
pluralize:pluralize('test', 1, true); //=> "1 test" | ||
pluralize:pluralize('test', 5, true); //=> "5 tests" | ||
pluralize:pluralize('蘋果', 2, true); //=> "2 蘋果" | ||
pluralize:isPlural("test"); // false | ||
pluralize:isPlural("tests"); // true | ||
``` | ||
|
||
#### Step 3: Run the Ballerina application | ||
|
||
```bash | ||
bal run | ||
``` |