line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Socialtext::WikiObject::YAML; |
2
|
2
|
|
|
2
|
|
36339
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
85
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
67
|
|
4
|
2
|
|
|
2
|
|
11
|
use base 'Socialtext::WikiObject::PreBlock'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1236
|
|
5
|
2
|
|
|
2
|
|
1664
|
use YAML; |
|
2
|
|
|
|
|
23650
|
|
|
2
|
|
|
|
|
467
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Socialtext::WikiObject::YAML - Parse page content as YAML |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 METHODS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head2 parse_wikitext() |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Override parent method to load the wikitext as YAML. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub parse_wikitext { |
24
|
3
|
|
|
3
|
1
|
7
|
my $self = shift; |
25
|
3
|
|
|
|
|
5
|
my $wikitext = shift; |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
|
|
23
|
$self->SUPER::parse_wikitext($wikitext); |
28
|
3
|
|
|
|
|
18
|
$wikitext = $self->pre_block; |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
|
|
8
|
my $data = {}; |
31
|
3
|
|
|
|
|
5
|
eval { $data = Load($wikitext) }; |
|
3
|
|
|
|
|
12
|
|
32
|
3
|
50
|
|
|
|
44785
|
$data->{yaml_error} = $@ if $@; |
33
|
3
|
|
|
|
|
11
|
$self->{_hash} = $data; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Store the data into $self |
36
|
3
|
|
|
|
|
12
|
for my $k (keys %$data) { |
37
|
3
|
|
|
|
|
26
|
$self->{$k} = $self->{lc $k} = $data->{$k}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 as_hash |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Return the parsed YAML as a hash. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
2
|
1
|
2120
|
sub as_hash { $_[0]->{_hash} } |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# TODO - Add AUTOLOADed methods? |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 AUTHOR |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Luke Closs, C<< >> |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 BUGS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
58
|
|
|
|
|
|
|
L. |
59
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
60
|
|
|
|
|
|
|
your bug as I make changes. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Copyright 2007 Luke Closs, all rights reserved. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
67
|
|
|
|
|
|
|
under the same terms as Perl itself. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |