Socialtext::WikiObject::YAML - Parse page content as YAML


Socialtext-Resting-Utils documentation Contained in the Socialtext-Resting-Utils distribution.

Index


Code Index:

NAME

Top

Socialtext::WikiObject::YAML - Parse page content as YAML

METHODS

Top

parse_wikitext()

Override parent method to load the wikitext as YAML.

as_hash

Return the parsed YAML as a hash.

AUTHOR

Top

Luke Closs, <luke.closs at socialtext.com>

BUGS

Top

Please report any bugs or feature requests to http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Socialtext-Resting-Utils. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Top


Socialtext-Resting-Utils documentation Contained in the Socialtext-Resting-Utils distribution.
package Socialtext::WikiObject::YAML;
use strict;
use warnings;
use base 'Socialtext::WikiObject::PreBlock';
use YAML;

our $VERSION = '0.01';

sub parse_wikitext {
    my $self = shift;
    my $wikitext = shift;

    $self->SUPER::parse_wikitext($wikitext);
    $wikitext = $self->pre_block;

    my $data = {};
    eval { $data = Load($wikitext) };
    $data->{yaml_error} = $@ if $@;
    $self->{_hash} = $data;

    # Store the data into $self
    for my $k (keys %$data) {
        $self->{$k} = $self->{lc $k} = $data->{$k};
    }
}

sub as_hash { $_[0]->{_hash} }

# TODO - Add AUTOLOADed methods?

1;