File Coverage

blib/lib/Data/Sah/Coerce/perl/To_str/From_str/Ltrim.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 20 22 90.9


line stmt bran cond sub pod time code
1             package Data::Sah::Coerce::perl::To_str::From_str::Ltrim;
2              
3             # AUTHOR
4             our $DATE = '2019-11-28'; # DATE
5             our $DIST = 'Data-Sah-Coerce-perl-To_str-From_str-Trim'; # DIST
6             our $VERSION = '0.005'; # VERSION
7              
8 1     1   1784 use 5.010001;
  1         3  
9 1     1   5 use strict;
  1         1  
  1         19  
10 1     1   4 use warnings;
  1         2  
  1         133  
11              
12             sub meta {
13             +{
14 1     1 0 12 v => 4,
15             summary => 'Trim whitespaces at the beginning of string',
16             prio => 50,
17             };
18             }
19              
20             sub coerce {
21 1     1 0 14 my %args = @_;
22              
23 1         2 my $dt = $args{data_term};
24              
25 1         2 my $res = {};
26              
27 1         2 $res->{expr_match} = "!ref($dt)";
28 1         3 $res->{expr_coerce} = join(
29             "",
30             "do { my \$res = $dt; \$res =~ s/\\A\\s+//s; \$res }",
31             );
32              
33 1         3 $res;
34             }
35              
36             1;
37             # ABSTRACT: Trim whitespaces at the beginning of string
38              
39             __END__
40              
41             =pod
42              
43             =encoding UTF-8
44              
45             =head1 NAME
46              
47             Data::Sah::Coerce::perl::To_str::From_str::Ltrim - Trim whitespaces at the beginning of string
48              
49             =head1 VERSION
50              
51             This document describes version 0.005 of Data::Sah::Coerce::perl::To_str::From_str::Ltrim (from Perl distribution Data-Sah-Coerce-perl-To_str-From_str-Trim), released on 2019-11-28.
52              
53             =head1 SYNOPSIS
54              
55             To use in a Sah schema:
56              
57             ["str",{"x.perl.coerce_rules"=>["From_str::Ltrim"]}]
58              
59             =for Pod::Coverage ^(meta|coerce)$
60              
61             =head1 HOMEPAGE
62              
63             Please visit the project's homepage at L<https://metacpan.org/release/Data-Sah-Coerce-perl-To_str-From_str-Trim>.
64              
65             =head1 SOURCE
66              
67             Source repository is at L<https://github.com/perlancar/perl-Data-Sah-Coerce-perl-To_str-From_str-Trim>.
68              
69             =head1 BUGS
70              
71             Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Sah-Coerce-perl-To_str-From_str-Trim>
72              
73             When submitting a bug or request, please include a test-file or a
74             patch to an existing test-file that illustrates the bug or desired
75             feature.
76              
77             =head1 AUTHOR
78              
79             perlancar <perlancar@cpan.org>
80              
81             =head1 COPYRIGHT AND LICENSE
82              
83             This software is copyright (c) 2019, 2018 by perlancar@cpan.org.
84              
85             This is free software; you can redistribute it and/or modify it under
86             the same terms as the Perl 5 programming language system itself.
87              
88             =cut