NAME
oEdtk::Utils - generic text, index, date and tracking helpers
SYNOPSIS
use oEdtk::Utils qw(delete_useless_whitespaces IDX_FORMAT);
my $clean = delete_useless_whitespaces(" a b "); # "a b"
my $fmt = IDX_FORMAT();
DESCRIPTION
Generic helpers ported from the fork's oEdtk::Utils at S23: text cleanup (delete_useless_whitespaces, kill_non_latin_1_9_chars_in_place, trim_list), the index format (IDX_FORMAT), date and price parsing (parse_jjmmaaaa, parse_yyyymmdd, parse_price, convert_date, month_to_name), tracking (track_begin, track, track_end, TRACK_MODE_BATCH) and small value helpers (flatten_index_variables, max_value, scalar_dump, alert).
The corporate part of the fork's module -- init and the INDEX_* accessors, which call oEUser::Lib or name corporate schema identifiers -- lives in oEUser::Utils. Their old names are kept here as delegates: they forward to the companion distribution, which is loaded on demand, and a missing oEUser fails with a clear message. This module itself never depends on oEUser.
FUNCTIONS
delete_useless_whitespaces
my $clean = delete_useless_whitespaces($string);
Remove the surrounding whitespace and collapse internal runs to a single space. Croaks on an undef argument.
IDX_FORMAT
my $format = IDX_FORMAT();
Return the current index format, an array reference of [ old_tag, new_field, offset ] entries.
kill_non_latin_1_9_chars_in_place
kill_non_latin_1_9_chars_in_place(\$string);
Replace, in place, the DEL and C1 control bytes of $string with spaces.
alert
alert($flow_file, $line_number, $message, @objects);
Carp an alert carrying the flow file, the line number and the objects.
flatten_index_variables
my $index = flatten_index_variables($record);
Return a hash reference of the index_variables sub-hash, each key prefixed with index.
max_value
my $max = max_value(\@values);
Return the greatest value of the list reference, compared as strings.
parse_jjmmaaaa
my $parts = parse_jjmmaaaa($string, $flow_file, $line_number);
Parse a dd/mm/yyyy string into [ day, "month_name year" ], or raise an alert and return.
parse_price
my $price = parse_price($number, $flow_file, $line_number);
Return the price unchanged when it is valid, otherwise raise an alert.
parse_yyyymmdd
my $parts = parse_yyyymmdd($string, $flow_file, $line_number);
Parse a yyyymmdd string into [ day, "month_name year" ], or raise an alert and return.
scalar_dump
my $readable = scalar_dump($string);
Render the non-printable bytes of $string as hexadecimal escapes, for display.
track
track($tracking, \@fields, $type);
Track one document on the given tracking object, with an optional event type.
track_begin
my $tracking = track_begin($job, $user, \@fields, $mode);
Start tracking and return the tracking object. The tracking class and the toolkit are loaded on demand.
track_end
track_end($tracking);
Record the end-of-run tracking event on the given object.
trim_list
my $string = trim_list(@parts);
Join the list with single spaces, collapsing runs of whitespace.
The unexported helpers check_date, convert_date, month_to_name, my_dumper, latest_idx1_in_directory, comment_index_file, TRACK_MODE_BATCH and _delegate, and the corporate accessors init and the INDEX_* names, are not part of the public API; the accessors delegate on demand to the companion oEUser::Utils.
AUTHOR
The oEdtk team.