Commits

Shlomi Fish  committed dfa78c1

Extract a common method from Screenplay|Fiction.

  • Participants
  • Parent commits fb88ff3

Comments (0)

Files changed (3)

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

     return $fiction_ns;
 }
 
-sub convert
+sub _convert_write_content
 {
-    my ($self, $args) = @_;
-
-    # These should be un-commented for debugging.
-    # local $::RD_HINT = 1;
-    # local $::RD_TRACE = 1;
-
-    # We need this so P::RD won't skip leading whitespace at lines
-    # which are siginificant.
-
-    my $tree = $self->_calc_tree($args);
-
-    if (!defined($tree))
-    {
-        Carp::confess("Parsing failed.");
-    }
+    my ($self, $tree) = @_;
 
     my $writer = $self->_writer;
 
 
     $writer->endTag();
 
-    return ${$self->_flush_buffer()};
+    return;
 }
 
 1;

File perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/FictionBase/TagsTree2XML.pm

     return;
 }
 
+=head2 $self->convert({ source => { file => $path_to_file } })
+
+Converts the file $path_to_file to XML and returns it. Throws an exception
+on failure.
+
+=cut
+
+sub convert
+{
+    my ($self, $args) = @_;
+
+    my $tree = $self->_calc_tree($args);
+    if (!defined($tree))
+    {
+        Carp::confess("Parsing failed.");
+    }
+
+    $self->_convert_write_content($tree);
+
+    return ${$self->_flush_buffer()};
+}
+
 =head2 meta()
 
 Internal - (to settle pod-coverage.).

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

     return $screenplay_ns;
 }
 
-sub convert
+sub _convert_write_content
 {
-    my ($self, $args) = @_;
-
-    # These should be un-commented for debugging.
-    # local $::RD_HINT = 1;
-    # local $::RD_TRACE = 1;
-
-    # We need this so P::RD won't skip leading whitespace at lines
-    # which are siginificant.
-
-    my $tree = $self->_calc_tree($args);
-
-    if (!defined($tree))
-    {
-        Carp::confess("Parsing failed.");
-    }
+    my ($self, $tree) = @_;
 
     my $writer = $self->_writer;
 
 
     $writer->endTag();
 
-    return ${$self->_flush_buffer()};
+    return;
 }
 
 1;