Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/book/data-shortnameprovider
Create short names containing useful information
https://github.com/book/data-shortnameprovider
Last synced: about 1 month ago
JSON representation
Create short names containing useful information
- Host: GitHub
- URL: https://github.com/book/data-shortnameprovider
- Owner: book
- Created: 2014-05-14T08:28:02.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-04-21T09:02:13.000Z (over 9 years ago)
- Last Synced: 2024-10-03T12:36:22.993Z (4 months ago)
- Language: Perl
- Homepage: http://metacpan.org/pod/Data::ShortNameProvider
- Size: 234 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
Awesome Lists containing this project
README
NAME
Data::ShortNameProvider - Generate short names with style
SYNOPSIS
Create a name provider:
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,
);Generate a shortname:
$short_name = $np->generate_name('foo'); # returns "dbit1_140513__foo"
Parse a generated shortname:
$hash = $np->parse_generated_name($short_name);
$hash contains something like:
# depends on the style
{
prefix => 'dbit',
version => 1,
timestamp => '140513',
timestamp_epoch => 1400023019,
name => 'foo',
}or "undef" if $short_name could not be parsed as a short name generated
with that style.Check if a string is parsable:
my @names = grep { $np->is_generated_name($_) } @names;
DESCRIPTION
Create short names that encode a timestamp and a fixed label in a format
that's unlikely to match normal names.A typical use-case would be the creation of database table names or file
names in situations where you need to minimize the risk of clashing with
existing items.The generated names can be detected and parsed to extract the timestamp
and other components.ACKNOWLEDGEMENTS
This module is based on an idea and proposal by Tim Bunce, on the
"dbi-dev" mailing-list.The initial thread about Test::Database shortcomings:
Tim's proposal for a short name provider:
The first implementaion of the module was written during the first two
days of the Perl QA Hackathon 2015 in Berlin (with Tim Bunce providing
extensive feedback on IRC). Many thanks to TINITA for organizing this
event!AUTHOR
Philippe Bruhat (BooK), .
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.