line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Storage::Format::YAML; |
2
|
|
|
|
|
|
|
# ABSTRACT: A YAML serialization role |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.50'; |
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
3299
|
use Moose::Role; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
36
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# When I add YAML::LibYAML |
9
|
|
|
|
|
|
|
# Tests break because tye YAML is invalid...? |
10
|
|
|
|
|
|
|
# -dcp |
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
19593
|
use YAML::Any qw(Load Dump); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
44
|
|
13
|
4
|
|
|
4
|
|
1030
|
use namespace::autoclean; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
35
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
requires 'pack'; |
16
|
|
|
|
|
|
|
requires 'unpack'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub thaw { |
19
|
4
|
|
|
4
|
1
|
20823
|
my ( $class, $yaml, @args ) = @_; |
20
|
4
|
|
|
|
|
20
|
$class->unpack( Load($yaml), @args ); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub freeze { |
24
|
4
|
|
|
4
|
1
|
17748
|
my ( $self, @args ) = @_; |
25
|
4
|
|
|
|
|
27
|
Dump( $self->pack(@args) ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
4
|
|
601
|
no Moose::Role; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
20
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__END__ |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=pod |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=encoding UTF-8 |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 NAME |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
MooseX::Storage::Format::YAML - A YAML serialization role |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 VERSION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
version 0.50 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
package Point; |
49
|
|
|
|
|
|
|
use Moose; |
50
|
|
|
|
|
|
|
use MooseX::Storage; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
with Storage('format' => 'YAML'); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has 'x' => (is => 'rw', isa => 'Int'); |
55
|
|
|
|
|
|
|
has 'y' => (is => 'rw', isa => 'Int'); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $p = Point->new(x => 10, y => 10); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
## methods to freeze/thaw into |
62
|
|
|
|
|
|
|
## a specified serialization format |
63
|
|
|
|
|
|
|
## (in this case YAML) |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# pack the class into a YAML string |
66
|
|
|
|
|
|
|
$p->freeze(); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# ---- |
69
|
|
|
|
|
|
|
# __CLASS__: "Point" |
70
|
|
|
|
|
|
|
# x: 10 |
71
|
|
|
|
|
|
|
# y: 10 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# unpack the JSON string into a class |
74
|
|
|
|
|
|
|
my $p2 = Point->thaw(<<YAML); |
75
|
|
|
|
|
|
|
---- |
76
|
|
|
|
|
|
|
__CLASS__: "Point" |
77
|
|
|
|
|
|
|
x: 10 |
78
|
|
|
|
|
|
|
y: 10 |
79
|
|
|
|
|
|
|
YAML |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 METHODS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=over 4 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item B<freeze> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item B<thaw ($yaml)> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 Introspection |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=over 4 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item B<meta> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 BUGS |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
All complex software has bugs lurking in it, and this module is no |
102
|
|
|
|
|
|
|
exception. If you find a bug please or add the bug to cpan-RT |
103
|
|
|
|
|
|
|
at L<https://rt.cpan.org/Dist/Display.html?Queue=MooseX-Storage>. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AUTHORS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=over 4 |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Chris Prather <chris.prather@iinteractive.com> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Stevan Little <stevan.little@iinteractive.com> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
×××× ×§××'×× (Yuval Kogman) <nothingmuch@woobling.org> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=back |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This software is copyright (c) 2007 by Infinity Interactive, Inc.. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
128
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |