lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [2/2] git commit: Cloak POD for the CPAN dist of Clownfish.
Date Wed, 16 Jul 2014 02:51:02 GMT
Cloak POD for the CPAN dist of Clownfish.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/a429093d
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/a429093d
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/a429093d

Branch: refs/heads/prep_cpan_pod
Commit: a429093d5ac68da91a16277fed7b2e76379a1d9a
Parents: 2b63170
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Tue Jul 15 19:49:53 2014 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Tue Jul 15 19:49:53 2014 -0700

----------------------------------------------------------------------
 runtime/perl/buildlib/Clownfish/Build.pm | 52 +++++++++++++++++++++++++++
 runtime/perl/lib/Clownfish.pm            | 25 +++++++++++++
 2 files changed, 77 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a429093d/runtime/perl/buildlib/Clownfish/Build.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/buildlib/Clownfish/Build.pm b/runtime/perl/buildlib/Clownfish/Build.pm
index 5865fd9..85de0b2 100644
--- a/runtime/perl/buildlib/Clownfish/Build.pm
+++ b/runtime/perl/buildlib/Clownfish/Build.pm
@@ -37,6 +37,7 @@ $VERSION = eval $VERSION;
 use File::Spec::Functions qw( catdir catfile updir rel2abs );
 use File::Path qw( rmtree );
 use File::Copy qw( move );
+use File::Find qw( find );
 use Config;
 use Carp;
 use Cwd qw( getcwd );
@@ -329,8 +330,10 @@ sub ACTION_dist {
         system("cp -R $from $to") and confess("cp failed");
     }
     move( "MANIFEST", "MANIFEST.bak" ) or die "move() failed: $!";
+    my $saved = _hide_pod( $self, { 'lib/Clownfish.pm' => 1 } );
     $self->depends_on("manifest");
     $self->SUPER::ACTION_dist;
+    _restore_pod( $self, $saved );
 
     # Now that the tarball is packaged up, delete the copied assets.
     rmtree($_) for values %to_copy;
@@ -339,5 +342,54 @@ sub ACTION_dist {
     move( "MANIFEST.bak", "MANIFEST" ) or die "move() failed: $!";
 }
 
+
+# Strip POD from files in the `lib` directory.  This is a temporary measure to
+# allow us to release Clownfish as a separate dist but with a cloaked API.
+sub _hide_pod {
+    my ( $self, $excluded ) = @_;
+    my %saved;
+    find(
+        {
+            no_chdir => 1,
+            wanted   => sub {
+                my $path = $File::Find::name;
+                return if $excluded->{$path};
+                return unless $path =~ /\.(pm|pod)$/;
+                open( my $fh, '<:encoding(UTF-8)', $path )
+                  or confess("Can't open '$path' for reading: $!");
+                my $content = do { local $/; <$fh> };
+                close $fh;
+                if ( $path =~ /\.pod$/ ) {
+                    $saved{$path} = $content;
+                    print "Hiding POD for $path\n";
+                    unlink($path) or confess("Can't unlink '$path': $!");
+                }
+                else {
+                    my $copy = $content;
+                    $copy =~ s/^=\w+.*?^=cut\s*$//gsm;
+                    return if $copy eq $content;
+                    print "Hiding POD for $path\n";
+                    $saved{$path} = $content;
+                    open( $fh, '>:encoding(UTF-8)', $path )
+                      or confess("Can't open '$path' for writing: $!");
+                    print $fh $copy;
+                }
+            },
+        },
+        'lib',
+    );
+    return \%saved;
+}
+
+# Undo POD hiding.
+sub _restore_pod {
+    my ( $self, $saved ) = @_;
+    while ( my ( $path, $content ) = each %$saved ) {
+        open( my $fh, '>:encoding(UTF-8)', $path )
+          or confess("Can't open '$path' for writing: $!");
+        print $fh $saved->{$path};
+    }
+}
+
 1;
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a429093d/runtime/perl/lib/Clownfish.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/lib/Clownfish.pm b/runtime/perl/lib/Clownfish.pm
index e0ede72..7dff615 100644
--- a/runtime/perl/lib/Clownfish.pm
+++ b/runtime/perl/lib/Clownfish.pm
@@ -230,4 +230,29 @@ sub error {$Clownfish::Err::error}
 
 __END__
 
+=head1 NAME
+
+Clownfish - Apache Clownfish symbiotic object system.
+
+=head1 VERSION
+
+0.3.0
+
+=head1 DESCRIPTION
+
+The Apache Clownfish "symbiotic" object system for C is designed to pair with
+a "host" dynamic language environment, facilitating the development of high
+performance host language extensions.  Clownfish classes are declared in
+header files with a C<.cfh> extension.  The Clownfish headers are used by the
+Clownfish compiler to generate C header files and host language bindings.
+Methods, functions and variables are defined in normal C source files.
+
+The API for this alpha release of Clownfish has been cloaked.
+
+=head1 COPYRIGHT
+
+Clownfish is distributed under the Apache License, Version 2.0, as
+described in the file C<LICENSE> included with the distribution.
+
+=cut
 


Mime
View raw message