NAME
Data::TagDB::Factory - Work with Tag databases
VERSION
version v0.06
SYNOPSIS
use Data::TagDB;
my Data::TagDB::Factory $factory = $db->factory;
This module is used to create tags from other data. It is useful specifically when importing data or creating standard objects.
Note: This module requires write access to the database. In addition to the requested tags it may inject some well known tags (such as for types).
METHODS
db
my Data::TagDB $db = $factory->db;
Returns the current Data::TagDB object.
cache
my Data::TagDB::Cache $cache = $factory->cache;
Returns the Data::TagDB::Cache object used by this factory.
wk
my Data::TagDB::WellKnown $wk = $factory->wk;
This is a proxy for "wk" in Data::TagDB.
create_namespace
my Data::TagDB::Tag $tag = $factory->create_namespace($uuid, $tagname);
This creates a new namespace tag. Optionally $tagname
can be given to set a tagname.
create_generator
my Data::TagDB::Tag $tag = $factory->create_generator(%opts);
Creates a generator tag.
The following options are supported:
uuid
(required)-
The UUID of the generator.
tagname
-
A tagname for the generator.
ns
-
The namespace used by the generator. Can be a UUID or a Data::TagDB::Tag.
for_type
-
The type this generator is generating tags of.
create_wikidata
my Data::TagDB::Tag $tag = $factory->create_wikidata($qid);
# e.g.:
my Data::TagDB::Tag $tag = $factory->create_wikidata('Q2');
Generates a tag for Wikidata item (Q), property (P), or lexeme (L).
create_integer
my Data::TagDB::Tag $tag = $factory->create_integer($int);
# e.g.:
my Data::TagDB::Tag $tag = $factory->create_integer(5);
Generates a tag for an integer (positive or negative).
create_character
my Data::TagDB::Tag $tag = $factory->create_character($unicode_code_point);
# or:
my Data::TagDB::Tag $tag = $factory->create_character($type => $value);
# e.g.:
my Data::TagDB::Tag $tag = $factory->create_integer('U+1F981');
# or:
my Data::TagDB::Tag $tag = $factory->create_integer(0x1F981);
# or:
my Data::TagDB::Tag $tag = $factory->create_integer(raw => 'A');
Creates a tag for a character.
The code point may be passed in different ways. If no type is given unicode
is assumed. The following types are supported:
unicode
-
The Unicode code point either in standard
U+xxxx
notation or as a numerical value. ascii
-
The value as an US-ASCII code. The code is checked to be within the limits of US-ASCII.
raw
-
The value as a raw string. Note that this requires the passed value to be a Perl unicode string. This may also result in unexpected behaviour if the passed value is composed of multiple unicode code points. This can for example be the case when modifiers are used with some code points.
create_colour
my Data::TagDB::Tag $tag = $factory->create_colour($colour);
# e.g.:
my Data::TagDB::Tag $tag = $factory->create_colour('#c0c0c0');
# or:
my Data::URIID::Colour $colour = ...;
my Data::TagDB::Tag $tag = $factory->create_colour($colour);
Creates a tag for a colour. The passed colour must be in hash-and-hex format or a valid colour object from one of the supported modules.
Currently Data::URIID::Colour, Color::Library::Color, and Graphics::Color::RGB are supported.
create_date
my Data::TagDB::Tag $tag = $factory->create_date($date, %opts);
# e.g.:
my Data::TagDB::Tag $tag = $factory->create_date('2024-06-20Z');
# or:
my Data::TagDB::Tag $tag = $factory->create_date('today');
# or:
my Data::TagDB::Tag $tag = $factory->create_date($^T);
Takes a date and converts it to a tag. The date may be in ISO-8601 format with the time zone given as UTC (Z
), an integer being the UNIX epoch, an object that implements an epoch
method (such as DateTime), a code reference to a sub returning any thing from this list, or the special string now
, or today
.
Options are:
min_precision
-
The minimum required precision. Defaults to the value of
precision
or theyear
. max_precision
-
The maximum allowed precision. Defaults to the value of
precision
or theday
. precision
-
The default value for
min_precision
, andmax_precision
. Most often only this option is set to force a specific precision.
Valid precision values are: year
, month
, day
.
generate
my Data::TagDB::Tag $tag = $factory->generate(%opts);
This is the generic generation method. Calling this method directly should be avoided in in favour of calling on of the create_...
methods.
The following options are supported:
tagname
-
A tagname for the generator.
ns
-
The namespace used by the generator. Can be a UUID or a Data::TagDB::Tag.
generator
-
The generator to use. If this generator contains all the required data many of the other values may be skipped.
input
-
The input to the hashing function. This should be avoided to be used.
$request
is the preferred option. request
-
The generator request.
style
-
The style of the generator. Also know as it's type.
copy_names
-
Whether or not to copy tagnames.
AUTHOR
Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2024 by Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)