| 1 | package Dist::Conformance::Source 0.011; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Where the standards come from: the flavor files and the templates | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use 5.040; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use re '/aasx'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use Mojo::Base -base, -signatures; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use Dist::Conformance::Schema(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 6 | has path => q{}; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # The directory of the whole tree. A subclass must implement it. | ||||||||||||||||||||||||||||
| 16 | # @returns InstanceOf["Mojo::File"] the directory | ||||||||||||||||||||||||||||
| 17 | # @throws when the subclass does not implement it | ||||||||||||||||||||||||||||
| 18 | # @example my $top = $source->root; | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub root ($self) { die( ref($self) . " does not implement root\n" ) } | ||||||||||||||||||||||||||
|
Subroutine
root: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # A short description of the source for a message, such as the URL and the ref. | ||||||||||||||||||||||||||||
| 22 | # A subclass must implement it. | ||||||||||||||||||||||||||||
| 23 | # @returns Str the description | ||||||||||||||||||||||||||||
| 24 | # @throws when the subclass does not implement it | ||||||||||||||||||||||||||||
| 25 | # @example say 'Flavor from ', $source->describe; | ||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub describe ($self) { die( ref($self) . " does not implement describe\n" ) } | ||||||||||||||||||||||||||
|
Subroutine
describe: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # The directory that L</path> names. | ||||||||||||||||||||||||||||
| 29 | # @returns InstanceOf["Mojo::File"] the directory | ||||||||||||||||||||||||||||
| 30 | # @throws as L</root> does | ||||||||||||||||||||||||||||
| 31 | # @example my $standards = $source->base; | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub base ($self) { | ||||||||||||||||||||||||||
|
Subroutine
base: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 33 | 0 | my $root = $self->root; | |||||||||||||||||||||||||||
| 34 | 0 | ▶ | return $self->path ne q{} ? $root->child( split m{/}, $self->path ) : $root; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # The bytes of the file at C<$relative> below L</base>. | ||||||||||||||||||||||||||||
| 38 | # @param relative Str the path of the file, relative to L</base> | ||||||||||||||||||||||||||||
| 39 | # @returns Str the bytes | ||||||||||||||||||||||||||||
| 40 | # @throws when there is no such file, and on an absolute path or a path with a | ||||||||||||||||||||||||||||
| 41 | # C<..> component | ||||||||||||||||||||||||||||
| 42 | # @example my $flavor_text = $source->file('conformance/troglodyne.yml'); | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub file ( $self, $relative ) { | ||||||||||||||||||||||||||
|
Subroutine
file: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 0 | Dist::Conformance::Schema::relative_path( $relative, 'the standards' ); | |||||||||||||||||||||||||||
| 45 | 0 | my $file = $self->base->child( split m{/}, $relative ); | |||||||||||||||||||||||||||
| 46 | 0 | ▶ | die( "The standards at " . $self->describe . " have no $relative\n" ) if !-e $file || -d _; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not -e $file or -d _
MC/DC0%0/2
not -e $file or -d _
not -e $file
-d _
Truth table0%0/3
not(A) or B
A= not -e $fileB= -d _
| |||||||||||||||||||||||||||||
| 47 | 0 | return $file->slurp; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # Whether L<file|/"file(relative)"> would find C<$relative>. | ||||||||||||||||||||||||||||
| 51 | # @param relative Str the path of the file, relative to L</base> | ||||||||||||||||||||||||||||
| 52 | # @returns Bool | ||||||||||||||||||||||||||||
| 53 | # @throws as L</root> does | ||||||||||||||||||||||||||||
| 54 | # @example my $has = $source->exists_file('templates/perlcriticrc'); | ||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub exists_file ( $self, $relative ) { | ||||||||||||||||||||||||||
|
Subroutine
exists_file: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | 0 | my $file = $self->base->child( split m{/}, $relative ); | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | return -e $file && !-d _; | ||||||||||||||||||||||||||
|
Condition0%0/3
-e $file && !-d(_)
MC/DC0%0/2
-e $file && !-d(_)
-e $file
!-d(_)
Truth table0%0/3
A && not(B)
A= -e $fileB= !-d(_)
| |||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||||||||||