Skip to content

Commit

Permalink
Updated documentation; added mailmap
Browse files Browse the repository at this point in the history
  • Loading branch information
cxw42 committed Oct 3, 2019
1 parent cef9744 commit 34b2d1b
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 36 deletions.
4 changes: 4 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Ivan Butorin <[email protected]> <[email protected]>
Chris White <[email protected]> <[email protected]>
Chris White <[email protected]> <[email protected]>
Toby Inkster <[email protected]> <[email protected]>
14 changes: 9 additions & 5 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Revision history for Class-Tiny-ConstrainedAccessor

0.000013 2019-10-02
- Arguments can now be provided in a hashref (#7).
Thanks to FISHBONE for code.

0.000012 2019-09-20
- Production release of 0.000011

Expand Down Expand Up @@ -31,16 +35,16 @@ Revision history for Class-Tiny-ConstrainedAccessor
- Fix tests to run on <5.010

0.000004 2019-03-22
- Check constructor parameters (GH-4)
- Add option to suppress BUILD generation (GH-5)
- Check constructor parameters (#4)
- Add option to suppress BUILD generation (#5)

0.000003 2019-03-19
- Updated documentation. First non-TRIAL release.

0.000002 2019-03-17 (TRIAL VERSION)
- Support other type systems (GH-1). Thanks to TOBYINK for code.
- Constraint-check default values (GH-3).
- Run as far back as 5.006 (GH-2).
- Support other type systems (#1). Thanks to TOBYINK for code.
- Constraint-check default values (#3).
- Run as far back as 5.006 (#2).

0.000001 2019-03-12 (TRIAL VERSION)
- First version, released on an unsuspecting world.
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ t/08-custom-constraint.t
t/10-moox-types-mooselike.t
t/11-mousex-types.t
t/12-specio.t
t/13-type-tiny-hashref.t
t/MY/Class/CustomConstraint.pm
t/MY/Class/MooseXTypes.pm
t/MY/Class/MooXTypesMooseLike.pm
Expand All @@ -27,6 +28,7 @@ t/MY/Class/Specio.pm
t/MY/Class/TypeTiny.pm
t/MY/Class/TypeTinyBadDefaults.pm
t/MY/Class/TypeTinyBUILD.pm
t/MY/Class/TypeTinyHashref.pm
t/MY/Class/TypeTinyNOBUILD.pm
t/MY/Class/ValueIsValid.pm
t/MY/Helpers.pm
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.SKIP
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Files used only for development
^\.editorconfig
^\.[^\\\/]*\.yml
^\.mailmap

# Miscellaneous
\bfoo\b.*
Expand Down
2 changes: 2 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ my %opts = (

x_contributors => [
# Use CPAN emails so MetaCPAN will pick them up.
# In alphabetical order, except for the original author.
'Christopher White <[email protected]>',
'Ivan Butorin <[email protected]>',
'Toby Inkster <[email protected]>',
],

Expand Down
24 changes: 16 additions & 8 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,19 @@ CONSTRAINTS WITHOUT A TYPE SYSTEM

SUBROUTINES
import
Creates the accessors you have requested. Basic usage:
Creates the accessors you have requested. Constraints can be passed as a
list or hashref of variable/constraint pairs. Basic usage:

# Constraints are passed as a list of pairs
use Class::Tiny::ConstrainedAccessor
name => constraint
[, name => constraint ...]; # ... any number of name=>constraint pairs
[, name2 => constraint ...]; # ... any number of name=>constraint pairs

# Constraints are passed as a hashref
use Class::Tiny::ConstrainedAccessor {
name => constraint,
[, name2 => constraint ...]; # ... any number of name=>constraint pairs
};

This also creates a BUILD() subroutine to check the constructor
parameters, if a "BUILD()" doesn't already exist.
Expand All @@ -71,8 +79,8 @@ SUBROUTINES

OPTIONS
To specify options, pass an arrayref as the first argument on the `use`
line. This is to leave room for someday carrying attributes and
constraints in a hashref. For example:
line. This is because a hashref carries attributes and constraints. For
example:

use Class::Tiny::ConstrainedAccessor [ OPTION=>value ],
name => constraint ...;
Expand All @@ -92,7 +100,7 @@ OPTIONS

AUTHORS
Created by Christopher White, "<cxwembedded at gmail.com>". Thanks to
Toby Inkster for code contributions.
Toby Inkster (TOBYINK) and Ivan Butorin (FISHBONE) for code contributions.

BUGS
Please report any bugs or feature requests through the GitHub Issues
Expand All @@ -112,12 +120,12 @@ SUPPORT

<https://github.com/cxw42/Class-Tiny-ConstrainedAccessor>

* Search CPAN
* MetaCPAN

<https://metacpan.org/release/Class-Tiny-ConstrainedAccessor>
<https://metacpan.org/pod/Class::Tiny::ConstrainedAccessor>

LICENSE
Copyright 2019 Christopher White.
Copyright 2019 Christopher White and contributors.

This program is free software; you can redistribute it and/or modify it
under the terms of the the Apache License (2.0). You may obtain a copy of
Expand Down
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,19 @@ for optimization than general-purpose type systems.

## import

Creates the accessors you have requested. Basic usage:
Creates the accessors you have requested. Constraints can be passed as a list
or hashref of variable/constraint pairs. Basic usage:

# Constraints are passed as a list of pairs
use Class::Tiny::ConstrainedAccessor
name => constraint
[, name => constraint ...]; # ... any number of name=>constraint pairs
[, name2 => constraint ...]; # ... any number of name=>constraint pairs

# Constraints are passed as a hashref
use Class::Tiny::ConstrainedAccessor {
name => constraint,
[, name2 => constraint ...]; # ... any number of name=>constraint pairs
};

This also creates a [BUILD()](https://metacpan.org/pod/Class::Tiny#BUILD) subroutine to check the
constructor parameters, if a `BUILD()` doesn't already exist.
Expand All @@ -77,8 +85,8 @@ own `BUILD()` if you want to.
# OPTIONS

To specify options, pass an **arrayref** as the first argument on the \`use\`
line. This is to leave room for someday carrying attributes and constraints in
a hashref. For example:
line. This is because a hashref carries attributes and constraints.
For example:

use Class::Tiny::ConstrainedAccessor [ OPTION=>value ],
name => constraint ...;
Expand All @@ -100,7 +108,7 @@ Valid options are:
# AUTHORS

Created by Christopher White, `<cxwembedded at gmail.com>`. Thanks to
Toby Inkster for code contributions.
Toby Inkster (TOBYINK) and Ivan Butorin (FISHBONE) for code contributions.

# BUGS

Expand All @@ -121,13 +129,13 @@ You can also look for information at:

[https://github.com/cxw42/Class-Tiny-ConstrainedAccessor](https://github.com/cxw42/Class-Tiny-ConstrainedAccessor)

- Search CPAN
- MetaCPAN

[https://metacpan.org/release/Class-Tiny-ConstrainedAccessor](https://metacpan.org/release/Class-Tiny-ConstrainedAccessor)
[https://metacpan.org/pod/Class::Tiny::ConstrainedAccessor](https://metacpan.org/pod/Class::Tiny::ConstrainedAccessor)

# LICENSE

Copyright 2019 Christopher White.
Copyright 2019 Christopher White and contributors.

This program is free software; you can redistribute it and/or modify it
under the terms of the the Apache License (2.0). You may obtain a
Expand Down
29 changes: 15 additions & 14 deletions lib/Class/Tiny/ConstrainedAccessor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use strict;
use warnings;
use Class::Tiny;

our $VERSION = '0.000012';
our $VERSION = '0.000013';

# Docs {{{1

Expand All @@ -23,7 +23,6 @@ can come from L<Type::Tiny>, L<MooseX::Types>, L<MooX::Types::MooseLike>,
L<MouseX::Types>, or L<Specio>. Alternatively, constraints can be applied
using the technique described in
L<"Constraints without a type system"|/CONSTRAINTS WITHOUT A TYPE SYSTEM>.
Constraints can be passed as a B<hash> or a B<hasref>.
Example of a class using this package:
Expand Down Expand Up @@ -72,17 +71,19 @@ for optimization than general-purpose type systems.
=head2 import
Creates the accessors you have requested. Basic usage:
Creates the accessors you have requested. Constraints can be passed as a list
or hashref of variable/constraint pairs. Basic usage:
# constraints are passed as a hash
# Constraints are passed as a list of pairs
use Class::Tiny::ConstrainedAccessor
name => constraint
[, name => constraint ...]; # ... any number of name=>constraint pairs
[, name2 => constraint ...]; # ... any number of name=>constraint pairs
# constraints are passed as a hashref
# Constraints are passed as a hashref
use Class::Tiny::ConstrainedAccessor {
name => constraint,
}
[, name2 => constraint ...]; # ... any number of name=>constraint pairs
};
This also creates a L<BUILD()|Class::Tiny/BUILD> subroutine to check the
constructor parameters, if a C<BUILD()> doesn't already exist.
Expand All @@ -95,8 +96,8 @@ own C<BUILD()> if you want to.
=head1 OPTIONS
To specify options, pass an B<arrayref> as the first argument on the `use`
line. This is to leave room for someday carrying attributes and constraints in
a hashref. For example:
line. This is because a hashref carries attributes and constraints.
For example:
use Class::Tiny::ConstrainedAccessor [ OPTION=>value ],
name => constraint ...;
Expand Down Expand Up @@ -131,7 +132,6 @@ sub import {
%opts = @{+shift} if ref $_[0] eq 'ARRAY';

my %constraints;
# Both hashref and hash are supported for constraints
if (ref $_[0] eq 'HASH' && scalar @_ == 1) {
%constraints = %{$_[0]};
} else {
Expand Down Expand Up @@ -292,7 +292,7 @@ __END__
=head1 AUTHORS
Created by Christopher White, C<< <cxwembedded at gmail.com> >>. Thanks to
Toby Inkster for code contributions.
Toby Inkster (TOBYINK) and Ivan Butorin (FISHBONE) for code contributions.
=head1 BUGS
Expand All @@ -315,15 +315,15 @@ You can also look for information at:
L<https://github.com/cxw42/Class-Tiny-ConstrainedAccessor>
=item * Search CPAN
=item * MetaCPAN
L<https://metacpan.org/release/Class-Tiny-ConstrainedAccessor>
L<https://metacpan.org/pod/Class::Tiny::ConstrainedAccessor>
=back
=head1 LICENSE
Copyright 2019 Christopher White.
Copyright 2019 Christopher White and contributors.
This program is free software; you can redistribute it and/or modify it
under the terms of the the Apache License (2.0). You may obtain a
Expand All @@ -338,5 +338,6 @@ See the License for the specific language governing permissions and
limitations under the License.
=cut
# }}}1
# vi: set fdm=marker:
2 changes: 1 addition & 1 deletion t/MY/Class/TypeTinyHashref.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use vars::i '$MediumInteger' => Type::Tiny->new(
constraint => sub { looks_like_number($_) and $_ >= 10 and $_ < 20 }
);

# Pass constraints in form of a hashref
# Pass constraints in a hashref
use Class::Tiny::ConstrainedAccessor {
medint => $MediumInteger, # create accessor sub medint()
med_with_default => $MediumInteger,
Expand Down

0 comments on commit 34b2d1b

Please sign in to comment.