App-Info
view release on metacpan or search on metacpan
lib/App/Info/Lib/Iconv.pm view on Meta::CPAN
use strict;
use File::Basename ();
use App::Info::Util;
use App::Info::Lib;
use vars qw(@ISA $VERSION);
@ISA = qw(App::Info::Lib);
$VERSION = '0.57';
use constant WIN32 => $^O eq 'MSWin32';
my $u = App::Info::Util->new;
##############################################################################
=head1 INTERFACE
=head2 Constructor
=head3 new
my $iconv = App::Info::Lib::Iconv->new(@params);
Returns an App::Info::Lib::Iconv object. See L<App::Info|App::Info> for a
complete description of argument parameters.
When called, C<new()> searches the the list of directories returned by the
C<search_bin_dirs()> method for an executable file with a name returned by the
C<search_exe_names()> method. If the executable is found, libiconv will be
assumed to be installed. Otherwise, most of the object methods will return
C<undef>.
B<Events:>
=over 4
=item info
Searching for iconv
=item unknown
Path to iconv executable?
=item confirm
Path to iconv executable?
=back
=cut
sub new {
my $self = shift->SUPER::new(@_);
# Find iconv.
$self->info("Searching for iconv");
if (my $exe = $u->first_cat_exe([$self->search_exe_names],
$self->search_bin_dirs)) {
# We found it. Confirm.
$self->{executable} = $self->confirm(
key => 'path to iconv',
prompt => 'Path to iconv executable?',
value => $exe,
callback => sub { -x },
error => 'Not an executable'
);
} else {
# No luck. Ask 'em for it.
$self->{executable} = $self->unknown(
key => 'path to iconv',
prompt => 'Path to iconv executable?',
callback => sub { -x },
error => 'Not an executable'
);
}
return $self;
}
##############################################################################
=head2 Class Method
=head3 key_name
my $key_name = App::Info::Lib::Iconv->key_name;
Returns the unique key name that describes this class. The value returned is
the string "libiconv".
=cut
sub key_name { 'libiconv' }
##############################################################################
=head2 Object Methods
=head3 installed
print "libiconv is ", ($iconv->installed ? '' : 'not '),
"installed.\n";
Returns true if libiconv is installed, and false if it is not.
App::Info::Lib::Iconv determines whether libiconv is installed based on the
presence or absence of the F<iconv> application, as found when C<new()>
constructed the object. If libiconv does not appear to be installed, then most
of the other object methods will return empty values.
=cut
sub installed { $_[0]->{executable} ? 1 : undef }
##############################################################################
=head3 name
my $name = $iconv->name;
Returns the name of the application. In this case, C<name()> simply returns
the string "libiconv".
=cut
sub name { 'libiconv' }
##############################################################################
=head3 version
my $version = $iconv->version;
( run in 0.458 second using v1.01-cache-2.11-cpan-6aa56a78535 )