diff --git a/lib/Directory/Simplify/File.pm b/Directory/Simplify/File.pm similarity index 100% rename from lib/Directory/Simplify/File.pm rename to Directory/Simplify/File.pm diff --git a/lib/Directory/Simplify/FileHash.pm b/Directory/Simplify/FileHash.pm similarity index 96% rename from lib/Directory/Simplify/FileHash.pm rename to Directory/Simplify/FileHash.pm index 54a0eb8..1e8db4f 100644 --- a/lib/Directory/Simplify/FileHash.pm +++ b/Directory/Simplify/FileHash.pm @@ -8,9 +8,9 @@ Object for abstracting management of a hashed filesystem =cut -# :squash-remove-start: +# :squash-ignore-start: require Directory::Simplify::File; -# :squash-remove-end: +# :squash-ignore-end: sub new { my $class = shift; diff --git a/lib/Directory/Simplify/Instruction/CopyTimestamp.pm b/Directory/Simplify/Instruction/CopyTimestamp.pm similarity index 93% rename from lib/Directory/Simplify/Instruction/CopyTimestamp.pm rename to Directory/Simplify/Instruction/CopyTimestamp.pm index fba95c9..491a4f4 100644 --- a/lib/Directory/Simplify/Instruction/CopyTimestamp.pm +++ b/Directory/Simplify/Instruction/CopyTimestamp.pm @@ -4,9 +4,9 @@ use strict; use warnings; use overload '""' => 'as_string'; -# :squash-remove-start: +# :squash-ignore-start: require Directory::Simplify::Utils; -# :squash-remove-end: +# :squash-ignore-end: sub new { my $class = shift; diff --git a/lib/Directory/Simplify/Instruction/Generator.pm b/Directory/Simplify/Instruction/Generator.pm similarity index 99% rename from lib/Directory/Simplify/Instruction/Generator.pm rename to Directory/Simplify/Instruction/Generator.pm index d2bab1b..3567d05 100644 --- a/lib/Directory/Simplify/Instruction/Generator.pm +++ b/Directory/Simplify/Instruction/Generator.pm @@ -6,10 +6,10 @@ use overload '""' => 'as_string'; use File::Basename qw/ dirname /; use File::Compare qw/ compare /; -# :squash-remove-start: +# :squash-ignore-start: require Directory::Simplify::Instruction::CopyTimestamp; require Directory::Simplify::Instruction::Hardlink; -# :squash-remove-end: +# :squash-ignore-end: sub new { my $class = shift; diff --git a/lib/Directory/Simplify/Instruction/Hardlink.pm b/Directory/Simplify/Instruction/Hardlink.pm similarity index 95% rename from lib/Directory/Simplify/Instruction/Hardlink.pm rename to Directory/Simplify/Instruction/Hardlink.pm index 24d274e..9a7e7c0 100644 --- a/lib/Directory/Simplify/Instruction/Hardlink.pm +++ b/Directory/Simplify/Instruction/Hardlink.pm @@ -4,9 +4,9 @@ use strict; use warnings; use overload '""' => 'as_string'; -# :squash-remove-start: +# :squash-ignore-start: require Directory::Simplify::Utils; -# :squash-remove-end: +# :squash-ignore-end: sub new { my $class = shift; diff --git a/lib/Directory/Simplify/Utils.pm b/Directory/Simplify/Utils.pm similarity index 100% rename from lib/Directory/Simplify/Utils.pm rename to Directory/Simplify/Utils.pm diff --git a/make-allinone.sh b/make-allinone.sh index 6bbaa4d..5f201d9 100755 --- a/make-allinone.sh +++ b/make-allinone.sh @@ -8,6 +8,6 @@ echo "Outputting to $OUT" >&2 shopt -s globstar "$WORKDIR/util/squash" \ "$WORKDIR/simplify_static_dir-main.pl" \ - "$WORKDIR"/lib/**/*.pm \ + "$WORKDIR"/**/*.pm \ > "$OUT" chmod +x -- "$OUT" diff --git a/simplify_static_dir-main.pl b/simplify_static_dir-main.pl index 78ecfe4..e69e39a 100755 --- a/simplify_static_dir-main.pl +++ b/simplify_static_dir-main.pl @@ -104,16 +104,16 @@ use File::Find qw/ find /; use Getopt::Std qw/ getopts /; use Pod::Usage qw/ pod2usage /; -# :squash-remove-start: +# :squash-ignore-start: # (this prepends to the load path) use FindBin qw//; -use lib "$FindBin::RealBin/lib"; +use lib $FindBin::RealBin; require Directory::Simplify::File; require Directory::Simplify::FileHash; require Directory::Simplify::Instruction::Generator; require Directory::Simplify::Utils; -# :squash-remove-end: +# :squash-ignore-end: sub HELP_MESSAGE { my $fh = shift; diff --git a/util/squash b/util/squash index a015533..3403c19 100755 --- a/util/squash +++ b/util/squash @@ -18,48 +18,17 @@ for my $arg (@ARGV) { warn "Reading $filename\n"; open my $fh, '<', $filename or die "Can't open $filename: $!"; my $in_pod = 0; - my $in_section = ''; - my $ignore_lines = 0; - my $empty_lines = 0; + my $in_ignore_section = 0; while (<$fh>) { if (/#.*:squash-ignore-start:$/) { - $in_section = 'ignore'; - $ignore_lines = 1; + $in_ignore_section = 1; + next; } elsif (/#.*:squash-ignore-end:$/) { - $in_section = ''; - $ignore_lines = 1; - } - if ($ignore_lines > 0) { - $ignore_lines--; + $in_ignore_section = 0; next; } - - if ($in_section eq 'ignore') { - $empty_lines = 0 unless /^$/; - $code .= $_; - next; - } - - # Remove repeated newlines between paragraphs - # (Provided of course we're not in an 'ignore' section) - if (/^$/) { - ++$empty_lines; - if ($empty_lines > 1) { - next; - } - } else { - $empty_lines = 0; - } - - if (/#.*:squash-remove-start:$/) { - $in_section = 'remove'; - next; - } elsif (/#.*:squash-remove-end:$/) { - $in_section = ''; - next; - } - next if $in_section eq 'remove'; - next if /#.*:squash-remove-line:$/; + next if $in_ignore_section; + next if /#.*:squash-ignore-line:$/; next if /^\s*1;$/; @@ -80,13 +49,12 @@ for my $arg (@ARGV) { s{\s*##.+critic.*}{}; $code .= $_; } - - # Warn if there were unterminated :squash-*: sections - warn "$filename: Unterminated :squash-$in_section-start: section" if $in_section; - close $fh; } +# Remove repeated newlines between paragraphs +$code =~ s/\n\n+/\n\n/gs; + print $code; exit 0;