File Coverage

blib/lib/HTML/KhatGallery/Plugin/SortNaturally.pm
Criterion Covered Total %
statement 9 23 39.1
branch 0 4 0.0
condition n/a
subroutine 3 5 60.0
pod 2 2 100.0
total 14 34 41.1


line stmt bran cond sub pod time code
1             package HTML::KhatGallery::Plugin::SortNaturally;
2 1     1   23107 use strict;
  1         3  
  1         41  
3 1     1   5 use warnings;
  1         3  
  1         52  
4              
5             =head1 NAME
6              
7             HTML::KhatGallery::Plugin::SortNaturally - Plugin for khatgallery to use Natural sort for index lists.
8              
9             =head1 VERSION
10              
11             This describes version B<0.01> of HTML::KhatGallery::Plugin::SortNaturally.
12              
13             =cut
14              
15             our $VERSION = '0.01';
16              
17             =head1 SYNOPSIS
18              
19             # use the khatgallery script
20             khatgallery --plugins HTML::KhatGallery::Plugin::SortNaturally I
21            
22             # from within a script
23             require HTML::KhatGallery;
24              
25             my @plugins = qw(HTML::KhatGallery:;Core HTML::KhatGallery::Plugin::SortNaturally);
26             HTML::KhatGallery->import(@plugins);
27             HTML::KhatGallery->run(%args);
28              
29             =head1 DESCRIPTION
30              
31             This is a plugin for khatgallery to use Natural sort for index lists.
32              
33             =cut
34              
35 1     1   2342 use Sort::Naturally;
  1         5255  
  1         261  
36              
37             =head1 OBJECT METHODS
38              
39             Documentation for developers and those wishing to write plugins.
40              
41             =head1 Dir Action Methods
42              
43             Methods implementing directory-related actions. All such actions
44             expect a reference to a state hash, and generally will update either
45             that hash or the object itself, or both, in the course of their
46             running.
47              
48             =head2 sort_images
49              
50             Sorts the $dir_state->{files} array.
51              
52             =cut
53             sub sort_images {
54 0     0 1   my $self = shift;
55 0           my $dir_state = shift;
56              
57 0 0         if (@{$dir_state->{files}})
  0            
58             {
59 0           my @images = nsort(@{$dir_state->{files}});
  0            
60 0           $dir_state->{files} = \@images;
61             }
62             } # sort_images
63              
64             =head2 sort_dirs
65              
66             Sorts the $dir_state->{subdirs} array.
67              
68             =cut
69             sub sort_dirs {
70 0     0 1   my $self = shift;
71 0           my $dir_state = shift;
72              
73 0 0         if (@{$dir_state->{subdirs}})
  0            
74             {
75 0           my @dirs = nsort(@{$dir_state->{subdirs}});
  0            
76 0           $dir_state->{subdirs} = \@dirs;
77             }
78             } # sort_dirs
79              
80              
81             =head1 REQUIRES
82              
83             Test::More
84             HTML::KhatGallery
85             Sort::Naturally
86              
87             =head1 INSTALLATION
88              
89             To install this module, run the following commands:
90              
91             perl Build.PL
92             ./Build
93             ./Build test
94             ./Build install
95              
96             Or, if you're on a platform (like DOS or Windows) that doesn't like the
97             "./" notation, you can do this:
98              
99             perl Build.PL
100             perl Build
101             perl Build test
102             perl Build install
103              
104             In order to install somewhere other than the default, such as
105             in a directory under your home directory, like "/home/fred/perl"
106             go
107              
108             perl Build.PL --install_base /home/fred/perl
109              
110             as the first step instead.
111              
112             This will install the files underneath /home/fred/perl.
113              
114             You will then need to make sure that you alter the PERL5LIB variable to
115             find the modules.
116              
117             Therefore you will need to change the PERL5LIB variable to add
118             /home/fred/perl/lib
119              
120             PERL5LIB=/home/fred/perl/lib:${PERL5LIB}
121              
122             =head1 SEE ALSO
123              
124             perl(1).
125              
126             =head1 BUGS
127              
128             Please report any bugs or feature requests to the author.
129              
130             =head1 AUTHOR
131              
132             Kathryn Andersen (RUBYKAT)
133             perlkat AT katspace dot com
134             http://www.katspace.org/tools
135              
136             =head1 COPYRIGHT AND LICENCE
137              
138             Copyright (c) 2006 by Kathryn Andersen
139              
140             This program is free software; you can redistribute it and/or modify it
141             under the same terms as Perl itself.
142              
143             =cut
144              
145             1; # End of HTML::KhatGallery::Plugin::SortNaturally
146             __END__