File Coverage

blib/lib/Yukki/TextUtil.pm
Criterion Covered Total %
statement 25 28 89.2
branch n/a
condition n/a
subroutine 9 11 81.8
pod 3 3 100.0
total 37 42 88.1


line stmt bran cond sub pod time code
1             package Yukki::TextUtil;
2             $Yukki::TextUtil::VERSION = '0.991_002'; # TRIAL
3              
4 3     3   61 $Yukki::TextUtil::VERSION = '0.991002';use v5.24;
  3         10  
5 3     3   19 use utf8;
  3         7  
  3         32  
6              
7 3     3   92 use Encode ();
  3         8  
  3         83  
8 3     3   1969 use IO::Prompter ();
  3         81831  
  3         122  
9 3     3   97 use Path::Tiny;
  3         11  
  3         224  
10 3     3   21 use YAML ();
  3         6  
  3         115  
11              
12 3     3   16 use namespace::clean;
  3         6  
  3         35  
13              
14             # ABSTRACT: Utilities to help make everything happy UTF-8
15              
16              
17 3         36 use Sub::Exporter -setup => {
18             exports => [ qw(
19             dump_file
20             load_file
21             prompt
22             ) ],
23 3     3   1320 };
  3         3430  
24              
25              
26             sub dump_file {
27 0     0 1 0 my ($file, $data) = @_;
28 0         0 path($file)->spew_utf8(YAML::Dump($data));
29             }
30              
31              
32             sub load_file {
33 2     2 1 1413 my ($file) = @_;
34 2         15 YAML::Load(path($file)->slurp_utf8);
35             }
36              
37              
38             sub prompt {
39 0     0 1   Encode::decode('UTF-8', IO::Prompter::prompt(@_));
40             }
41              
42             1;
43              
44             __END__
45              
46             =pod
47              
48             =encoding UTF-8
49              
50             =head1 NAME
51              
52             Yukki::TextUtil - Utilities to help make everything happy UTF-8
53              
54             =head1 VERSION
55              
56             version 0.991_002
57              
58             =head1 DESCRIPTION
59              
60             Yukki aims at fully supporting UTF-8 in everything it does. Please report any bugs you find. This library exports tools used internally to help make sure that input is decoded from UTF-8 on the way in and encoded into UTF-8 on the way out.
61              
62             =head1 SUBROUTINES
63              
64             =head2 dump_file
65              
66             dump_file($file, $data);
67              
68             This is pretty much identical in purpose to L<YAML/DumpFile>, but encodes to UTF-8 on the way out.
69              
70             =head2 load_file
71              
72             $data = load_file($file);
73              
74             This is similar to L<YAML/LoadFile>, but decodes from UTF-8 while reading input.
75              
76             =head2 prompt
77              
78             $value = prompt(...);
79              
80             This is similar to L<IO::Prompter/prompt>, but decodes UTF-8 in the input.
81              
82             =head1 AUTHOR
83              
84             Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
85              
86             =head1 COPYRIGHT AND LICENSE
87              
88             This software is copyright (c) 2017 by Qubling Software LLC.
89              
90             This is free software; you can redistribute it and/or modify it under
91             the same terms as the Perl 5 programming language system itself.
92              
93             =cut