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

filter: Statementstmt 100% 22 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 100% 28 / 28 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::IPAddresses;
5 1 $Code::TidyAll::Plugin::SortLines::IPAddresses::VERSION = '0.0.1';
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 extends 'Code::TidyAll::Plugin';
8  
9 1 ▶use Net::Works::Address;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶sub transform_source {
Subroutine transform_source: called CC=1 SCAR=0.0
Pod documented
12 1 my ( $self, $source ) = @_;
13  
14 return
15 # join( "\n", $collator->sort( grep {/\S/} split( /\n/, $source ) ) )
16 # . "\n";
17 1 join( "\n", map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, eval { Net::Works::Address->new_from_string( string => $_ )->as_integer } ] } grep {/\S/} split( /\n/, $source ) )
18 . "\n";
19 }
20  
21 1 1;
22  
23 =pod
24  
25 =encoding UTF-8
26  
27 =head1 NAME
28  
29 Code::TidyAll::Plugin::SortLines::IPAddresses - Sort lines of a file containing IP addresses
30  
31 =head1 VERSION
32  
33 version 0.0.1
34  
35 =head1 SYNOPSIS
36  
37 # In configuration:
38  
39 [SortLines::IPAddresses]
40 select = file_with_ips
41  
42 =head1 DESCRIPTION
43  
44 Sorts the lines of a file containing ip addresses, one per line. Whitespace lines are
45 discarded.
46  
47 =head1 ACKNOWLEDGEMENTS
48  
49 This code was essentially pilfered from L<Code::TidyAll::Plugin::SortLines>
50  
51 =head1 AUTHOR
52  
53 Kevin Phair <phair.kevin@gmail.com>
54  
55 =head1 COPYRIGHT AND LICENSE
56  
57 This software is Copyright (c) 2017 by Kevin Phair.
58  
59 This is free software, licensed under:
60  
61 The (three-clause) BSD License
62  
63 =cut
64  
65 __END__
↑ Summary