App-Info
view release on metacpan or search on metacpan
lib/App/Info/Lib/OSSPUUID.pm view on Meta::CPAN
# Handle an unknown value.
unless ($self->{version}) {
# Create a validation code reference.
my $chk_version = sub {
# Try to get the version number parts.
my ($x, $y, $z) = /^(\d+)\.(\d+).(\d+)$/;
# Return false if we didn't get all three.
return unless $x and defined $y and defined $z;
# Save all three parts.
@{$self}{qw(major minor patch)} = ($x, $y, $z);
# Return true.
return 1;
};
$self->{version} = $self->unknown(
key => 'OSSP UUID version number',
callback => $chk_version
);
}
return $self->{version};
}
##############################################################################
=head3 major version
my $major_version = $uuid->major_version;
Returns the OSSP UUID library major version number. App::Info::Lib::OSSPUUID
parses the major version number from the system call C<`uuid-config
--version`>. For example, if C<version()> returns "1.3.0", then this method
returns "1".
B<Events:>
=over 4
=item info
Executing `uuid-config --version`
=item error
Failed to find OSSP UUID version with `uuid-config --version`
Unable to parse name from string
Unable to parse version from string
Failed to parse OSSP UUID version parts from string
=item unknown
Enter a valid OSSP UUID major version number
=back
=cut
# This code reference is used by major_version(), minor_version(), and
# patch_version() to validate a version number entered by a user.
my $is_int = sub { /^\d+$/ };
sub major_version {
my $self = shift;
return unless $self->{uuid_config};
# Load data.
$get_version->($self) unless exists $self->{'--version'};
# Handle an unknown value.
$self->{major} = $self->unknown(
key => 'OSSP UUID major version number',
callback => $is_int
) unless $self->{major};
return $self->{major};
}
##############################################################################
=head3 minor version
my $minor_version = $uuid->minor_version;
Returns the OSSP UUID library minor version number. App::Info::Lib::OSSPUUID
parses the minor version number from the system call C<`uuid-config
--version`>. For example, if C<version()> returns "1.3.0", then this method
returns "3".
B<Events:>
=over 4
=item info
Executing `uuid-config --version`
=item error
Failed to find OSSP UUID version with `uuid-config --version`
Unable to parse name from string
Unable to parse version from string
Failed to parse OSSP UUID version parts from string
=item unknown
Enter a valid OSSP UUID minor version number
=back
=cut
sub minor_version {
my $self = shift;
return unless $self->{uuid_config};
# Load data.
$get_version->($self) unless exists $self->{'--version'};
# Handle an unknown value.
$self->{minor} = $self->unknown(
key => 'OSSP UUID minor version number',
lib/App/Info/Lib/OSSPUUID.pm view on Meta::CPAN
# Find executable.
$self->info("Looking for $key");
unless ($self->{$key}) {
my $bin = $self->bin_dir or return;
if (my $exe = $u->first_cat_exe([$self->search_uuid_names], $bin)) {
# We found it. Confirm.
$self->{$key} = $self->confirm(
key => "path to $key",
prompt => "Path to $key executable?",
value => $exe,
callback => sub { -x },
error => 'Not an executable'
);
} else {
# Handle an unknown value.
$self->{$key} = $self->unknown(
key => "path to $key",
prompt => "Path to $key executable?",
callback => sub { -x },
error => 'Not an executable'
);
}
}
return $self->{$key};
};
*uuid = \&executable;
##############################################################################
=head3 bin_dir
my $bin_dir = $uuid->bin_dir;
Returns the OSSP UUID binary directory path. App::Info::Lib::OSSPUUID gathers
the path from the system call C<`uuid-config --bindir`>.
B<Events:>
=over 4
=item info
Executing `uuid-config --bindir`
=item error
Cannot find bin directory
=item unknown
Enter a valid OSSP UUID bin directory
=back
=cut
# This code reference is used by bin_dir(), lib_dir(), and so_lib_dir() to
# validate a directory entered by the user.
my $is_dir = sub { -d };
sub bin_dir {
my $self = shift;
return unless $self->{uuid_config};
unless (exists $self->{bin_dir} ) {
if (my $dir = $get_data->($self, '--bindir')) {
$self->{bin_dir} = $dir;
} else {
# Handle an unknown value.
$self->error("Cannot find bin directory");
$self->{bin_dir} = $self->unknown(
key => 'OSSP UUID bin dir',
callback => $is_dir
);
}
}
return $self->{bin_dir};
}
##############################################################################
=head3 inc_dir
my $inc_dir = $uuid->inc_dir;
Returns the OSSP UUID include directory path. App::Info::Lib::OSSPUUID gathers
the path from the system call C<`uuid-config --includedir`>.
B<Events:>
=over 4
=item info
Executing `uuid-config --includedir`
=item error
Cannot find include directory
=item unknown
Enter a valid OSSP UUID include directory
=back
=cut
sub inc_dir {
my $self = shift;
return unless $self->{uuid_config};
unless (exists $self->{inc_dir} ) {
if (my $dir = $get_data->($self, '--includedir')) {
$self->{inc_dir} = $dir;
} else {
# Handle an unknown value.
$self->error("Cannot find include directory");
$self->{inc_dir} = $self->unknown(
( run in 0.499 second using v1.01-cache-2.11-cpan-39bf76dae61 )