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.99_01'; # TRIAL
3              
4 3     3   38 $Yukki::TextUtil::VERSION = '0.9901';use v5.24;
  3         10  
5 3     3   15 use utf8;
  3         7  
  3         19  
6              
7 3     3   895 use Encode ();
  3         14503  
  3         49  
8 3     3   1062 use File::Slurper ();
  3         6985  
  3         51  
9 3     3   1882 use IO::Prompter ();
  3         71486  
  3         90  
10 3     3   833 use YAML ();
  3         10313  
  3         59  
11              
12 3     3   20 use namespace::clean;
  3         7  
  3         25  
13              
14             # ABSTRACT: Utilities to help make everything happy UTF-8
15              
16              
17 3         31 use Sub::Exporter -setup => {
18             exports => [ qw(
19             dump_file
20             load_file
21             prompt
22             ) ],
23 3     3   1083 };
  3         3027  
24              
25              
26             sub dump_file {
27 0     0 1 0 my ($file, $data) = @_;
28 0         0 File::Slurper::write_text("$file", YAML::Dump($data));
29             }
30              
31              
32             sub load_file {
33 2     2 1 1122 my ($file) = @_;
34 2         34 YAML::Load(File::Slurper::read_text("$file"));
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.99_01
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