line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
1430782
|
use 5.008001; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
77
|
|
2
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
69
|
|
3
|
2
|
|
|
2
|
|
18
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
150
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package MooseX::Types::Stringlike; |
6
|
|
|
|
|
|
|
# ABSTRACT: Moose type constraints for strings or string-like objects |
7
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1742
|
use MooseX::Types -declare => [ qw/Stringable Stringlike ArrayRefOfStringable ArrayRefOfStringlike / ]; |
|
2
|
|
|
|
|
14033343
|
|
|
2
|
|
|
|
|
22
|
|
10
|
2
|
|
|
2
|
|
588504
|
use MooseX::Types::Moose qw/Str Object ArrayRef/; |
|
2
|
|
|
|
|
34110
|
|
|
2
|
|
|
|
|
25
|
|
11
|
2
|
|
|
2
|
|
10565
|
use overload (); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
615
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Thanks ilmari for suggesting something like this |
14
|
|
|
|
|
|
|
subtype Stringable, |
15
|
|
|
|
|
|
|
as Object, |
16
|
|
|
|
|
|
|
where { overload::Method($_, '""') }; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
subtype Stringlike, |
19
|
|
|
|
|
|
|
as Str; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
coerce Stringlike, |
22
|
|
|
|
|
|
|
from Stringable, |
23
|
|
|
|
|
|
|
via { "$_" }; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
subtype ArrayRefOfStringable, |
27
|
|
|
|
|
|
|
as ArrayRef[Stringable]; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
subtype ArrayRefOfStringlike, |
30
|
|
|
|
|
|
|
as ArrayRef[Stringlike]; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
coerce ArrayRefOfStringlike, |
33
|
|
|
|
|
|
|
from ArrayRefOfStringable, |
34
|
|
|
|
|
|
|
via { [ map { "$_" } @$_ ] }; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# vim: ts=2 sts=2 sw=2 et: |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=pod |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=encoding UTF-8 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
MooseX::Types::Stringlike - Moose type constraints for strings or string-like objects |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 VERSION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
version 0.003 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SYNOPSIS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
package Foo; |
58
|
|
|
|
|
|
|
use Moose; |
59
|
|
|
|
|
|
|
use MooseX::Types::Stringlike qw/Stringlike Stringable ArrayRefOfStringlike ArrayRefOfStringable/; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has path => ( |
62
|
|
|
|
|
|
|
is => 'ro', |
63
|
|
|
|
|
|
|
isa => Stringlike, |
64
|
|
|
|
|
|
|
coerce => 1 |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has stringable_object => ( |
68
|
|
|
|
|
|
|
is => 'ro', |
69
|
|
|
|
|
|
|
isa => Stringable, |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has paths => ( |
73
|
|
|
|
|
|
|
is => 'ro', |
74
|
|
|
|
|
|
|
isa => ArrayRefOfStringlike, |
75
|
|
|
|
|
|
|
coerce => 1 |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
has stringable_objects => ( |
79
|
|
|
|
|
|
|
is => 'ro', |
80
|
|
|
|
|
|
|
isa => ArrayRefOfStringable, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DESCRIPTION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This module provides a more general version of the C<Str> type. If coercions |
86
|
|
|
|
|
|
|
are enabled, it will accepts objects that overload stringification and coerces |
87
|
|
|
|
|
|
|
them into strings. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=for Pod::Coverage method_names_here |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 SUBTYPES |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This module uses L<MooseX::Types> to define the following subtypes. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 Stringlike |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
C<Stringlike> is a subtype of C<Str>. It can coerce C<Stringable> objects into |
98
|
|
|
|
|
|
|
a string. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 Stringable |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
C<Stringable> is a subtype of C<Object> where the object has overloaded stringification. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 ArrayRefOfStringlike |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
C<ArrayRefStringlike> is a subtype of C<ArrayRef[Str]>. It can coerce C<ArrayRefOfStringable> objects into |
107
|
|
|
|
|
|
|
an arrayref of strings. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 ArrayRefOfStringable |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
C<ArrayRefOfStringable> is a subtype of C<ArrayRef[Object]> where the objects have overloaded stringification. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SEE ALSO |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over 4 |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
L<Moose::Manual::Types> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
L<MooseX::Types> |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L<MooseX::Types::Moose> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=back |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 ACKNOWLEDGMENTS |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Thank you to Dagfinn Ilmari Mannsåker for the idea on IRC that led to this module. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SUPPORT |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 Bugs / Feature Requests |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Please report any bugs or feature requests through the issue tracker |
142
|
|
|
|
|
|
|
at L<https://github.com/dagolden/MooseX-Types-Stringlike/issues>. |
143
|
|
|
|
|
|
|
You will be notified automatically of any progress on your issue. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 Source Code |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This is open source software. The code repository is available for |
148
|
|
|
|
|
|
|
public review and contribution under the terms of the license. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L<https://github.com/dagolden/MooseX-Types-Stringlike> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
git clone https://github.com/dagolden/MooseX-Types-Stringlike.git |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
David Golden <dagolden@cpan.org> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This software is Copyright (c) 2012 by David Golden. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This is free software, licensed under: |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
The Apache License, Version 2.0, January 2004 |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |