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::CFC.
Date Fri, 18 Jul 2014 23:04:08 GMT
Cloak POD for the CPAN dist of Clownfish::CFC.


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

Branch: refs/heads/master
Commit: 7e96df7571001e4f4fbed422173a952f0bad1c3b
Parents: e68aa86
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Tue Jul 15 19:29:28 2014 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Fri Jul 18 16:03:17 2014 -0700

----------------------------------------------------------------------
 compiler/perl/buildlib/Clownfish/CFC/Build.pm | 51 ++++++++++++++++++++++
 compiler/perl/lib/Clownfish/CFC.pod           | 30 +++++++++++++
 2 files changed, 81 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/7e96df75/compiler/perl/buildlib/Clownfish/CFC/Build.pm
----------------------------------------------------------------------
diff --git a/compiler/perl/buildlib/Clownfish/CFC/Build.pm b/compiler/perl/buildlib/Clownfish/CFC/Build.pm
index 0eeb1db..9f9d1f0 100644
--- a/compiler/perl/buildlib/Clownfish/CFC/Build.pm
+++ b/compiler/perl/buildlib/Clownfish/CFC/Build.pm
@@ -27,6 +27,7 @@ no lib 'lib';
 use File::Spec::Functions qw( catfile updir catdir curdir );
 use File::Copy qw( move );
 use File::Path qw( rmtree );
+use File::Find qw( find );
 use Config;
 use Cwd qw( getcwd );
 use Carp;
@@ -191,8 +192,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/CFC.pod' => 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;
@@ -201,5 +204,53 @@ 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/7e96df75/compiler/perl/lib/Clownfish/CFC.pod
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC.pod b/compiler/perl/lib/Clownfish/CFC.pod
new file mode 100644
index 0000000..b22c050
--- /dev/null
+++ b/compiler/perl/lib/Clownfish/CFC.pod
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+=head1 NAME
+
+Clownfish::CFC - Compiler for Apache Clownfish.
+
+=head1 DESCRIPTION
+
+The API for this alpha release of the CFC compiler 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