Perl::Critic::MergeProfile - merge multiple Perl::Critic profiles into one
Version 0.003
use Perl::Critic::MergeProfile; my $merge = Perl::Critic::MergeProfile->new; $merge->read('xt/author/perlcriticrc-base'); $merge->read('xt/author/perlcriticrc-project'); $merge->write('xt/author/perlcriticrc-merged');
Merges multiple Perl::Critic profiles into a single one.
This allows to keep a common base profile for all projects but add project specific changes to the profile.
Returns a new Perl::Critic::MergeProfile instance. Arguments to new are ignored.
Perl::Critic::MergeProfile
new
Calls read from Config::Tiny with the same arguments it was called. Please see the documentation for read of Config::Tiny for an explanation of the parameters.
read
If no valid Config::Tiny object is returned an exception is thrown.
If this is the first call to read or read_string, the returned Config::Tiny object is used as the base of the new merged profile. No checks are performed on this first profile object.
read_string
Otherwise, the returned object is checked and if the same policy is enabled and disabled in this new profile an exception is thrown.
After that, existing entries for all policies from the new profile are removed from the merged profile. Then the polices from the new profile are added to the merged profile.
Entries in the global section of this profile overwrite the existing entries with the same name in the global section.
Behaves the same as read but calls read_string from Config::Tiny.
An exception is thrown if no valid policy exists, because neither read nor read_string were successfully called at least once.
Otherwise write from Config::Tiny is called on the profile with the same arguments write was called. Please see the documentation for write of Config::Tiny for an explanation of the parameters.
write
Returns something true if on success and throws an exception otherwise.
Behaves the same as write but calls write_string from Config::Tiny.
write_string
Returns the policy as string on success and throws an exception otherwise.
The following test script can be used to test your code with Perl::Critic with a merged profile.
use 5.006; use strict; use warnings; use Test::More; use Perl::Critic::MergeProfile; eval { my $merge = Perl::Critic::MergeProfile->new; $merge->read('xt/author/perlcriticrc-base'); $merge->read('xt/author/perlcriticrc-project'); my $profile = $merge->write_string; require Test::Perl::Critic; Test::Perl::Critic->import(-profile => \$profile); 1; } || do { my $error = $@; BAIL_OUT($error); }; all_critic_ok();
Config::Tiny, Perl::Critic, Test::Perl::Critic
Please report any bugs or feature requests through the issue tracker at https://github.com/skirmess/Perl-Critic-MergeProfile/issues. You will be notified automatically of any progress on your issue.
This is open source software. The code repository is available for public review and contribution under the terms of the license.
https://github.com/skirmess/Perl-Critic-MergeProfile
git clone https://github.com/skirmess/Perl-Critic-MergeProfile.git
Sven Kirmess <sven.kirmess@kzone.ch>
This software is Copyright (c) 2018 by Sven Kirmess.
This is free software, licensed under:
The (two-clause) FreeBSD License
To install Perl::Critic::MergeProfile, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl::Critic::MergeProfile
CPAN shell
perl -MCPAN -e shell install Perl::Critic::MergeProfile
For more information on module installation, please visit the detailed CPAN module installation guide.