NAME
Data::ShortNameProvider::Style::Basic - Basic style for Data::ShortNameProvider
SYNOPSIS
my $np = Data::ShortNameProvider->new(
style => 'Basic', # default
timestamp_epoch => 1400023019, # defaults to time()
max_name_length => 32, # croak if a longer name is generated
# style-specific arguments
prefix => 'dbit',
version => 1,
);
Directly:
my $np = Data::ShortNameProvider::Style::Basic->new(
timestamp_epoch => 1400023019, # defaults to time()
prefix => 'dbit',
version => 1,
);
Generate a shortname:
$short_name = $np->generate_name('foo'); # returns "dbit1_140513__foo"
DESCRIPTION
Short names generated with this style will look like the following:
<prefix><version>_<YYMMDD>__<name>
ATTRIBUTES
prefix
A string prefix for the short name.
version
The application can use version
to indicate some change in semantics. I.e., the application could use the version string to give itself some hints about what the short name really means.
One could argue that version could be handled by the application by having it add a digit to the prefix but it seems better to keep them separate.
Default: 1
.
timestamp_epoch
This is a timestamp in Unix epoch, that may be used by the style to produce short names.
Provided by Data::ShortNameProvider::Role::Style.
timestamp
The actual timestamp string used in the generated short name, as produced from "timestamp_epoch".
parsing_regexp
The regular expression used to parse a generated name back into its components.
METHODS
generate_name
my $short_name = $provider->parse_generated_name( $name );
Generate a "short name" for the $name
parameter.
parse_generated_name
my $hash = $provider->parse_generated_name( $short_name );
Return the components of the name as a hash.
is_generated_name
if( $provider->is_generated_name( $name ) ) { ... }
Return a boolean indicating if the $name
string could have been generated by this provider.
Provided by Data::ShortNameProvider::Role::Style.
AUTHOR
Philippe Bruhat (BooK), <book@cpan.org>.
COPYRIGHT
Copyright 2014-2015 Philippe Bruhat (BooK), all rights reserved.
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.