Skip to content

Commit

Permalink
remove dependency XML::LibXML
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnu committed Nov 8, 2011
1 parent c8356de commit 5f54582
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
1 change: 0 additions & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ requires 'File::Find';
requires 'CPAN::DistnameInfo';
requires 'File::Sync';
requires 'File::Temp';
requires 'XML::LibXML';

requires_external_bin('tar');
requires_external_bin('unzip');
Expand Down
33 changes: 20 additions & 13 deletions lib/OrePAN/Package/Whois.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,41 @@ use strict;
use warnings;
use utf8;
use Mouse;
use XML::LibXML;

has filename => (
is => 'ro',
required => 1,
);

has doc => (
has data => (
is => 'ro',
default => sub {
my $doc = XML::LibXML::Document->new('1.0', 'UTF-8');
$doc->setDocumentElement($doc->createElement('cpan-whois'));
$doc;
},
isa => 'Str',
default => '',
);

sub add {
my ($self, %data) = @_;
my $whois = $self->doc->documentElement();
$whois->addChild(my $cpanid = XML::LibXML::Element->new('cpanid'));
$cpanid->addChild(XML::LibXML::Element->new('id'))->appendText($data{cpanid});
$cpanid->addChild(XML::LibXML::Element->new('type'))->appendText('author');
$cpanid->addChild(XML::LibXML::Element->new('has_cpandir'))->appendText('1');
$self->{data} .= <<"EOS";
<cpanid>
<id>$data{cpanid}</id>
<type>author</type>
<has_cpandir>1</has_cpandir>
</cpanid>
EOS
chomp $self->{data};
}

sub save {
my ($self, ) = @_;
$self->doc->toFile($self->filename, 1);
my $cont = $self->data;
open my $fh, '>', $self->filename or die $!;
print $fh <<"EOS";
<?xml version="1.0" encoding="UTF-8"?>
<cpan-whois>
$cont
</cpan-whois>
EOS
close $fh;
}

no Mouse; __PACKAGE__->meta->make_immutable;
Expand Down

0 comments on commit 5f54582

Please sign in to comment.