Data::ShortNameProvider::Style::Basic - Basic style for Data::ShortNameProvider
Via Data::ShortNameProvider:
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"
Short names generated with this style will look like the following:
<prefix><version>_<YYMMDD>__<name>
A string prefix for the short name.
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.
version
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.
1
This is a timestamp in Unix epoch, that may be used by the style to produce short names.
Provided by Data::ShortNameProvider::Role::Style.
The actual timestamp string used in the generated short name, as produced from "timestamp_epoch".
The regular expression used to parse a generated name back into its components.
my $short_name = $provider->parse_generated_name( $name );
Generate a "short name" for the $name parameter.
$name
my $hash = $provider->parse_generated_name( $short_name );
Return the components of the name as a hash.
if( $provider->is_generated_name( $name ) ) { ... }
Return a boolean indicating if the $name string could have been generated by this provider.
Philippe Bruhat (BooK), <book@cpan.org>.
Copyright 2014-2015 Philippe Bruhat (BooK), all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Data::ShortNameProvider, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::ShortNameProvider
CPAN shell
perl -MCPAN -e shell install Data::ShortNameProvider
For more information on module installation, please visit the detailed CPAN module installation guide.