File Coverage

blib/lib/Sah/PSchema/re_from_str.pm
Criterion Covered Total %
statement 3 7 42.8
branch 0 2 0.0
condition 0 2 0.0
subroutine 1 3 33.3
pod 0 2 0.0
total 4 16 25.0


line stmt bran cond sub pod time code
1             package Sah::PSchema::re_from_str;
2              
3 1     1   337957 use strict;
  1         2  
  1         177  
4              
5             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
6             our $DATE = '2024-05-30'; # DATE
7             our $DIST = 'Sah-PSchemaBundle-Re'; # DIST
8             our $VERSION = '0.003'; # VERSION
9              
10             sub meta {
11             return +{
12 0     0 0   v => 1,
13             args => {
14             always_quote => {
15             summary => 'Passed to Regexp::From::String\'s str_to_re()',
16             schema => 'bool*',
17             },
18             case_insensitive => {
19             summary => 'Passed to Regexp::From::String\'s str_to_re()',
20             schema => 'bool*',
21             },
22             anchored => {
23             summary => 'Passed to Regexp::From::String\'s str_to_re()',
24             schema => 'bool*',
25             },
26             },
27             };
28             }
29              
30             sub get_schema {
31 0     0 0   my ($class, $args, $merge) = @_;
32             return [re => {
33             summary => 'Regexp object from string using Regexp::From::String\'s str_to_re()',
34             description => <<'_',
35              
36             This schema accepts Regexp object or string which will be coerced to Regexp object
37             using 's `str_to_re()` function.
38              
39             Basically, if string is of the form of `/.../` or `qr(...)`, then you could
40             specify metacharacters as if you are writing a literal regexp pattern in Perl.
41             Otherwise, your string will be `quotemeta()`-ed first then compiled to Regexp
42             object. This means in the second case you cannot specify metacharacters.
43              
44             _
45              
46             prefilters => [ ['Re::re_from_str'=>($args || {})] ],
47              
48             examples => [
49             ],
50 0 0 0       %{ $merge || {} },
  0            
51             }];
52             }
53              
54             1;
55             # ABSTRACT: Regexp object from string (parameterized)
56              
57             __END__