Skip to content

Commit 4735db3

Browse files
committed
Complete the dashboard
1 parent 2def38c commit 4735db3

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

Makefile.PL

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ WriteMakefile(
3939
'File::stat' => 0,
4040
'File::Temp' => 0,
4141
'IPC::Run3' => 0,
42+
'IPC::System::Simple' => 0,
4243
'JSON::MaybeXS' => 0,
4344
'POSIX' => 0,
4445
'Readonly' => 0,

README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,34 @@ Dies: If count is not a positive integer
164164

165165
Warns: If unable to generate the requested number of unique strings
166166

167+
## set\_seed($seed)
168+
169+
Sets the random seed for reproducible generation
170+
171+
## validate($string)
172+
173+
Checks if a string matches the pattern without generating.
174+
175+
if ($gen->validate('1234')) {
176+
print "Valid!\n";
177+
}
178+
179+
## pattern\_info()
180+
181+
Returns detailed information about the pattern.
182+
183+
my $info = $gen->pattern_info();
184+
print "Complexity: $info->{complexity}\n";
185+
print "Min length: $info->{min_length}\n";
186+
print "Has Unicode: ", $info->{features}{has_unicode} ? "Yes" : "No", "\n";
187+
188+
`pattern_info` analyzes a regular expression to produce a structured summary of its characteristics,
189+
including estimated string lengths, detected features, and an overall complexity rating.
190+
It first calls `_estimate_length` to heuristically compute the minimum and maximum possible lengths of strings matching the pattern by scanning for literals,
191+
character classes, and quantifiers.
192+
It then detects the presence of advanced regex constructions such as alternation, lookahead or lookbehind assertions, named groups, and Unicode properties, storing them in a feature hash.
193+
Finally, it calculates a rough "complexity" classification based on pattern length and detected features-returning a hash reference that describes the regex's structure, estimated lengths, and complexity level.
194+
167195
## create\_random\_string
168196

169197
For consistency with [Data::Random::String](https://metacpan.org/pod/Data%3A%3ARandom%3A%3AString).
@@ -174,10 +202,11 @@ For consistency with [Data::Random::String](https://metacpan.org/pod/Data%3A%3AR
174202

175203
Nigel Horne, `<njh at nigelhorne.com>`
176204

177-
# LICENSE
205+
# SEE ALSO
178206

179-
This is free software; you can redistribute it and/or modify it under
180-
the same terms as Perl itself.
207+
- Test coverage report: [https://nigelhorne.github.io/Data-Random-String-Matches/coverage/](https://nigelhorne.github.io/Data-Random-String-Matches/coverage/)
208+
- [String::Random](https://metacpan.org/pod/String%3A%3ARandom)
209+
- [Regexp::Genex](https://metacpan.org/pod/Regexp%3A%3AGenex)
181210

182211
# LICENCE AND COPYRIGHT
183212

lib/Data/Random/String/Matches.pm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,13 @@ Returns detailed information about the pattern.
403403
print "Min length: $info->{min_length}\n";
404404
print "Has Unicode: ", $info->{features}{has_unicode} ? "Yes" : "No", "\n";
405405
406+
C<pattern_info> analyzes a regular expression to produce a structured summary of its characteristics,
407+
including estimated string lengths, detected features, and an overall complexity rating.
408+
It first calls C<_estimate_length> to heuristically compute the minimum and maximum possible lengths of strings matching the pattern by scanning for literals,
409+
character classes, and quantifiers.
410+
It then detects the presence of advanced regex constructions such as alternation, lookahead or lookbehind assertions, named groups, and Unicode properties, storing them in a feature hash.
411+
Finally, it calculates a rough "complexity" classification based on pattern length and detected features-returning a hash reference that describes the regex's structure, estimated lengths, and complexity level.
412+
406413
=cut
407414

408415
sub pattern_info {

0 commit comments

Comments
 (0)