File Coverage

blib/lib/Colouring/In/XS.pm
Criterion Covered Total %
statement 24 24 100.0
branch 6 6 100.0
condition 3 4 75.0
subroutine 6 6 100.0
pod 1 1 100.0
total 40 41 97.5


line stmt bran cond sub pod time code
1             package Colouring::In::XS;
2              
3 18     18   2146998 use 5.006;
  18         74  
4 18     18   130 use strict;
  18         118  
  18         766  
5 18     18   153 use warnings;
  18         77  
  18         3239  
6              
7             our $VERSION = '0.07';
8              
9             require XSLoader;
10             XSLoader::load('Colouring::In::XS', $VERSION);
11              
12             sub import {
13 18     18   169 my ($pkg, @exports) = @_;
14 18         50 my $caller = caller;
15 18 100       105 set_messages(pop @exports) if (ref $exports[-1] eq 'HASH');
16 18 100       13460 if (scalar @exports) {
17 18     18   135 no strict 'refs';
  18         57  
  18         5389  
18 11         29 *{"${caller}::${_}"} = \&{"${_[0]}::${_}"} foreach @exports;
  11         20620  
  11         99  
19             }
20             }
21              
22             sub validate {
23 4     4 1 160237 my ($self, $colour) = @_;
24 4         10 my $new = eval { $self->new($colour) };
  4         34  
25 4 100       12 if ($@) {
26             return {
27 3   100     0 valid => \0,
28             message => get_message('VALIDATE_ERROR') || 'The string passed to Colouring::In::XS::validate is not a valid color.',
29             color => $colour
30             };
31             }
32             return {
33 1   50     10 valid => \1,
34             message => get_message('VALIDATE') || 'The string passed to Colouring::In::XS::validate is a valid color',
35             color => $colour,
36             colour => $new
37             };
38             }
39              
40             1;
41              
42             __END__