| 1 | # License: http://creativecommons.org/publicdomain/zero/1.0/ | ||||||||||||||||||||
| 2 | # (CC0 or Public Domain). To the extent possible under law, the author, | ||||||||||||||||||||
| 3 | # Jim Avera (email jim.avera at gmail) has waived all copyright and | ||||||||||||||||||||
| 4 | # related or neighboring rights to this document. | ||||||||||||||||||||
| 5 | # Attribution is requested but not required. | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | ▶ | use strict; use warnings FATAL => 'all'; use feature qw/say state/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 1 | ▶ | use utf8; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | package Spreadsheet::Edit::Preload; | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | # Allow "use <thismodule. VERSION ..." in development sandbox to not bomb | ||||||||||||||||||||
| 13 | 1 | ▶ | { no strict 'refs'; ${__PACKAGE__."::VER"."SION"} = 998.999; } | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 1 | our $VERSION = '1001.005'; # VERSION from Dist::Zilla::Plugin::OurPkgVersion | |||||||||||||||||||
| 15 | 1 | our $DATE = '2026-11-11'; # DATE from Dist::Zilla::Plugin::OurDate | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 1 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 1 | ▶ | use Import::Into; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 1 | require Spreadsheet::Edit; | |||||||||||||||||||
| 20 | 1 | our @CARP_NOT = ('Spreadsheet::Edit'); | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 2 | ▶ | sub import { | ||||||||||||||||||
|
Subroutine
import: called CC=4 SCAR=14.2
| |||||||||||||||||||||
| 23 | 2 | my $pkg = shift; # that's us | |||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 2 | my $callpkg = caller($Exporter::ExportLevel); | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | # Import Spreadsheet::Edit and the usual variables for the user | ||||||||||||||||||||
| 28 | 2 | Spreadsheet::Edit->import::into($callpkg, ':all'); | |||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | # We specially handle option 'verbose' (without 'debug') to only show | ||||||||||||||||||||
| 31 | # the spreadsheet name, rather than tracing all the calls. | ||||||||||||||||||||
| 32 | # | ||||||||||||||||||||
| 33 | 2 | ▶ | my $opthash = ref($_[0]) eq "HASH" ? shift(@_) : {}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | #use Data::Dumper::Interp; | ||||||||||||||||||||
| 36 | 2 | ▶ | my $my_verbose = !$opthash->{debug} && delete($opthash->{verbose}); | ||||||||||||||||||
|
Condition33%1/3
!$$opthash{'debug'} && delete $$opthash{'verbose'}
MC/DC0%0/2
!$$opthash{'debug'} && delete $$opthash{'verbose'}
!$$opthash{'debug'}
delete $$opthash{'verbose'}
Truth table33%1/3
not(A) && B
A= !$$opthash{'debug'}B= delete $$opthash{'verbose'}
| |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | # Create new sheet, possibly specifying title_rx | ||||||||||||||||||||
| 39 | my $sh = Spreadsheet::Edit->new( | ||||||||||||||||||||
| 40 | 2 | map{ $_ => $opthash->{$_} } qw/verbose silent debug/ | |||||||||||||||||||
| 41 | ); | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | # Read the content | ||||||||||||||||||||
| 44 | 2 | $sh->read_spreadsheet($opthash, @_); | |||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 2 | ▶ | if ($my_verbose) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | 0 | warn "> Read ",$sh->data_source(),"\n"; | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | # Tie variables in the caller's package | ||||||||||||||||||||
| 51 | 2 | $sh->tie_column_vars({package => $callpkg}, ':all'); | |||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | # Make it the 'current sheet' in the caller's package | ||||||||||||||||||||
| 54 | 2 | Spreadsheet::Edit::sheet( {package => $callpkg}, $sh ); | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 1 | 1; | |||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||