Revision c6bc1816
Von Sven Schöling vor etwa 9 Jahren hinzugefügt
modules/override/YAML/Dumper/Base.pm | ||
---|---|---|
1 | 1 |
package YAML::Dumper::Base; |
2 |
use strict; use warnings; |
|
3 |
use YAML::Base; use base 'YAML::Base'; |
|
2 |
|
|
3 |
use YAML::Mo; |
|
4 |
|
|
4 | 5 |
use YAML::Node; |
5 | 6 |
|
6 | 7 |
# YAML Dumping options |
7 |
field spec_version => '1.0'; |
|
8 |
field indent_width => 2; |
|
9 |
field use_header => 1; |
|
10 |
field use_version => 0; |
|
11 |
field sort_keys => 1; |
|
12 |
field anchor_prefix => ''; |
|
13 |
field dump_code => 0; |
|
14 |
field use_block => 0; |
|
15 |
field use_fold => 0; |
|
16 |
field compress_series => 1; |
|
17 |
field inline_series => 0; |
|
18 |
field use_aliases => 1; |
|
19 |
field purity => 0; |
|
20 |
field stringify => 0; |
|
8 |
has spec_version => default => sub {'1.0'}; |
|
9 |
has indent_width => default => sub {2}; |
|
10 |
has use_header => default => sub {1}; |
|
11 |
has use_version => default => sub {0}; |
|
12 |
has sort_keys => default => sub {1}; |
|
13 |
has anchor_prefix => default => sub {''}; |
|
14 |
has dump_code => default => sub {0}; |
|
15 |
has use_block => default => sub {0}; |
|
16 |
has use_fold => default => sub {0}; |
|
17 |
has compress_series => default => sub {1}; |
|
18 |
has inline_series => default => sub {0}; |
|
19 |
has use_aliases => default => sub {1}; |
|
20 |
has purity => default => sub {0}; |
|
21 |
has stringify => default => sub {0}; |
|
22 |
has quote_numeric_strings => default => sub {0}; |
|
21 | 23 |
|
22 | 24 |
# Properties |
23 |
field stream => '';
|
|
24 |
field document => 0;
|
|
25 |
field transferred => {};
|
|
26 |
field id_refcnt => {};
|
|
27 |
field id_anchor => {};
|
|
28 |
field anchor => 1;
|
|
29 |
field level => 0;
|
|
30 |
field offset => [];
|
|
31 |
field headless => 0;
|
|
32 |
field blessed_map => {};
|
|
25 |
has stream => default => sub {''};
|
|
26 |
has document => default => sub {0};
|
|
27 |
has transferred => default => sub {{}};
|
|
28 |
has id_refcnt => default => sub {{}};
|
|
29 |
has id_anchor => default => sub {{}};
|
|
30 |
has anchor => default => sub {1};
|
|
31 |
has level => default => sub {0};
|
|
32 |
has offset => default => sub {[]};
|
|
33 |
has headless => default => sub {0};
|
|
34 |
has blessed_map => default => sub {{}};
|
|
33 | 35 |
|
34 | 36 |
# Global Options are an idea taken from Data::Dumper. Really they are just |
35 | 37 |
# sugar on top of real OO properties. They make the simple Dump/Load API |
... | ... | |
64 | 66 |
if defined $YAML::Purity; |
65 | 67 |
$self->stringify($YAML::Stringify) |
66 | 68 |
if defined $YAML::Stringify; |
69 |
$self->quote_numeric_strings($YAML::QuoteNumericStrings) |
|
70 |
if defined $YAML::QuoteNumericStrings; |
|
67 | 71 |
} |
68 | 72 |
|
69 | 73 |
sub dump { |
... | ... | |
75 | 79 |
my $self = shift; |
76 | 80 |
my ($ref) = @_; |
77 | 81 |
$ref = \$_[0] unless ref $ref; |
78 |
my (undef, undef, $node_id) = YAML::Base->node_info($ref);
|
|
82 |
my (undef, undef, $node_id) = YAML::Mo::Object->node_info($ref);
|
|
79 | 83 |
$self->{blessed_map}->{$node_id}; |
80 | 84 |
} |
81 |
|
|
85 |
|
|
82 | 86 |
sub bless { |
83 | 87 |
my $self = shift; |
84 | 88 |
my ($ref, $blessing) = @_; |
85 | 89 |
my $ynode; |
86 | 90 |
$ref = \$_[0] unless ref $ref; |
87 |
my (undef, undef, $node_id) = YAML::Base->node_info($ref);
|
|
91 |
my (undef, undef, $node_id) = YAML::Mo::Object->node_info($ref);
|
|
88 | 92 |
if (not defined $blessing) { |
89 | 93 |
$ynode = YAML::Node->new($ref); |
90 | 94 |
} |
... | ... | |
105 | 109 |
} |
106 | 110 |
|
107 | 111 |
1; |
108 |
|
|
109 |
__END__ |
|
110 |
|
|
111 |
=head1 NAME |
|
112 |
|
|
113 |
YAML::Dumper::Base - Base class for YAML Dumper classes |
|
114 |
|
|
115 |
=head1 SYNOPSIS |
|
116 |
|
|
117 |
package YAML::Dumper::Something; |
|
118 |
use YAML::Dumper::Base -base; |
|
119 |
|
|
120 |
=head1 DESCRIPTION |
|
121 |
|
|
122 |
YAML::Dumper::Base is a base class for creating YAML dumper classes. |
|
123 |
|
|
124 |
=head1 AUTHOR |
|
125 |
|
|
126 |
Ingy döt Net <ingy@cpan.org> |
|
127 |
|
|
128 |
=head1 COPYRIGHT |
|
129 |
|
|
130 |
Copyright (c) 2006. Ingy döt Net. All rights reserved. |
|
131 |
|
|
132 |
This program is free software; you can redistribute it and/or modify it |
|
133 |
under the same terms as Perl itself. |
|
134 |
|
|
135 |
See L<http://www.perl.com/perl/misc/Artistic.html> |
|
136 |
|
|
137 |
=cut |
Auch abrufbar als: Unified diff
YAML: Versionsupdate