File Coverage

blib/lib/Locale/Scope.pm
Criterion Covered Total %
statement 15 20 75.0
branch n/a
condition 0 2 0.0
subroutine 5 8 62.5
pod 1 2 50.0
total 21 32 65.6


line stmt bran cond sub pod time code
1             package Locale::Scope;
2 2     2   45511 use 5.008005;
  2         8  
  2         86  
3 2     2   13 use strict;
  2         5  
  2         80  
4 2     2   23 use warnings;
  2         5  
  2         129  
5              
6             our $VERSION = "0.03";
7              
8 2     2   2171 use parent qw/Exporter/;
  2         741  
  2         9  
9             our @EXPORT_OK = qw/locale_scope/;
10              
11 2     2   1394 use POSIX qw/setlocale/;
  2         22163  
  2         15  
12              
13 0     0 1   sub locale_scope { __PACKAGE__->new(@_) }
14              
15             sub new {
16 0     0 0   my ($class, $category, $locale) = @_;
17 0   0       return bless +{
18             category => $category,
19             before => setlocale($category),
20             current => setlocale($category, $locale) || die "failed to setlocale. locale: $locale",
21             } => $class;
22             }
23              
24             sub DESTROY {
25 0     0     my $self = shift;
26 0           setlocale($self->{category}, $self->{before});
27             }
28              
29             1;
30             __END__