blib/lib/Code/TidyAll/Plugin/SortLines/Naturally.pm

filter: Statementstmt 100% 20 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 100% 26 / 26 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Code::TidyAll::Plugin::SortLines::Naturally;
5 1 $Code::TidyAll::Plugin::SortLines::Naturally::VERSION = '0.000003';
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 extends 'Code::TidyAll::Plugin';
8  
9 1 ▶use Unicode::Collate::Locale ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 has 'locale' => ( is => 'ro', default => 'en_US' );
12  
13 1 ▶sub transform_source {
Subroutine transform_source: called CC=1 SCAR=0.0
Pod documented
14 1 my ( $self, $source ) = @_;
15  
16 1 my $collator = Unicode::Collate::Locale->new( locale => $self->locale );
17 return
18 1 join( "\n", $collator->sort( grep {/\S/} split( /\n/, $source ) ) )
19 . "\n";
20 }
21  
22 1 1;
23  
24 =pod
25  
26 =encoding UTF-8
27  
28 =head1 NAME
29  
30 Code::TidyAll::Plugin::SortLines::Naturally - Sort lines of a file using Unicode::Collate::Locale
31  
32 =head1 VERSION
33  
34 version 0.000003
35  
36 =head1 SYNOPSIS
37  
38 # In configuration:
39  
40 [SortLines::Naturally]
41 select = .ispell* **/.gitignore
42  
43 =head1 DESCRIPTION
44  
45 Sorts the lines of a file; whitespace lines are discarded. Useful for files
46 containing one entry per line, such as C<.svnignore>, C<.gitignore>, and
47 C<.ispell*>.
48  
49 =head1 CONFIGURATION
50  
51 =over
52  
53 =item locale
54  
55 The locale to use for collation. Defaults to "en_US".
56  
57 =back
58  
59 =head1 ACKNOWLEDGEMENTS
60  
61 This code was essentially pilfered from L<Code::TidyAll::Plugin::SortLines>
62  
63 =head1 AUTHOR
64  
65 Olaf Alders <olaf@wundercounter.com>
66  
67 =head1 COPYRIGHT AND LICENSE
68  
69 This software is copyright (c) 2014 by Olaf Alders.
70  
71 This is free software; you can redistribute it and/or modify it under
72 the same terms as the Perl 5 programming language system itself.
73  
74 =cut
75  
76 __END__
↑ Summary