| 1 | package MarpaX::Languages::Dash::Filer; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use warnings qw(FATAL utf8); # Fatalize encoding glitches. | ||
| 6 | |||
| 7 | use File::Basename; # For basename(). | ||
| 8 | |||
| 9 | use Moo; | ||
| 10 | |||
| 11 | our $VERSION = '1.00'; | ||
| 12 | |||
| 13 | # ------------------------------------------------ | ||
| 14 | |||
| 15 | sub get_files | ||
| 16 | { | ||
| 17 | my($self, $dir_name, $type) = @_; | ||
| 18 | |||
| 19 | opendir(my $fh, $dir_name); | ||
| 20 | my(@file) = sort grep{/$type$/} readdir $fh; | ||
| 21 | closedir $fh; | ||
| 22 | |||
| 23 | my(%file); | ||
| 24 | |||
| 25 | for my $file_name (@file) | ||
| 26 | { | ||
| 27 | $file{basename($file_name, ".$type")} = $file_name; | ||
| 28 | } | ||
| 29 | |||
| 30 | return %file; | ||
| 31 | |||
| 32 | } # End of get_files. | ||
| 33 | |||
| 34 | # ----------------------------------------------- | ||
| 35 | |||
| 36 | 1; | ||
| 37 | |||
| 38 | =pod | ||
| 39 | |||
| 40 | =head1 NAME | ||
| 41 | |||
| 42 | L<MarpaX::Languages::Dash::Filer> - Utils used by MarpaX::Languages::Dash | ||
| 43 | |||
| 44 | =head1 Synopsis | ||
| 45 | |||
| 46 | Returns a hash of files' basenames and their names. Used by L<MarpaX::Languages::Dash::Utils>. | ||
| 47 | |||
| 48 | =head1 Description | ||
| 49 | |||
| 50 | Some utils to simplify testing. | ||
| 51 | |||
| 52 | End-users do not need to call the methods in this module. | ||
| 53 | |||
| 54 | =head1 Distributions | ||
| 55 | |||
| 56 | This module is available as a Unix-style distro (*.tgz). | ||
| 57 | |||
| 58 | See L<http://savage.net.au/Perl-modules/html/installing-a-module.html> | ||
| 59 | for help on unpacking and installing distros. | ||
| 60 | |||
| 61 | =head1 Installation | ||
| 62 | |||
| 63 | Install L<MarpaX::Languages::Dash> as you would for any C<Perl> module: | ||
| 64 | |||
| 65 | Run: | ||
| 66 | |||
| 67 | cpanm MarpaX::Languages::Dash | ||
| 68 | |||
| 69 | or run: | ||
| 70 | |||
| 71 | sudo cpan MarpaX::Languages::Dash | ||
| 72 | |||
| 73 | or unpack the distro, and then either: | ||
| 74 | |||
| 75 | perl Build.PL | ||
| 76 | ./Build | ||
| 77 | ./Build test | ||
| 78 | sudo ./Build install | ||
| 79 | |||
| 80 | or: | ||
| 81 | |||
| 82 | perl Makefile.PL | ||
| 83 | make (or dmake or nmake) | ||
| 84 | make test | ||
| 85 | make install | ||
| 86 | |||
| 87 | =head1 Constructor and Initialization | ||
| 88 | |||
| 89 | =head2 Calling new() | ||
| 90 | |||
| 91 | C<new()> is called as C<< my($obj) = MarpaX::Languages::Dash::Filer -> new(k1 => v1, k2 => v2, ...) >>. | ||
| 92 | |||
| 93 | It returns a new object of type C<MarpaX::Languages::Dash::Utils>. | ||
| 94 | |||
| 95 | Key-value pairs accepted in the parameter list: | ||
| 96 | |||
| 97 | =over 4 | ||
| 98 | |||
| 99 | =item o (none) | ||
| 100 | |||
| 101 | =back | ||
| 102 | |||
| 103 | =head1 Methods | ||
| 104 | |||
| 105 | =head2 get_files($dir_name, $type) | ||
| 106 | |||
| 107 | Returns a hash of files from the given $dir_name, whose type (extension) matches $type. | ||
| 108 | |||
| 109 | =head1 Version Numbers | ||
| 110 | |||
| 111 | Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions. | ||
| 112 | |||
| 113 | =head1 Machine-Readable Change Log | ||
| 114 | |||
| 115 | The file Changes was converted into Changelog.ini by L<Module::Metadata::Changes>. | ||
| 116 | |||
| 117 | =head1 Support | ||
| 118 | |||
| 119 | Email the author, or log a bug on RT: | ||
| 120 | |||
| 121 | L<https://rt.cpan.org/Public/Dist/Display.html?Name=MarpaX::Languages::Dash>. | ||
| 122 | |||
| 123 | =head1 Author | ||
| 124 | |||
| 125 | L<MarpaX::Languages::Dash> was written by Ron Savage I<E<lt>ron@savage.net.auE<gt>> in 2013. | ||
| 126 | |||
| 127 | Home page: L<http://savage.net.au/index.html>. | ||
| 128 | |||
| 129 | =head1 Copyright | ||
| 130 | |||
| 131 | Australian copyright (c) 2013, Ron Savage. | ||
| 132 | |||
| 133 | All Programs of mine are 'OSI Certified Open Source Software'; | ||
| 134 | you can redistribute them and/or modify them under the terms of | ||
| 135 | The Artistic License, a copy of which is available at: | ||
| 136 | http://www.opensource.org/licenses/index.html | ||
| 137 | |||
| 138 | =cut |