[Bps-public-commit] r14087 - in Data-Plist: . lib/Data/Plist

alexmv at bestpractical.com alexmv at bestpractical.com
Mon Jul 14 16:14:46 EDT 2008


Author: alexmv
Date: Mon Jul 14 16:14:41 2008
New Revision: 14087

Modified:
   Data-Plist/   (props changed)
   Data-Plist/ical-import.pl
   Data-Plist/lib/Data/Plist/BinaryWriter.pm
   Data-Plist/lib/Data/Plist/Writer.pm
   Data-Plist/lib/Data/Plist/XMLWriter.pm
   Data-Plist/lib/Foundation/NSMutableData.pm

Log:
 r34143 at kohr-ah:  chmrr | 2008-07-14 16:12:58 -0400
  * Method name cleanups for writers


Modified: Data-Plist/ical-import.pl
==============================================================================
--- Data-Plist/ical-import.pl	(original)
+++ Data-Plist/ical-import.pl	Mon Jul 14 16:14:41 2008
@@ -18,5 +18,5 @@
     }
 
     my $p = Data::Plist::BinaryReader->open_string($content);
-    print Data::Plist::XMLWriter->open_string($p->object("Foundation"));
+    print Data::Plist::XMLWriter->write($p->object("Foundation"));
 }

Modified: Data-Plist/lib/Data/Plist/BinaryWriter.pm
==============================================================================
--- Data-Plist/lib/Data/Plist/BinaryWriter.pm	(original)
+++ Data-Plist/lib/Data/Plist/BinaryWriter.pm	Mon Jul 14 16:14:41 2008
@@ -5,7 +5,7 @@
 
 use base qw/Data::Plist::Writer/;
 
-sub open_fh {
+sub write_fh {
 }
 
 1;

Modified: Data-Plist/lib/Data/Plist/Writer.pm
==============================================================================
--- Data-Plist/lib/Data/Plist/Writer.pm	(original)
+++ Data-Plist/lib/Data/Plist/Writer.pm	Mon Jul 14 16:14:41 2008
@@ -8,32 +8,25 @@
     return bless {} => $class;
 }
 
-sub open_string {
+sub write {
     my $self = shift;
-    my ($object) = @_;
+    my $object = pop;
+    my $to = shift;
 
-    my $fh;
-    my $content;
-    open( $fh, ">", \$content );
-    $self->open_fh($fh, $object) or return "moose";
-    return $content;
-}
-
-sub open_file {
-    my $self = shift;
-    my ($filename, $object) = @_;
-
-    my $fh;
-    open( $fh, ">", $filename ) or die "can't open $filename for conversion";
-    binmode($fh);
-    return $self->open_fh($fh, $object);
-}
-
-sub open_fh {
-    my $self = shift;
-    my ($fh, $object) = @_;
-
-    die "Unimplemented!";
+    if (not $to) {
+        my $content;
+        my $fh;
+        open( $fh, ">", \$content );
+        $self->write_fh($fh, $object) or return;
+        return $content;
+    } elsif (ref $to) {
+        $self->write_fh($to, $object)
+    } else {
+        my $fh;
+        open( $fh, ">", $to ) or die "Can't open $to for writing: $!";
+        $self->write_fh($fh, $object) or return;
+    }
+    return;
 }
 
 sub fold_uids {

Modified: Data-Plist/lib/Data/Plist/XMLWriter.pm
==============================================================================
--- Data-Plist/lib/Data/Plist/XMLWriter.pm	(original)
+++ Data-Plist/lib/Data/Plist/XMLWriter.pm	Mon Jul 14 16:14:41 2008
@@ -7,7 +7,7 @@
 use XML::Writer;
 use MIME::Base64 qw//;
 
-sub open_fh {
+sub write_fh {
     my $self = shift;
     $self = $self->new() unless ref $self;
 

Modified: Data-Plist/lib/Foundation/NSMutableData.pm
==============================================================================
--- Data-Plist/lib/Foundation/NSMutableData.pm	(original)
+++ Data-Plist/lib/Foundation/NSMutableData.pm	Mon Jul 14 16:14:41 2008
@@ -14,7 +14,7 @@
     my $self = shift;
     return $self->SUPER::serialize_equiv unless ref $self->data;
     # XXX TODO: This should be BinaryWriter, but it hasn't been written yet
-    return { "NS.data" => Data::Plist::XMLWriter->open_string($self->data) };
+    return { "NS.data" => Data::Plist::XMLWriter->write($self->data) };
 }
 
 1;



More information about the Bps-public-commit mailing list