Skip to content

Commit

Permalink
First version after rework
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed May 18, 2022
1 parent ed6812d commit 6021248
Show file tree
Hide file tree
Showing 11 changed files with 348 additions and 188 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: test

on:
push:
branches:
- '*'
tags-ignore:
- '*'
pull_request:

jobs:
raku:
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
raku-version:
- 'latest'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: Raku/setup-raku@v1
with:
raku-version: ${{ matrix.raku-version }}
- name: Run Tests
run: zef test .
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lib/.precomp
.precomp/
/Lingua-Conjunction-*
5 changes: 4 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Revision History for 'Lingua-Conjunction' Perl 6 Distribution
Revision history for Lingua-Conjunction

{{$NEXT}}
- First version in zef ecosystem

1.001001 2015-12-08
- First version released on an unsuspecting world
40 changes: 28 additions & 12 deletions META6.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
{
"perl" : "6.c",
"name" : "Lingua::Conjunction",
"license" : "Artistic-2.0",
"version" : "1.001001",
"description" : "Convert lists into linguistic conjunctions and fill them into a template",
"depends" : [ ],
"test-depends" : [ "Test" ],
"provides" : {
"Lingua::Conjunction" : "lib/Lingua/Conjunction.pm6"
},
"authors" : ["Zoffix Znet"],
"support" : { "source" : "git://github.com/raku-community-modules/Lingua-Conjunction.git" }
"auth": "zef:raku-community-modules",
"authors": [
"Zoffix Znet"
],
"build-depends": [
],
"depends": [
],
"description": "Convert lists into linguistic conjunctions and fill them into a template",
"license": "Artistic-2.0",
"name": "Lingua::Conjunction",
"perl": "6.c",
"provides": {
"Lingua::Conjunction": "lib/Lingua/Conjunction.rakumod"
},
"resources": [
],
"source-url": "https://github.com/raku-community-modules/Lingua-Conjunction.git",
"support": {
"source": "git://github.com/raku-community-modules/Lingua-Conjunction.git"
},
"tags": [
"LINGUA",
"CONJUNCTION"
],
"test-depends": [
],
"version": "1.001001"
}
181 changes: 66 additions & 115 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,159 +1,110 @@
[![Build Status](https://travis-ci.org/zoffixznet/perl6-Lingua-Conjunction.svg)](https://travis-ci.org/zoffixznet/perl6-Lingua-Conjunction)
[![Actions Status](https://github.com/raku-community-modules/Lingua-Conjunction/actions/workflows/test.yml/badge.svg)](https://github.com/raku-community-modules/Lingua-Conjunction/actions)

# NAME
NAME
====

Lingua::Conjunction - Convert lists into linguistic conjunctions and fill them into a template

# SYNOPSIS
SYNOPSIS
========

```raku
use Lingua::Conjunction;
use Lingua::Conjunction;

say conjunction <chair>; # chair
say conjunction <chair spoon>; # chair and spoon
say conjunction <chair spoon window>; # chair, spoon, and window
say conjunction <chair>; # chair
say conjunction <chair spoon>; # chair and spoon
say conjunction <chair spoon window>; # chair, spoon, and window

# "Tom, a man; Tiffany, a woman; and GumbyBRAIN, a bot"
say conjunction 'Tom, a man', 'Tiffany, a woman', 'GumbyBRAIN, a bot';
# "Tom, a man; Tiffany, a woman; and GumbyBRAIN, a bot"
say conjunction 'Tom, a man', 'Tiffany, a woman', 'GumbyBRAIN, a bot';

# These are reports for May, June, and August
say conjunction <May June August>, :str('These [is|are] report[|s] for |list|');
# These are reports for May, June, and August
say conjunction <May June August>, :str('These [is|are] report[|s] for |list|');

# "Jacques, un garcon; Jeanne, une fille et Spot, un chien"
say conjunction 'Jacques, un garcon', 'Jeanne, une fille', 'Spot, un chien',
:lang<fr>;
# "Jacques, un garcon; Jeanne, une fille et Spot, un chien"
say conjunction 'Jacques, un garcon', 'Jeanne, une fille', 'Spot, un chien',
:lang<fr>;
```

# Table of Contents
- [NAME](#name)
- [SYNOPSIS](#synopsis)
- [DESCRIPTION](#description)
- [EXPORTED SUBROUTINES](#exported-subroutines)
- [`conjunction`](#conjunction)
- [`alt`](#alt)
- [`con`](#con)
- [`dis`](#dis)
- [`lang`](#lang)
- [`last`](#last)
- [`sep`](#sep)
- [`str`](#str)
- [`type`](#type)
- [REPOSITORY](#repository)
- [BUGS](#bugs)
- [AUTHOR](#author)
- [LICENSE](#license)
DESCRIPTION
===========

# DESCRIPTION
Provides a way to make it easy to prepare a string containing a list of items, where that string is meant to be read by a human.

Provides a way to make it easy to prepare a string containing a list of items,
where that string is meant to be read by a human.
EXPORTED SUBROUTINES
====================

# EXPORTED SUBROUTINES
conjunction
-----------

## `conjunction`

say conjunction <chair spoon>;
say conjunction <May June August>, :str('Report[|s] for |list|'),
:lang<fr>, :!last, :sep<·>, :alt<°>, :con<aaand>, :dis<ooor>, :type<or>;
```raku
say conjunction <chair spoon>;
say conjunction <May June August>, :str('Report[|s] for |list|'),
:lang<fr>, :!last, :sep<·>, :alt<°>, :con<aaand>, :dis<ooor>, :type<or>;
```

Returns a string with the given list of items joined based on the
configuration specified by the named arguments, which are as follows:
Returns a string with the given list of items joined based on the configuration specified by the named arguments, which are as follows:

### `alt`
### alt

Specifies an alternative separator to use when at least one of the items
contains `sep` separator. **Defaults to** `;` (a semicolon).
Specifies an alternative separator to use when at least one of the items contains `sep` separator. **Defaults to** `;` (a semicolon).

### `con`
head3 con

Short for **con**junction. The term to use when joining the last item
to the previous one, when `type` argument is set to value `and`.
**By default** is set based on value of `lang` argument.
Short for **con**junction. The term to use when joining the last item to the previous one, when `type` argument is set to value `and`. **By default** is set based on value of `lang` argument.

### `dis`
### dis

Short for **dis**junction. The term to use when joining the last item
to the previous one, when `type` argument is set to value `or`.
**By default** is set based on value of `lang` argument.
Short for **dis**junction. The term to use when joining the last item to the previous one, when `type` argument is set to value `or`. **By default** is set based on value of `lang` argument.

### `lang`
### lang

Takes a string representing the code of the language to use. This will
pre-set `con`, `dis`, and `last` arguments. **Defaults to** `en`.
Currently supported languages and the defaults they pre-set are as follows
(language is the first two-letter key on the left; that's what you'd
specify as `lang` argument):
Takes a string representing the code of the language to use. This will pre-set `con`, `dis`, and `last` arguments. **Defaults to** `en`. Currently supported languages and the defaults they pre-set are as follows (language is the first two-letter key on the left; that's what you'd specify as `lang` argument):

```raku
af => { last => True, con => 'en', dis => 'of' },
da => { last => True, con => 'og', dis => 'eller' },
de => { last => True, con => 'und', dis => 'oder' },
en => { last => True, con => 'and', dis => 'or' },
es => { last => True, con => 'y', dis => 'o' },
fi => { last => True, con => 'ja', dis => 'tai' },
fr => { last => False, con => 'et', dis => 'ou' },
it => { last => True, con => 'e', dis => 'o' },
la => { last => True, con => 'et', dis => 'vel' },
nl => { last => True, con => 'en', dis => 'of' },
no => { last => False, con => 'og', dis => 'eller' },
pt => { last => True, con => 'e', dis => 'ou' },
sw => { last => True, con => 'na', dis => 'au' },
```
<table class="pod-table">
<thead><tr>
<th>lang</th> <th>last</th> <th>con</th> <th>dis</th> <th></th>
</tr></thead>
<tbody>
<tr> <td>af</td> <td>True</td> <td>en</td> <td>of</td> <td></td> </tr> <tr> <td>da</td> <td>True</td> <td>og</td> <td>eller</td> <td></td> </tr> <tr> <td>de</td> <td>True</td> <td>und</td> <td>oder</td> <td></td> </tr> <tr> <td>en</td> <td>True</td> <td>and</td> <td>or</td> <td></td> </tr> <tr> <td>es</td> <td>True</td> <td>y</td> <td>o</td> <td></td> </tr> <tr> <td>fi</td> <td>True</td> <td>ja</td> <td>tai</td> <td></td> </tr> <tr> <td>fr</td> <td>False</td> <td>et</td> <td>ou</td> <td></td> </tr> <tr> <td>it</td> <td>True</td> <td>e</td> <td>o</td> <td></td> </tr> <tr> <td>la</td> <td>True</td> <td>et</td> <td>vel</td> <td></td> </tr> <tr> <td>nl</td> <td>True</td> <td>en</td> <td>of</td> <td></td> </tr> <tr> <td>no</td> <td>False</td> <td>og</td> <td>eller</td> <td></td> </tr> <tr> <td>pt</td> <td>True</td> <td>e</td> <td>ou</td> <td></td> </tr> <tr> <td>sw</td> <td>True</td> <td>na</td> <td>au</td> <td></td> </tr>
</tbody>
</table>

### `last`
### last

Specifies whether to use `sep` when joining the penultimate and last elements
of the list, when the number of elements is more than 2. In English, this
is what's known as [Oxford Comma](https://en.wikipedia.org/wiki/Serial_comma).
**By default** is set based on value of `lang` argument.
Specifies whether to use `sep` when joining the penultimate and last elements of the list, when the number of elements is more than 2. In English, this is what's known as [Oxford Comma](https://en.wikipedia.org/wiki/Serial_comma). **By default** is set based on value of `lang` argument.

### `sep`
### sep

The primary item separator to use. **Defaults to** `,` (a comma).

### `str`

say conjunction <May June August>, :str('Report[|s] for |list|');
say conjunction <Squishy Slushi Sushi>,
:str('Octop[us|i] [is|are] named |list|');
### str

Specifies a template to use when generating the string. You can use
special sequence `[|]` (e.g. `octop[us|i]`) where string to the left of
the `|` will be used when the list contains just one item and the string to
the right will be used otherwise. The other special sequence is
`|list|` that can will be replaced with the "conjuncted" items of the list.
**Defaults to** `|list|`

### `type`
```raku
say conjunction <May June August>, :str('Report[|s] for |list|');
say conjunction <Squishy Slushi Sushi>,
:str('Octop[us|i] [is|are] named |list|');
```

Takes either value `and` or value `or`. Specifies whether words
specified by `con` or by `dis` arguments should be used when joining the
last two elements of the list.
Specifies a template to use when generating the string. You can use special sequence `[|]` (e.g. `octop[us|i]`) where string to the left of the `|` will be used when the list contains just one item and the string to the right will be used otherwise. The other special sequence is `|list|` that can will be replaced with the "conjuncted" items of the list. **Defaults to** `|list|`.

# REPOSITORY
### type

Fork this module on GitHub:
https://github.com/raku-community-modules/Lingua-Conjunction
Takes either value `and` or value `or`. Specifies whether words specified by `con` or by `dis` arguments should be used when joining the last two elements of the list.

# BUGS
AUTHOR
======

To report bugs or request features, please use
https://github.com/raku-community-modules/Lingua-Conjunction/issues
This module was inspired by Perl's [Lingua::Conjunction](https://metacpan.org/pod/Lingua::Conjunction) and and [List::ToHumanString](https://metacpan.org/pod/List::ToHumanString). Some of the internal data was shamelessly ~~stolen~~ borrowed from [Lingua::Conjunction](https://metacpan.org/pod/Lingua::Conjunction)'s guts.

# AUTHOR
The rest is by Zoffix Znet (http://zoffix.com/)

This module was inspired by Perl's
[Lingua::Conjunction](https://metacpan.org/pod/Lingua::Conjunction) and
and my own
[List::ToHumanString](https://metacpan.org/pod/List::ToHumanString). Some
of the internal data was shamelessly ~~stolen~~ borrowed from
[Lingua::Conjunction](https://metacpan.org/pod/Lingua::Conjunction)'s guts.
COPYRIGHT AND LICENSE
=====================

The rest is by Zoffix Znet (http://zoffix.com/)
Copyright 2015 - 2017 Zoffix Znet

# LICENSE
Copyright 2018 - 2022 Raku Community

You can use and distribute this module under the terms of the
The Artistic License 2.0. See the `LICENSE` file included in this
distribution for complete details.
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

13 changes: 13 additions & 0 deletions dist.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name = Lingua-Conjunction

[ReadmeFromPod]
; enabled = false
filename = lib/Lingua/Conjunction.rakumod

[UploadToZef]

[PruneFiles]
; match = ^ 'xt/'

[Badges]
provider = github-actions/test.yml
47 changes: 0 additions & 47 deletions lib/Lingua/Conjunction.pm6

This file was deleted.

Loading

0 comments on commit 6021248

Please sign in to comment.