App-ENumberUtils

 view release on metacpan or  search on metacpan

lib/App/ENumberUtils.pm  view on Meta::CPAN


This distribution contains the following CLIs:

=over

=item 1. L<list-enumber-ranges>

=item 2. L<list-enumbers>

=back

=head1 FUNCTIONS


=head2 list_enumber_ranges

Usage:

 list_enumber_ranges(%args) -> [$status_code, $reason, $payload, \%result_meta]

List E Number ranges.

This function is not exported by default, but exportable.

Arguments ('*' denotes required arguments):

=over 4

=item * B<description> => I<str>

Only return records where the 'description' field equals specified value.

=item * B<description.contains> => I<str>

Only return records where the 'description' field contains specified text.

=item * B<description.in> => I<array[str]>

Only return records where the 'description' field is in the specified values.

=item * B<description.is> => I<str>

Only return records where the 'description' field equals specified value.

=item * B<description.isnt> => I<str>

Only return records where the 'description' field does not equal specified value.

=item * B<description.matches> => I<str>

Only return records where the 'description' field matches specified regular expression pattern.

=item * B<description.max> => I<str>

Only return records where the 'description' field is less than or equal to specified value.

=item * B<description.min> => I<str>

Only return records where the 'description' field is greater than or equal to specified value.

=item * B<description.not_contains> => I<str>

Only return records where the 'description' field does not contain specified text.

=item * B<description.not_in> => I<array[str]>

Only return records where the 'description' field is not in the specified values.

=item * B<description.not_matches> => I<str>

Only return records where the 'description' field does not match specified regular expression.

=item * B<description.xmax> => I<str>

Only return records where the 'description' field is less than specified value.

=item * B<description.xmin> => I<str>

Only return records where the 'description' field is greater than specified value.

=item * B<detail> => I<bool> (default: 0)

Return array of full records instead of just ID fields.

By default, only the key (ID) field is returned per result entry.

=item * B<exclude_fields> => I<array[str]>

Select fields to return.

=item * B<fields> => I<array[str]>

Select fields to return.

=item * B<queries> => I<array[str]>

Search.

This will search all searchable fields with one or more specified queries. Each
query can be in the form of C<-FOO> (dash prefix notation) to require that the
fields do not contain specified string, or C</FOO/> to use regular expression.
All queries must match if the C<query_boolean> option is set to C<and>; only one
query should match if the C<query_boolean> option is set to C<or>.

=item * B<query_boolean> => I<str> (default: "and")

Whether records must match all search queries ('and') or just one ('or').

If set to C<and>, all queries must match; if set to C<or>, only one query should
match. See the C<queries> option for more details on searching.

=item * B<random> => I<bool> (default: 0)

Return records in random order.

=item * B<range> => I<str>

Only return records where the 'range' field equals specified value.

=item * B<range.contains> => I<str>

Only return records where the 'range' field contains specified text.

=item * B<range.in> => I<array[str]>

Only return records where the 'range' field is in the specified values.

=item * B<range.is> => I<str>

Only return records where the 'range' field equals specified value.

=item * B<range.isnt> => I<str>

Only return records where the 'range' field does not equal specified value.

=item * B<range.matches> => I<str>

Only return records where the 'range' field matches specified regular expression pattern.

=item * B<range.max> => I<str>

Only return records where the 'range' field is less than or equal to specified value.

=item * B<range.min> => I<str>

Only return records where the 'range' field is greater than or equal to specified value.

=item * B<range.not_contains> => I<str>

Only return records where the 'range' field does not contain specified text.

=item * B<range.not_in> => I<array[str]>

Only return records where the 'range' field is not in the specified values.

=item * B<range.not_matches> => I<str>

Only return records where the 'range' field does not match specified regular expression.

=item * B<range.xmax> => I<str>

Only return records where the 'range' field is less than specified value.

=item * B<range.xmin> => I<str>

Only return records where the 'range' field is greater than specified value.

=item * B<result_limit> => I<int>

Only return a certain number of records.

=item * B<result_start> => I<int> (default: 1)

Only return starting from the n'th record.

=item * B<sort> => I<array[str]>

Order records according to certain field(s).

A list of field names separated by comma. Each field can be prefixed with '-' to
specify descending order instead of the default ascending.

=item * B<subrange> => I<str>

Only return records where the 'subrange' field equals specified value.

=item * B<subrange.contains> => I<str>

Only return records where the 'subrange' field contains specified text.

=item * B<subrange.in> => I<array[str]>

Only return records where the 'subrange' field is in the specified values.

=item * B<subrange.is> => I<str>

Only return records where the 'subrange' field equals specified value.

=item * B<subrange.isnt> => I<str>

Only return records where the 'subrange' field does not equal specified value.

=item * B<subrange.matches> => I<str>

Only return records where the 'subrange' field matches specified regular expression pattern.

=item * B<subrange.max> => I<str>

Only return records where the 'subrange' field is less than or equal to specified value.

=item * B<subrange.min> => I<str>

Only return records where the 'subrange' field is greater than or equal to specified value.

=item * B<subrange.not_contains> => I<str>

Only return records where the 'subrange' field does not contain specified text.

=item * B<subrange.not_in> => I<array[str]>

Only return records where the 'subrange' field is not in the specified values.

=item * B<subrange.not_matches> => I<str>

Only return records where the 'subrange' field does not match specified regular expression.

=item * B<subrange.xmax> => I<str>

Only return records where the 'subrange' field is less than specified value.

=item * B<subrange.xmin> => I<str>

Only return records where the 'subrange' field is greater than specified value.

=item * B<with_field_names> => I<bool>

Return field names in each record (as hashE<sol>associative array).

When enabled, function will return each record as hash/associative array
(field name => value pairs). Otherwise, function will return each record
as list/array (field value, field value, ...).


=back

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code
(200 means OK, 4xx caller error, 5xx function error). Second element
($reason) is a string containing error message, or something like "OK" if status is
200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth
element (%result_meta) is called result metadata and is optional, a hash
that contains extra information, much like how HTTP response headers provide additional metadata.

Return value:  (any)



=head2 list_enumbers

Usage:

 list_enumbers(%args) -> [$status_code, $reason, $payload, \%result_meta]

List E Numbers.

This function is not exported by default, but exportable.

Arguments ('*' denotes required arguments):

=over 4

=item * B<code> => I<str>

Only return records where the 'code' field equals specified value.

=item * B<code.contains> => I<str>

Only return records where the 'code' field contains specified text.

=item * B<code.in> => I<array[str]>

Only return records where the 'code' field is in the specified values.

=item * B<code.is> => I<str>

Only return records where the 'code' field equals specified value.

=item * B<code.isnt> => I<str>

Only return records where the 'code' field does not equal specified value.

=item * B<code.matches> => I<str>

Only return records where the 'code' field matches specified regular expression pattern.

=item * B<code.max> => I<str>

Only return records where the 'code' field is less than or equal to specified value.

=item * B<code.min> => I<str>

Only return records where the 'code' field is greater than or equal to specified value.

=item * B<code.not_contains> => I<str>

Only return records where the 'code' field does not contain specified text.

=item * B<code.not_in> => I<array[str]>

Only return records where the 'code' field is not in the specified values.

=item * B<code.not_matches> => I<str>

Only return records where the 'code' field does not match specified regular expression.

=item * B<code.xmax> => I<str>

Only return records where the 'code' field is less than specified value.

=item * B<code.xmin> => I<str>

Only return records where the 'code' field is greater than specified value.

=item * B<color_index> => I<int>

Only return records where the 'color_index' field equals specified value.

=item * B<color_index.in> => I<array[int]>

Only return records where the 'color_index' field is in the specified values.

=item * B<color_index.is> => I<int>

Only return records where the 'color_index' field equals specified value.

=item * B<color_index.isnt> => I<int>

Only return records where the 'color_index' field does not equal specified value.

=item * B<color_index.max> => I<int>

Only return records where the 'color_index' field is less than or equal to specified value.

=item * B<color_index.min> => I<int>

Only return records where the 'color_index' field is greater than or equal to specified value.

=item * B<color_index.not_in> => I<array[int]>

Only return records where the 'color_index' field is not in the specified values.

=item * B<color_index.xmax> => I<int>

Only return records where the 'color_index' field is less than specified value.

=item * B<color_index.xmin> => I<int>

Only return records where the 'color_index' field is greater than specified value.

=item * B<colour> => I<str>

Only return records where the 'colour' field equals specified value.

=item * B<colour.contains> => I<str>

Only return records where the 'colour' field contains specified text.

=item * B<colour.in> => I<array[str]>

Only return records where the 'colour' field is in the specified values.

=item * B<colour.is> => I<str>

Only return records where the 'colour' field equals specified value.

=item * B<colour.isnt> => I<str>

Only return records where the 'colour' field does not equal specified value.

=item * B<colour.matches> => I<str>

Only return records where the 'colour' field matches specified regular expression pattern.

=item * B<colour.max> => I<str>

Only return records where the 'colour' field is less than or equal to specified value.

=item * B<colour.min> => I<str>

Only return records where the 'colour' field is greater than or equal to specified value.

=item * B<colour.not_contains> => I<str>

Only return records where the 'colour' field does not contain specified text.

=item * B<colour.not_in> => I<array[str]>

Only return records where the 'colour' field is not in the specified values.

=item * B<colour.not_matches> => I<str>

Only return records where the 'colour' field does not match specified regular expression.

=item * B<colour.xmax> => I<str>

Only return records where the 'colour' field is less than specified value.

=item * B<colour.xmin> => I<str>

Only return records where the 'colour' field is greater than specified value.

=item * B<detail> => I<bool> (default: 0)

Return array of full records instead of just ID fields.

By default, only the key (ID) field is returned per result entry.

=item * B<exclude_fields> => I<array[str]>

Select fields to return.

=item * B<fields> => I<array[str]>

Select fields to return.

=item * B<names> => I<str>

Only return records where the 'names' field equals specified value.

=item * B<names.contains> => I<str>

Only return records where the 'names' field contains specified text.

=item * B<names.in> => I<array[str]>

Only return records where the 'names' field is in the specified values.

=item * B<names.is> => I<str>

Only return records where the 'names' field equals specified value.

=item * B<names.isnt> => I<str>

Only return records where the 'names' field does not equal specified value.

=item * B<names.matches> => I<str>

Only return records where the 'names' field matches specified regular expression pattern.

=item * B<names.max> => I<str>

Only return records where the 'names' field is less than or equal to specified value.

=item * B<names.min> => I<str>

Only return records where the 'names' field is greater than or equal to specified value.

=item * B<names.not_contains> => I<str>

Only return records where the 'names' field does not contain specified text.

=item * B<names.not_in> => I<array[str]>

Only return records where the 'names' field is not in the specified values.

=item * B<names.not_matches> => I<str>

Only return records where the 'names' field does not match specified regular expression.

=item * B<names.xmax> => I<str>

Only return records where the 'names' field is less than specified value.

=item * B<names.xmin> => I<str>

Only return records where the 'names' field is greater than specified value.

=item * B<purpose> => I<str>

Only return records where the 'purpose' field equals specified value.

=item * B<purpose.contains> => I<str>

Only return records where the 'purpose' field contains specified text.

=item * B<purpose.in> => I<array[str]>

Only return records where the 'purpose' field is in the specified values.

=item * B<purpose.is> => I<str>

Only return records where the 'purpose' field equals specified value.

=item * B<purpose.isnt> => I<str>

Only return records where the 'purpose' field does not equal specified value.

=item * B<purpose.matches> => I<str>

Only return records where the 'purpose' field matches specified regular expression pattern.

=item * B<purpose.max> => I<str>

Only return records where the 'purpose' field is less than or equal to specified value.

=item * B<purpose.min> => I<str>

Only return records where the 'purpose' field is greater than or equal to specified value.

=item * B<purpose.not_contains> => I<str>

Only return records where the 'purpose' field does not contain specified text.

=item * B<purpose.not_in> => I<array[str]>

Only return records where the 'purpose' field is not in the specified values.

=item * B<purpose.not_matches> => I<str>

Only return records where the 'purpose' field does not match specified regular expression.

=item * B<purpose.xmax> => I<str>

Only return records where the 'purpose' field is less than specified value.

=item * B<purpose.xmin> => I<str>

Only return records where the 'purpose' field is greater than specified value.

=item * B<queries> => I<array[str]>

Search.

This will search all searchable fields with one or more specified queries. Each
query can be in the form of C<-FOO> (dash prefix notation) to require that the
fields do not contain specified string, or C</FOO/> to use regular expression.
All queries must match if the C<query_boolean> option is set to C<and>; only one
query should match if the C<query_boolean> option is set to C<or>.

=item * B<query_boolean> => I<str> (default: "and")

Whether records must match all search queries ('and') or just one ('or').

If set to C<and>, all queries must match; if set to C<or>, only one query should
match. See the C<queries> option for more details on searching.

=item * B<random> => I<bool> (default: 0)

Return records in random order.

=item * B<result_limit> => I<int>

Only return a certain number of records.

=item * B<result_start> => I<int> (default: 1)

Only return starting from the n'th record.

=item * B<sort> => I<array[str]>

Order records according to certain field(s).

A list of field names separated by comma. Each field can be prefixed with '-' to
specify descending order instead of the default ascending.

=item * B<status> => I<str>

Only return records where the 'status' field equals specified value.

=item * B<status.contains> => I<str>

Only return records where the 'status' field contains specified text.

=item * B<status.in> => I<array[str]>

Only return records where the 'status' field is in the specified values.

=item * B<status.is> => I<str>

Only return records where the 'status' field equals specified value.

=item * B<status.isnt> => I<str>

Only return records where the 'status' field does not equal specified value.

=item * B<status.matches> => I<str>

Only return records where the 'status' field matches specified regular expression pattern.

=item * B<status.max> => I<str>

Only return records where the 'status' field is less than or equal to specified value.

=item * B<status.min> => I<str>

Only return records where the 'status' field is greater than or equal to specified value.

=item * B<status.not_contains> => I<str>

Only return records where the 'status' field does not contain specified text.

=item * B<status.not_in> => I<array[str]>

Only return records where the 'status' field is not in the specified values.

=item * B<status.not_matches> => I<str>

Only return records where the 'status' field does not match specified regular expression.

=item * B<status.xmax> => I<str>

Only return records where the 'status' field is less than specified value.

=item * B<status.xmin> => I<str>

Only return records where the 'status' field is greater than specified value.

=item * B<with_field_names> => I<bool>

Return field names in each record (as hashE<sol>associative array).

When enabled, function will return each record as hash/associative array
(field name => value pairs). Otherwise, function will return each record
as list/array (field value, field value, ...).


=back

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code
(200 means OK, 4xx caller error, 5xx function error). Second element
($reason) is a string containing error message, or something like "OK" if status is
200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth
element (%result_meta) is called result metadata and is optional, a hash
that contains extra information, much like how HTTP response headers provide additional metadata.

Return value:  (any)

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-ENumberUtils>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-ENumberUtils>.

=head1 SEE ALSO

L<https://en.wikipedia.org/wiki/E_number>

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 CONTRIBUTING


To contribute, you can send patches by email/via RT, or send pull requests on
GitHub.

Most of the time, you don't need to build the distribution yourself. You can
simply modify the code, then test via:

 % prove -l



( run in 1.727 second using v1.01-cache-2.11-cpan-39bf76dae61 )