| 1 | package Yukki::TextUtil; | ||
| 2 | 13 | $Yukki::TextUtil::VERSION = '0.991_002'; # TRIAL | |
| 3 | |||
| 4 | 13 | ▶ | $Yukki::TextUtil::VERSION = '0.991002';use v5.24; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 13 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 13 | ▶ | use Encode (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 13 | ▶ | use IO::Prompter (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 13 | ▶ | use Path::Tiny; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 13 | ▶ | use YAML (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 13 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | # ABSTRACT: Utilities to help make everything happy UTF-8 | ||
| 15 | |||
| 16 | |||
| 17 | 13 | use Sub::Exporter -setup => { | |
| 18 | exports => [ qw( | ||
| 19 | dump_file | ||
| 20 | load_file | ||
| 21 | prompt | ||
| 22 | ) ], | ||
| 23 | 13 | ▶ | }; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | |||
| 25 | |||
| 26 | sub dump_file { | ||
| 27 | 0 | ▶ | my ($file, $data) = @_; |
|
Subroutine
dump_file: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 28 | 0 | path($file)->spew_utf8(YAML::Dump($data)); | |
| 29 | } | ||
| 30 | |||
| 31 | |||
| 32 | sub load_file { | ||
| 33 | 12 | ▶ | my ($file) = @_; |
|
Subroutine
load_file: called CC=1 SCAR=0.0
Pod
documented
| |||
| 34 | 12 | YAML::Load(path($file)->slurp_utf8); | |
| 35 | } | ||
| 36 | |||
| 37 | |||
| 38 | sub prompt { | ||
| 39 | 16 | ▶ | Encode::decode('UTF-8', IO::Prompter::prompt(@_)); |
|
Subroutine
prompt: called CC=1 SCAR=0.0
Pod
documented
| |||
| 40 | } | ||
| 41 | |||
| 42 | 13 | 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 | ||