| 1 | package Langertha::Raider::Home; | ||||||||||||||||||||
| 2 | # ABSTRACT: Internal resolver of the home and project .raider directories | ||||||||||||||||||||
| 3 | 138 | our $VERSION = '0.503'; | |||||||||||||||||||
| 4 | 138 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 138 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 138 | ▶ | use Path::Tiny; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 918 | ▶ | sub home_dir { $ENV{HOME} // (getpwuid($<))[7] } | ||||||||||||||||||
|
Subroutine
home_dir: called CC=2 SCAR=7.2
Pod
documented
Condition66%2/3
$ENV{"HOME"} // (getpwuid $<)[7]
MC/DC0%0/2
$ENV{"HOME"} // (getpwuid $<)[7]
$ENV{"HOME"}
(getpwuid $<)[7]
Truth table66%2/3
A // B
A= $ENV{"HOME"}B= (getpwuid $<)[7]
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 4739 | ▶ | sub dir_name { '.raider' } | ||||||||||||||||||
|
Subroutine
dir_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 889 | ▶ | sub home_base { | ||||||||||||||||||
|
Subroutine
home_base: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 14 | 889 | my ( $self, $home ) = @_; | |||||||||||||||||||
| 15 | 889 | ▶ | $home //= $self->home_dir; | ||||||||||||||||||
|
Condition100%3/3
$home //= $self->home_dir
MC/DC100%2/2
$home //= $self->home_dir
$home
$self->home_dir
Truth table100%3/3
A //= B
A= $homeB= $self->home_dir
| |||||||||||||||||||||
| 16 | 889 | ▶ | return unless defined $home; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 17 | 887 | return $self->_base($home); | |||||||||||||||||||
| 18 | } | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 3694 | ▶ | sub project_base { | ||||||||||||||||||
|
Subroutine
project_base: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 21 | 3694 | my ( $self, $root ) = @_; | |||||||||||||||||||
| 22 | 3694 | return $self->_base($root); | |||||||||||||||||||
| 23 | } | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 4581 | ▶ | sub _base { path($_[1])->absolute->child($_[0]->dir_name) } | ||||||||||||||||||
|
Subroutine
_base: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 138 | 1; | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | __END__ | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | =pod | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | =encoding UTF-8 | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | =head1 NAME | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | Langertha::Raider::Home - Internal resolver of the home and project .raider directories | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | =head1 VERSION | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | version 0.503 | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | =head1 SYNOPSIS | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | # Internal to Langertha-Raider -- no API promise. | ||||||||||||||||||||
| 46 | my $home = Langertha::Raider::Home->home_dir; # $ENV{HOME}, else getpwuid | ||||||||||||||||||||
| 47 | my $user = Langertha::Raider::Home->home_base; # ~/.raider | ||||||||||||||||||||
| 48 | my $proj = Langertha::Raider::Home->project_base($root); # <root>/.raider | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =head1 DESCRIPTION | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | B<Internal module.> Its interface may change without notice. | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | The one place that knows where the F<.raider> directories of a user and of a | ||||||||||||||||||||
| 55 | project live (ADR 0011). Class methods only; every path is returned as an | ||||||||||||||||||||
| 56 | absolute L<Path::Tiny>. | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | =head2 home_dir | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | The user's home: C<$ENV{HOME}>, else the home from the password database. | ||||||||||||||||||||
| 61 | May be C<undef> when neither knows one. | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | =head2 dir_name | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | The name of the directory inside a home or project, C<.raider>. | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | =head2 home_base | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | my $base = Langertha::Raider::Home->home_base; # ~/.raider | ||||||||||||||||||||
| 70 | my $base = Langertha::Raider::Home->home_base($home); # <home>/.raider | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | F<.raider> under the given home, by default under L</home_dir>. Returns | ||||||||||||||||||||
| 73 | nothing when there is no home at all. | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | =head2 project_base | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | F<.raider> under the given project root. | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | =head1 SUPPORT | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | =head2 Issues | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | Please report bugs and feature requests on GitHub at | ||||||||||||||||||||
| 84 | L<https://github.com/Getty/langertha-raider/issues>. | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | =head2 IRC | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | =head1 CONTRIBUTING | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | =head1 AUTHOR | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/> | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | This software is copyright (c) 2026 by Torsten Raudssus. | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 103 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | =cut | ||||||||||||||||||||