| 1 | package File::Find::Rule::DMIDecode; | ||||||||||
| 2 | |||||||||||
| 3 | 5 | ▶ | use base qw(File::Find::Rule); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 5 | ▶ | use List::MoreUtils qw(any); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 5 | ▶ | use Parse::DMIDecode; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 5 | ▶ | use Perl6::Slurp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 5 | our $VERSION = 0.04; | |||||||||
| 12 | |||||||||||
| 13 | # Detect dmidecode file. | ||||||||||
| 14 | sub File::Find::Rule::dmidecode_file { | ||||||||||
| 15 | 1 | ▶ | my $file_find_rule = shift; | ||||||||
|
Subroutine
dmidecode_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 16 | 1 | my $self = $file_find_rule->_force_object; | |||||||||
| 17 | return $self->file->exec(sub{ | ||||||||||
| 18 | 1 | ▶ | my $file = shift; | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||
| 19 | |||||||||||
| 20 | 1 | my $data = slurp($file); | |||||||||
| 21 | 1 | my $dmidecode = Parse::DMIDecode->new; | |||||||||
| 22 | 1 | $dmidecode->parse($data); | |||||||||
| 23 | |||||||||||
| 24 | 1 | ▶ | return $dmidecode->dmidecode_version ? 1 : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 1 | }); | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | sub File::Find::Rule::dmidecode_handle { | ||||||||||
| 29 | 2 | ▶ | my ($file_find_rule, $handle) = @_; | ||||||||
|
Subroutine
dmidecode_handle: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 30 | 2 | my $self = $file_find_rule->_force_object; | |||||||||
| 31 | return $self->file->exec(sub{ | ||||||||||
| 32 | 2 | ▶ | my $file = shift; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 33 | |||||||||||
| 34 | 2 | my $data = slurp($file); | |||||||||
| 35 | 2 | my $dmidecode = Parse::DMIDecode->new; | |||||||||
| 36 | 2 | $dmidecode->parse($data); | |||||||||
| 37 | |||||||||||
| 38 | 2 | ▶ | return any { $_->handle eq $handle } $dmidecode->get_handles; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 39 | 2 | }); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | sub File::Find::Rule::dmidecode_type { | ||||||||||
| 43 | 2 | ▶ | my ($file_find_rule, $dmi_type) = @_; | ||||||||
|
Subroutine
dmidecode_type: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 44 | 2 | my $self = $file_find_rule->_force_object; | |||||||||
| 45 | return $self->file->exec(sub{ | ||||||||||
| 46 | 2 | ▶ | my $file = shift; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 47 | |||||||||||
| 48 | 2 | my $data = slurp($file); | |||||||||
| 49 | 2 | my $dmidecode = Parse::DMIDecode->new; | |||||||||
| 50 | 2 | $dmidecode->parse($data); | |||||||||
| 51 | |||||||||||
| 52 | 2 | return $dmidecode->get_handles(dmitype => $dmi_type); | |||||||||
| 53 | 2 | }); | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 5 | 1; | |||||||||
| 57 | |||||||||||
| 58 | __END__ | ||||||||||