Commits

Shlomi Fish committed a0bb616

Extract into separate classes.

  • Participants
  • Parent commits f8a7935

Comments (0)

Files changed (10)

File perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/FromProto/Node/Comment.pm

+package XML::Grammar::Fiction::FromProto::Node::Comment;
+
+use MooX 'late';
+
+extends("XML::Grammar::Fiction::FromProto::Node");
+
+has "text" => (isa => "Str", is => "rw");
+
+1;

File perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/FromProto/Node/Description.pm

+package XML::Grammar::Fiction::FromProto::Node::Description;
+
+use MooX 'late';
+
+extends("XML::Grammar::Fiction::FromProto::Node::Text");
+
+1;

File perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/FromProto/Node/Element.pm

+package XML::Grammar::Fiction::FromProto::Node::Element;
+
+=head1 NAME
+
+XML::Grammar::Fiction::FromProto::Nodes - contains several nodes for
+use in XML::Grammar::Fiction::FromProto.
+
+=head1 VERSION
+
+Version 0.11.1
+
+=cut
+
+use MooX 'late';
+
+extends("XML::Grammar::Fiction::FromProto::Node::WithContent");
+
+has 'name' => (isa => 'Str', is => 'rw');
+has 'attrs' => (isa => 'ArrayRef', is => 'rw');
+has 'open_line' => (isa => 'Maybe[Int]', is => 'rw');
+
+=head1 METHODS
+
+=head2 lookup_attr
+
+Internal use.
+
+=cut
+
+sub lookup_attr
+{
+    my ($self, $attr_name) = @_;
+
+    my $pair = List::Util::first { $_->{key} eq $attr_name } (@{$self->attrs()});
+
+    if (!defined($pair))
+    {
+        return undef;
+    }
+    else
+    {
+        return $pair->{value};
+    }
+}
+
+1;
+

File perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/FromProto/Node/InnerDesc.pm

+package XML::Grammar::Fiction::FromProto::Node::InnerDesc;
+
+use MooX 'late';
+
+extends("XML::Grammar::Fiction::FromProto::Node::Element");
+
+=head1 METHODS
+
+=head2 name
+
+Internal use.
+
+=cut
+
+sub name
+{
+    return "inlinedesc";
+}
+
+1;

File perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/FromProto/Node/List.pm

+package XML::Grammar::Fiction::FromProto::Node::List;
+
+use MooX 'late';
+
+extends("XML::Grammar::Fiction::FromProto::Node");
+
+has 'contents' => (isa => "ArrayRef", is => "rw");
+
+1;
+

File perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/FromProto/Node/Paragraph.pm

+package XML::Grammar::Fiction::FromProto::Node::Paragraph;
+
+use MooX 'late';
+
+extends("XML::Grammar::Fiction::FromProto::Node::Element");
+
+1;

File perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/FromProto/Node/Saying.pm

+package XML::Grammar::Fiction::FromProto::Node::Saying;
+
+use MooX 'late';
+
+extends("XML::Grammar::Fiction::FromProto::Node::Text");
+
+has 'character' => (isa => "Str", is => "rw");
+
+1;

File perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/FromProto/Node/Text.pm

+package XML::Grammar::Fiction::FromProto::Node::Text;
+
+use strict;
+use warnings;
+
+use MooX 'late';
+
+extends("XML::Grammar::Fiction::FromProto::Node::WithContent");
+
+=head1 METHODS
+
+=head2 $self->get_text($regex)
+
+Internal use.
+
+=cut
+
+sub get_text
+{
+    my ($self, $re) = @_;
+
+    return $self->children->contents->[0];
+}
+
+1;
+

File perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/FromProto/Node/WithContent.pm

+package XML::Grammar::Fiction::FromProto::Node::WithContent;
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+XML::Grammar::Fiction::FromProto::Nodes - contains several nodes for
+use in XML::Grammar::Fiction::FromProto.
+
+=head1 VERSION
+
+Version 0.11.1
+
+=cut
+
+our $VERSION = '0.11.1';
+
+use MooX 'late';
+
+extends("XML::Grammar::Fiction::FromProto::Node");
+
+has 'children' => (
+    isa => 'XML::Grammar::Fiction::FromProto::Node::List',
+    is => 'rw'
+);
+
+sub _get_childs
+{
+    my $self = shift;
+
+    my $childs = $self->children->contents();
+
+    return $childs || [];
+}
+
+1;

File perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/FromProto/Nodes.pm

 
 our $VERSION = '0.11.1';
 
-package XML::Grammar::Fiction::FromProto::Node::WithContent;
-
-use MooX 'late';
-
-extends("XML::Grammar::Fiction::FromProto::Node");
-
-has 'children' => (
-    isa => 'XML::Grammar::Fiction::FromProto::Node::List',
-    is => 'rw'
-);
-
-sub _get_childs
-{
-    my $self = shift;
-
-    my $childs = $self->children->contents();
-
-    return $childs || [];
-}
-
-package XML::Grammar::Fiction::FromProto::Node::Element;
-
-use MooX 'late';
-
-extends("XML::Grammar::Fiction::FromProto::Node::WithContent");
-
-has 'name' => (isa => 'Str', is => 'rw');
-has 'attrs' => (isa => 'ArrayRef', is => 'rw');
-has 'open_line' => (isa => 'Maybe[Int]', is => 'rw');
-
-sub lookup_attr
-{
-    my ($self, $attr_name) = @_;
-
-    my $pair = List::Util::first { $_->{key} eq $attr_name } (@{$self->attrs()});
-
-    if (!defined($pair))
-    {
-        return undef;
-    }
-    else
-    {
-        return $pair->{value};
-    }
-}
-
-package XML::Grammar::Fiction::FromProto::Node::List;
-
-use MooX 'late';
-
-extends("XML::Grammar::Fiction::FromProto::Node");
-
-has 'contents' => (isa => "ArrayRef", is => "rw");
-
-package XML::Grammar::Fiction::FromProto::Node::Text;
-
-use MooX 'late';
-
-extends("XML::Grammar::Fiction::FromProto::Node::WithContent");
-
-sub get_text
-{
-    my ($self, $re) = @_;
-
-    return $self->children->contents->[0];
-}
-
-package XML::Grammar::Fiction::FromProto::Node::Saying;
-
-use MooX 'late';
-
-extends("XML::Grammar::Fiction::FromProto::Node::Text");
-
-has 'character' => (isa => "Str", is => "rw");
-
-package XML::Grammar::Fiction::FromProto::Node::Description;
-
-use MooX 'late';
-
-extends("XML::Grammar::Fiction::FromProto::Node::Text");
-
-package XML::Grammar::Fiction::FromProto::Node::Paragraph;
-
-use MooX 'late';
-
-extends("XML::Grammar::Fiction::FromProto::Node::Element");
-
-package XML::Grammar::Fiction::FromProto::Node::InnerDesc;
-
-use MooX 'late';
-
-extends("XML::Grammar::Fiction::FromProto::Node::Element");
-
-sub name
-{
-    return "inlinedesc";
-}
-
-package XML::Grammar::Fiction::FromProto::Node::Comment;
-
-use MooX 'late';
-
-extends("XML::Grammar::Fiction::FromProto::Node");
-
-has "text" => (isa => "Str", is => "rw");
+use XML::Grammar::Fiction::FromProto::Node::WithContent;
+use XML::Grammar::Fiction::FromProto::Node::Element;
+use XML::Grammar::Fiction::FromProto::Node::List;
+use XML::Grammar::Fiction::FromProto::Node::Text;
+use XML::Grammar::Fiction::FromProto::Node::Saying;
+use XML::Grammar::Fiction::FromProto::Node::Description;
+use XML::Grammar::Fiction::FromProto::Node::Paragraph;
+use XML::Grammar::Fiction::FromProto::Node::InnerDesc;
+use XML::Grammar::Fiction::FromProto::Node::Comment;
 
 1;