[libcode-tidyall-perl] 222/374: add

Jonas Smedegaard js at alioth.debian.org
Sun Sep 29 22:26:24 UTC 2013


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository libcode-tidyall-perl.

commit 60557d8230723cc2b0a478db989ab06a9f93c092
Author: Jonathan Swartz <swartz at pobox.com>
Date:   Wed Sep 12 17:04:37 2012 -0400

    add
---
 lib/Code/TidyAll/Plugin/MasonTidy.pm   |   55 ++++++++++++++++++++++++++++++++
 lib/Code/TidyAll/t/Plugin/MasonTidy.pm |   26 +++++++++++++++
 xt/author/Plugin-MasonTidy.t           |    3 ++
 3 files changed, 84 insertions(+)

diff --git a/lib/Code/TidyAll/Plugin/MasonTidy.pm b/lib/Code/TidyAll/Plugin/MasonTidy.pm
new file mode 100644
index 0000000..aefd950
--- /dev/null
+++ b/lib/Code/TidyAll/Plugin/MasonTidy.pm
@@ -0,0 +1,55 @@
+package Code::TidyAll::Plugin::MasonTidy;
+use IPC::System::Simple qw(run);
+use Moo;
+extends 'Code::TidyAll::Plugin';
+
+sub _build_cmd { 'masontidy' }
+
+sub transform_file {
+    my ( $self, $file ) = @_;
+
+    run( sprintf( "%s --replace %s %s", $self->cmd, $self->argv, $file ) );
+}
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+Code::TidyAll::Plugin::MasonTidy - use masontidy with tidyall
+
+=head1 SYNOPSIS
+
+   In tidyall.ini:
+
+   [MasonTidy]
+   select = comps/**/*.{mc,mi}
+   argv = --indent-perl-block 0 --perltidy-argv "-noll -l=78"
+
+=head1 DESCRIPTION
+
+Runs L<masontidy|masontidy>, a tidier for L<HTML::Mason|HTML::Mason> and
+L<Mason 2|Mason> components.
+
+=head1 INSTALLATION
+
+Install L<masontidy|masontidy> from CPAN.
+
+    cpanm masontidy
+
+=head1 CONFIGURATION
+
+=over
+
+=item argv
+
+Arguments to pass to masontidy
+
+=item cmd
+
+Full path to masontidy
+
+=back
diff --git a/lib/Code/TidyAll/t/Plugin/MasonTidy.pm b/lib/Code/TidyAll/t/Plugin/MasonTidy.pm
new file mode 100644
index 0000000..53533fc
--- /dev/null
+++ b/lib/Code/TidyAll/t/Plugin/MasonTidy.pm
@@ -0,0 +1,26 @@
+package Code::TidyAll::t::Plugin::MasonTidy;
+use Test::Class::Most parent => 'Code::TidyAll::t::Plugin';
+
+sub test_main : Tests {
+    my $self = shift;
+
+    my $source;
+
+    $source = '%if($foo) {\n%bar(1,2);\n%}';
+    $self->tidyall(
+        source      => $source,
+        expect_tidy => '% if ($foo) {\n%   bar( 1, 2 );\n% }'
+    );
+    $self->tidyall(
+        source      => $source,
+        conf        => { argv => '--perltidy-argv="-pt=2"' },
+        expect_tidy => '% if ($foo) {\n%   bar(1, 2);\n% }'
+    );
+    $self->tidyall(
+        source      => $source,
+        conf        => { argv => '--perltidy-line-argv=" "' },
+        expect_tidy => '% if ($foo) {\n%     bar( 1, 2 );\n% }'
+    );
+}
+
+1;
diff --git a/xt/author/Plugin-MasonTidy.t b/xt/author/Plugin-MasonTidy.t
new file mode 100644
index 0000000..d803660
--- /dev/null
+++ b/xt/author/Plugin-MasonTidy.t
@@ -0,0 +1,3 @@
+#!/usr/bin/perl
+use Code::TidyAll::t::Plugin::MasonTidy;
+Code::TidyAll::t::Plugin::MasonTidy->runtests;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcode-tidyall-perl.git



More information about the Pkg-perl-cvs-commits mailing list