| 1 | # Connector::Builtin::File::Simple | ||||||||||
| 2 | # | ||||||||||
| 3 | # Proxy class for accessing simple file | ||||||||||
| 4 | # | ||||||||||
| 5 | # Written by Martin Bartosch for the OpenXPKI project 2012 | ||||||||||
| 6 | # | ||||||||||
| 7 | package Connector::Builtin::File::Simple; | ||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use English; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use File::Spec; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 1 | extends 'Connector::Builtin'; | |||||||||
| 17 | |||||||||||
| 18 | 3 | ▶ | sub get { | ||||||||
|
Subroutine
get: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 19 | |||||||||||
| 20 | 3 | my $self = shift; | |||||||||
| 21 | |||||||||||
| 22 | 3 | my $filename = $self->{LOCATION}; | |||||||||
| 23 | |||||||||||
| 24 | 3 | ▶ | if (! -r $filename) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | return $self->_node_not_exists( ); | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 3 | my $content = do { | |||||||||
| 29 | 3 | local $INPUT_RECORD_SEPARATOR; | |||||||||
| 30 | 3 | open my $fh, '<', $filename; | |||||||||
| 31 | 3 | <$fh>; | |||||||||
| 32 | }; | ||||||||||
| 33 | |||||||||||
| 34 | 3 | return $content; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | sub get_meta { | ||||||||
|
Subroutine
get_meta: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 38 | 0 | my $self = shift; | |||||||||
| 39 | 0 | return { TYPE => "scalar" }; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 2 | ▶ | sub exists { | ||||||||
|
Subroutine
exists: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 43 | |||||||||||
| 44 | 2 | my $self = shift; | |||||||||
| 45 | |||||||||||
| 46 | 2 | my $filename = $self->{LOCATION}; | |||||||||
| 47 | |||||||||||
| 48 | 2 | return -r $filename; | |||||||||
| 49 | } | ||||||||||
| 50 | 1 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 51 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 52 | |||||||||||
| 53 | 1 | 1; | |||||||||
| 54 | __END__ | ||||||||||