App-ThisDist

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    Please visit the project's homepage at
    <https://metacpan.org/release/App-ThisDist>.

SOURCE
    Source repository is at
    <https://github.com/perlancar/perl-App-ThisDist>.

SEE ALSO
    App::DistUtils

    my_dist() from Dist::Util::Current tries to guess distribution name
    associated with source code file. It uses us when guessing via $DIST or
    .packlist files fail.

AUTHOR
    perlancar <perlancar@cpan.org>

CONTRIBUTING
    To contribute, you can send patches by email/via RT, or send pull
    requests on GitHub.

    Most of the time, you don't need to build the distribution yourself. You

lib/App/ThisDist.pm  view on Meta::CPAN

                    log_debug "Guessed distname=$distname from .git/config URL '$url'";
                    $detailinfo->{source} = "git config";
                    # XXX extract version?
                    last GUESS;
                }
            }
        }

      __DISABLED__FROM_REPO_NAME: {
            last; # currently disabled
            log_debug "Using CPAN::Dist::FromRepoName to guess from dir name ...";
            require CPAN::Dist::FromRepoName;
            my $res = CPAN::Dist::FromRepoName::extract_cpan_dist_from_repo_name($dir_basename);
            if (defined $res) {
                $distname = $res;
                log_debug "Guessed distname=$distname from repo name '$dir_basename'";
                $detailinfo->{source} = "repo name";
                # XXX extract version?
                last GUESS;
            }
        }

lib/App/ThisDist.pm  view on Meta::CPAN

            }
            last unless defined $dist;
            $distname = $dist;
            $distver  = $ver;
            log_debug "Guessed distname=$distname from a single perl archive file in the directory ($distfile)";
            $detailinfo->{source} = "archive";
            $detailinfo->{archive_file} = $distfile;
            last GUESS;
        }

        log_debug "Can't guess distribution, giving up";
    } # GUESS

    if ($detail) {
        $detailinfo->{dist} = $distname;
        $detailinfo->{dist_version} = $distver;
        $detailinfo;
    } else {
        return unless defined $distname;
        $extract_version ? "$distname ".(defined $distver ? $distver : "?") : $distname;
    }

lib/App/ThisDist.pm  view on Meta::CPAN

Please visit the project's homepage at L<https://metacpan.org/release/App-ThisDist>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-ThisDist>.

=head1 SEE ALSO

L<App::DistUtils>

C<my_dist()> from L<Dist::Util::Current> tries to guess distribution name
associated with source code file. It uses us when guessing via C<$DIST> or
F<.packlist> files fail.

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 CONTRIBUTING


To contribute, you can send patches by email/via RT, or send pull requests on

script/this-dist  view on Meta::CPAN

This document describes version 0.023 of this-dist (from Perl distribution App-ThisDist), released on 2024-01-06.

=head1 SYNOPSIS

 % pwd
 /home/budi/perl-Foo-Bar

 % this-dist
 Foo-Bar

 # See how distribution is guessed
 % DEBUG=1 this-dist
 this-dist: Guessed dist=App-PPIUtils from dist.ini
 Foo-Bar

 # Will exit with code 1 and print error message to stderr when dist cannot be guessed
 % cd /
 % this-dist
 this-dist: No perl distribution name can be associated with current directory '/'

 # Don't show error message when guessing is failed (just exit with code 1)
 % this-dist -q
 % _

 # Also try to extract version
 % this-dist -V
 Foo-Bar 1.23

Some other examples:

 # Show MetaCPAN distribution page in browser (but see this-dist-on-metacpan script)
 % firefox metacpan.org/release/`this-dist`

=head1 DESCRIPTION

This script tries these methods when guessing Perl distribution name associated
with current directory:

=over

=item * Distribution metadata {MYMETA,META}.{json,yml}

=item * Makefile.PL, Makefile, Build.PL

=item * Name in F<dist.ini> (L<Dist::Zilla> configuration file), if the file is available

script/this-mod  view on Meta::CPAN


 # (Re)install this module using L<cpanminus|App::cpanminus>:
 % cpanm -n --reinstall `this-mod`

 # remove namespace prefix
 % cd repos/perl-Acme-CPANModules-Symlink
 % cpanmodules ls-entries `this-mod -n Acme::CPANModules`

=head1 DESCRIPTION

This script tries these methods when guessing Perl module name associated with
current directory. First it tries to find the associated Perl distribution name:

=over

=item * Distribution metadata {MYMETA,META}.{json,yml}

=item * Makefile.PL, Makefile, Build.PL

=item * Name in F<dist.ini> (L<Dist::Zilla> configuration file), if the file is available



( run in 1.080 second using v1.01-cache-2.11-cpan-702932259ff )