App-diff2vba
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/diff2vba.pm view on Meta::CPAN
package App::diff2vba;
use 5.014;
use warnings;
our $VERSION = "1.00";
use utf8;
use Encode;
use Data::Dumper;
{
no warnings 'redefine';
*Data::Dumper::qquote = sub { qq["${\(shift)}"] };
$Data::Dumper::Useperl = 1;
}
use open IO => 'utf8', ':std';
use Pod::Usage;
use Data::Section::Simple qw(get_data_section);
use List::Util qw(max);
use List::MoreUtils qw(pairwise);
use App::diff2vba::Util qw(split_string);
use App::sdif::Util qw(read_unified_2);
use Getopt::EX::Hashed 1.03; {
Getopt::EX::Hashed->configure( DEFAULT => [ is => 'ro' ] );
has debug => " " ;
has verbose => " v ! " , default => 1;
has format => " =s " , default => 'dumb';
has subname => " =s " , default => 'Patch';
has maxlen => " =i " , default => 250;
has adjust => " =i " , default => 2;
has identical => " ! " ;
has reverse => " ! " ;
has help => " " ;
has version => " " ;
has '+help' => sub {
pod2usage
-verbose => 99,
-sections => [ qw(SYNOPSIS VERSION) ];
};
has '+version' => sub {
print "Version: $VERSION\n";
exit;
};
Getopt::EX::Hashed->configure( DEFAULT => [ is => 'rw' ] );
has SCRIPT => ;
has TABLE => ;
has QUOTES => default => { 'â' => "Chr(&H8167)", 'â' => "Chr(&H8168)" };
has QUOTES_RE => ;
} no Getopt::EX::Hashed;
sub run {
my $app = shift;
local @ARGV = map { utf8::is_utf8($_) ? $_ : decode('utf8', $_) } @_;
use Getopt::EX::Long qw(GetOptions Configure ExConfigure);
ExConfigure BASECLASS => [ __PACKAGE__, "Getopt::EX" ];
Configure qw(bundling no_getopt_compat);
$app->getopt || pod2usage();
$app->initialize;
for my $file (@ARGV ? @ARGV : '-') {
print $app->reset->load($file)->vba->script;
}
return 0;
}
sub load {
my $app = shift;
my $file = shift;
open my $fh, $file or die "$file: $!\n";
$app->TABLE(my $fromto = []);
while (<$fh>) {
#
# diff --combined (generic)
#
if (m{^
(?<command>
(?<mark> \@{2,} ) [ ]
(?<lines> (?: [-+]\d+(?:,\d+)? [ ] ){2,} )
\g{mark}
(?s:.*)
)
}x) {
my($command, $lines) = @+{qw(command lines)};
my $column = length $+{mark};
my @lines = map {
$_ eq ' ' ? 1 : int $_
} $lines =~ /\d+(?|,(\d+)|( ))/g;
warn $_ if $app->debug;
next if @lines != $column;
next if $column != 2;
push @$fromto, $app->read_diff($fh, @lines);
}
}
$app;
}
sub vba {
(my $app = shift)
->prologue()
->substitute()
->epilogue();
}
sub prologue {
my $app = shift;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 2.569 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-c30982ac1bc3 )