Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kfly8 committed Aug 18, 2024
1 parent d8c6ee8 commit 2fe2e84
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion META.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"abstract" : "Store constraints for Data::Checks, Type::Tiny, Moose and so on.",
"abstract" : "Store constraints for Data::Checks, Type::Tiny, Moose and more.",
"author" : [
"kobaken <[email protected]>"
],
Expand Down
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Actions Status](https://github.com/kfly8/kura/actions/workflows/test.yml/badge.svg)](https://github.com/kfly8/kura/actions) [![Coverage Status](https://img.shields.io/coveralls/kfly8/kura/main.svg?style=flat)](https://coveralls.io/r/kfly8/kura?branch=main) [![MetaCPAN Release](https://badge.fury.io/pl/kura.svg)](https://metacpan.org/release/kura)
# NAME

kura - Store constraints for Data::Checks, Type::Tiny, Moose and so on.
kura - Store constraints for Data::Checks, Type::Tiny, Moose and more.

# SYNOPSIS

Expand Down Expand Up @@ -38,18 +38,20 @@ ok !Qux->check('foo') && !Qux->check('bar') && !Qux->check('baz') && Qux->check

# DESCRIPTION

Kura - means "Traditional Japanese storehouse" - stores constraints, such as [Data::Checks](https://metacpan.org/pod/Data%3A%3AChecks), [Type::Tiny](https://metacpan.org/pod/Type%3A%3ATiny), [Moose::Meta::TypeConstraint](https://metacpan.org/pod/Moose%3A%3AMeta%3A%3ATypeConstraint), [Mouse::Meta::TypeConstraint](https://metacpan.org/pod/Mouse%3A%3AMeta%3A%3ATypeConstraint), [Specio](https://metacpan.org/pod/Specio) and so on. Of course, you can use [Moo](https://metacpan.org/pod/Moo) with kura by using [Type::Tiny](https://metacpan.org/pod/Type%3A%3ATiny) constraints.
Kura - means "Traditional Japanese storehouse" - stores constraints, such as [Data::Checks](https://metacpan.org/pod/Data%3A%3AChecks), [Type::Tiny](https://metacpan.org/pod/Type%3A%3ATiny), [Moose::Meta::TypeConstraint](https://metacpan.org/pod/Moose%3A%3AMeta%3A%3ATypeConstraint), [Mouse::Meta::TypeConstraint](https://metacpan.org/pod/Mouse%3A%3AMeta%3A%3ATypeConstraint), [Specio](https://metacpan.org/pod/Specio) and more. It can even be used with [Moo](https://metacpan.org/pod/Moo) when combined with [Type::Tiny](https://metacpan.org/pod/Type%3A%3ATiny) constraints.

```
Data::Checks -----------------> ********
* *
Type::Tiny -------------------> * *
* Kura * --> Call Named Value Constraints!
Moose::Meta::TypeConstraint --> * *
* *
YourFavoriteChecker ----------> ********
Data::Checks -----------------> +--------+
| |
Type::Tiny -------------------> | |
| Kura | ---> Named Value Constraints!
Moose::Meta::TypeConstraint --> | |
| |
YourFavoriteChecker ----------> +--------+
```

If your project uses multiple constraint libraries, kura allows you to simplify your codebase and making it easier to manage different constraint systems. This is especially useful in large projects or when migrating from one constraint system to another.

# HOW TO USE

## Declaring a constraint
Expand All @@ -60,9 +62,9 @@ It's easy to use to store constraints in a package:
use kura NAME => CONSTRAINT;
```

This constraint must be a any object that has a `check` method, or a code reference that returns true or false.
This constraint must be a any object that has a `check` method or a code reference that returns true or false.

Order of declarations is important, child constraints must be declared before parent constraints.
When declaring constraints, it is important to define child constraints before their parent constraints to avoid errors. For example:

```perl
# Bad order
Expand All @@ -74,6 +76,8 @@ use kura Child => Str;
use kura Parent => Dict[ name => Child ];
```

If constraints are declared in the wrong order, you might encounter errors like “Bareword not allowed.” Ensure that all dependencies are declared beforehand to prevent such issues.

## Using a constraint

You can use the declared constraint as follows:
Expand Down Expand Up @@ -113,7 +117,7 @@ hello(); # 'Hello, World!'

# Customizing

## $EXPORTER\_CLASS
## `$EXPORTER_CLASS`

`$EXPORTER_CLASS` is a package name of the Exporter class, default is [Exporter](https://metacpan.org/pod/Exporter).
You can change this class by setting `$kura::EXPORTER_CLASS`.
Expand Down
28 changes: 16 additions & 12 deletions lib/kura.pm
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ __END__
=head1 NAME
kura - Store constraints for Data::Checks, Type::Tiny, Moose and so on.
kura - Store constraints for Data::Checks, Type::Tiny, Moose and more.
=head1 SYNOPSIS
Expand Down Expand Up @@ -168,15 +168,17 @@ kura - Store constraints for Data::Checks, Type::Tiny, Moose and so on.
=head1 DESCRIPTION
Kura - means "Traditional Japanese storehouse" - stores constraints, such as L<Data::Checks>, L<Type::Tiny>, L<Moose::Meta::TypeConstraint>, L<Mouse::Meta::TypeConstraint>, L<Specio> and so on. Of course, you can use L<Moo> with kura by using L<Type::Tiny> constraints.
Kura - means "Traditional Japanese storehouse" - stores constraints, such as L<Data::Checks>, L<Type::Tiny>, L<Moose::Meta::TypeConstraint>, L<Mouse::Meta::TypeConstraint>, L<Specio> and more. It can even be used with L<Moo> when combined with L<Type::Tiny> constraints.
Data::Checks -----------------> ********
* *
Type::Tiny -------------------> * *
* Kura * --> Call Named Value Constraints!
Moose::Meta::TypeConstraint --> * *
* *
YourFavoriteChecker ----------> ********
Data::Checks -----------------> +--------+
| |
Type::Tiny -------------------> | |
| Kura | ---> Named Value Constraints!
Moose::Meta::TypeConstraint --> | |
| |
YourFavoriteChecker ----------> +--------+
If your project uses multiple constraint libraries, kura allows you to simplify your codebase and making it easier to manage different constraint systems. This is especially useful in large projects or when migrating from one constraint system to another.
=head1 HOW TO USE
Expand All @@ -186,9 +188,9 @@ It's easy to use to store constraints in a package:
use kura NAME => CONSTRAINT;
This constraint must be a any object that has a C<check> method, or a code reference that returns true or false.
This constraint must be a any object that has a C<check> method or a code reference that returns true or false.
Order of declarations is important, child constraints must be declared before parent constraints.
When declaring constraints, it is important to define child constraints before their parent constraints to avoid errors. For example:
# Bad order
use kura Parent => Dict[ name => Child ]; # => Bareword "Child" not allowed
Expand All @@ -198,6 +200,8 @@ Order of declarations is important, child constraints must be declared before pa
use kura Child => Str;
use kura Parent => Dict[ name => Child ];
If constraints are declared in the wrong order, you might encounter errors like “Bareword not allowed.” Ensure that all dependencies are declared beforehand to prevent such issues.
=head2 Using a constraint
You can use the declared constraint as follows:
Expand Down Expand Up @@ -231,7 +235,7 @@ So, you can add other functions to C<@EXPORT_OK>:
=head1 Customizing
=head2 $EXPORTER_CLASS
=head2 C<$EXPORTER_CLASS>
C<$EXPORTER_CLASS> is a package name of the Exporter class, default is L<Exporter>.
You can change this class by setting C<$kura::EXPORTER_CLASS>.
Expand Down

0 comments on commit 2fe2e84

Please sign in to comment.