| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MooseX::Types::IO::All; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
25742
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
49
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:FAYLAND'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
2230
|
use IO::All; |
|
|
1
|
|
|
|
|
22941
|
|
|
|
1
|
|
|
|
|
14
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
1849
|
use MooseX::Types::Moose qw/Str ScalarRef FileHandle ArrayRef/; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use namespace::clean; |
|
13
|
|
|
|
|
|
|
use MooseX::Types -declare => [qw( IO_All )]; |
|
14
|
|
|
|
|
|
|
use Fcntl 'SEEK_SET'; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $global = class_type 'IO::All'; |
|
17
|
|
|
|
|
|
|
subtype IO_All, as 'IO::All'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
coerce IO_All, |
|
20
|
|
|
|
|
|
|
from Str, |
|
21
|
|
|
|
|
|
|
via { |
|
22
|
|
|
|
|
|
|
io $_; |
|
23
|
|
|
|
|
|
|
}, |
|
24
|
|
|
|
|
|
|
from ScalarRef, |
|
25
|
|
|
|
|
|
|
via { |
|
26
|
|
|
|
|
|
|
my $s = io('$'); |
|
27
|
|
|
|
|
|
|
$s->print($$_); |
|
28
|
|
|
|
|
|
|
$s->seek(0, SEEK_SET); |
|
29
|
|
|
|
|
|
|
return $s; |
|
30
|
|
|
|
|
|
|
}; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$global->coercion(IO_All->coercion); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
|
35
|
|
|
|
|
|
|
__END__ |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
MooseX::Types::IO::All - L<IO::All> related constraints and coercions for Moose |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
package Foo; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
use Moose; |
|
46
|
|
|
|
|
|
|
use MooseX::Types::IO::All 'IO_All'; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has io => ( |
|
49
|
|
|
|
|
|
|
isa => IO_All, |
|
50
|
|
|
|
|
|
|
is => "rw", |
|
51
|
|
|
|
|
|
|
coerce => 1, |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# later |
|
55
|
|
|
|
|
|
|
my $str = "test for IO::String\n line 2"; |
|
56
|
|
|
|
|
|
|
my $foo = Foo->new( io => \$str ); |
|
57
|
|
|
|
|
|
|
my $io = $foo->io; # IO::All::String |
|
58
|
|
|
|
|
|
|
# or |
|
59
|
|
|
|
|
|
|
my $filename = "file.txt"; |
|
60
|
|
|
|
|
|
|
my $foo = Foo->new( io => $filename ); |
|
61
|
|
|
|
|
|
|
my $io = $foo->io; # IO::All |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This module packages one L<Moose::Util::TypeConstraints> with coercions, |
|
66
|
|
|
|
|
|
|
designed to work with the L<IO::All> suite of objects. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 CONSTRAINTS |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=over 4 |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item B<Str> |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
io $_; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
L<IO::All> object. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item B<ScalarRef> |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $s = io('$'); |
|
81
|
|
|
|
|
|
|
$s->print($$_); |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
L<IO::All::String> object. so generally u need |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
${ $s->string_ref } # the content |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
instead of ->all or ->slurp |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
L<Moose>, L<MooseX::Types>, L<MooseX::Types::IO>, L<IO::All> |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 AUTHOR |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Fayland Lam, C<< <fayland at gmail.com> >> |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
The L<Moose> Team |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Copyright 2008 Fayland Lam, all rights reserved. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
108
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |