File Coverage

blib/lib/Digital.pm
Criterion Covered Total %
statement 30 33 90.9
branch 1 4 25.0
condition n/a
subroutine 9 9 100.0
pod 0 2 0.0
total 40 48 83.3


line stmt bran cond sub pod time code
1             package Digital;
2             our $AUTHORITY = 'cpan:GETTY';
3             # ABSTRACT: Handling conversion of digital values towards physical units
4             $Digital::VERSION = '0.003';
5 3     3   717 use strict;
  3         7  
  3         90  
6 3     3   16 use warnings;
  3         5  
  3         71  
7 3     3   501 use Package::Stash;
  3         8251  
  3         74  
8 3     3   17 use Module::Runtime qw( use_module );
  3         6  
  3         15  
9              
10             our %inputs;
11              
12             sub register_input {
13 3     3 0 22 my ( undef, $input, $input_class ) = @_;
14 3 50       16 unless (defined $input_class) {
15 3         18 $input_class = $input;
16 3         13 $input = lc($input_class);
17 3         9 $input =~ s!::!_!g;
18 3         6 $input =~ s!^digitalx_!!g;
19             }
20 3         329 $inputs{$input} = $input_class;
21             }
22              
23             sub input {
24 2     2 0 12 my ( $class, $input, @args ) = @_;
25 2         8 my $input_class = $inputs{$input};
26 2         16 return $input_class->input(@args);
27             }
28              
29             sub import {
30 3     3   122 my ( $class, @args ) = @_;
31 3         11 my ( $caller ) = caller;
32 3         30 my $stash = Package::Stash->new($caller);
33 3         6 my @classes;
34 3 0       9 for (@args) { unless (/^-/) {
  0         0  
35 0         0 push @classes, 'DigitalX::'.$_;
36             } }
37 3         10 for (@classes) {
38 0         0 use_module($_);
39             }
40 3     2   3328 $stash->add_symbol('&input', sub { return $class->input(@_) });
  2     2   218  
41             }
42              
43             1;
44              
45             __END__