Skip to content

Commit

Permalink
Factor out the <content/> node
Browse files Browse the repository at this point in the history
  • Loading branch information
ash committed Oct 15, 2011
1 parent f613845 commit bb00b64
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 13 deletions.
4 changes: 3 additions & 1 deletion lib/Areno.pm
Expand Up @@ -6,6 +6,7 @@ use Cwd;
use Plack::Request;

use Areno::Manifest;
use Areno::Content;
use Areno::Dispatch;

sub new {
Expand Down Expand Up @@ -108,7 +109,8 @@ sub new_doc {
my $manifest = new Areno::Manifest($env);
$root->appendChild($manifest->node());

my $content = $this->new_content($dom, $env);
my $content = new Areno::Content();
$root->appendChild($content->node());

return {
dom => $dom,
Expand Down
20 changes: 20 additions & 0 deletions lib/Areno/Content.pm
@@ -0,0 +1,20 @@
package Areno::Content;

use strict;

use base 'Areno::Node';

use XML::LibXML;

sub new {
my ($class) = @_;

my $this = {
node => new XML::LibXML::Element('content'),
};
bless $this, $class;

return $this;
}

1;
8 changes: 2 additions & 6 deletions lib/Areno/Manifest.pm
Expand Up @@ -2,6 +2,8 @@ package Areno::Manifest;

use strict;

use base 'Areno::Node';

use XML::LibXML;
use Areno::Manifest::Request;

Expand All @@ -25,12 +27,6 @@ sub init {
$this->{node}->appendChild((new Areno::Manifest::Request($env))->node());
}

sub node {
my ($this) = @_;

return $this->{node};
}

sub dateNode {
my ($this) = @_;

Expand Down
10 changes: 4 additions & 6 deletions lib/Areno/Manifest/Request.pm
Expand Up @@ -2,6 +2,10 @@ package Areno::Manifest::Request;

use strict;

use base 'Areno::Node';

use XML::LibXML;

sub new {
my ($class, $env) = @_;

Expand All @@ -25,12 +29,6 @@ sub init {
$this->{node}->appendChild($this->useragentNode($request));
}

sub node {
my ($this) = @_;

return $this->{node};
}

sub argumentsNode {
my ($this, $request) = @_;

Expand Down
11 changes: 11 additions & 0 deletions lib/Areno/Node.pm
@@ -0,0 +1,11 @@
package Areno::Node;

use strict;

sub node {
my ($this) = @_;

return $this->{node};
}

1;

0 comments on commit bb00b64

Please sign in to comment.