File-RsyBak
view release on metacpan or search on metacpan
script/rsybak view on Meta::CPAN
#sub meta {
# +{
# v => 4,
# prio => 50,
# };
#}
#
#sub coerce {
# my %args = @_;
#
# my $dt = $args{data_term};
#
# my $res = {};
#
# $res->{expr_match} = join(
# " && ",
# "typeof($dt)=='number'",
# "$dt >= " . (10**8),
# "$dt <= " . (2**31),
# );
#
# $res->{expr_coerce} = "(new Date($dt * 1000))";
#
# $res;
#}
#
#1;
#
#__END__
#
### Data/Sah/Coerce/js/date/obj_Date.pm ###
#package Data::Sah::Coerce::js::date::obj_Date;
#
#our $DATE = '2019-01-26';
#our $VERSION = '0.033';
#
#use 5.010001;
#use strict;
#use warnings;
#
#sub meta {
# +{
# v => 4,
# might_fail => 1,
# prio => 50,
# };
#}
#
#sub coerce {
# my %args = @_;
#
# my $dt = $args{data_term};
#
# my $res = {};
#
# $res->{expr_match} = join(
# " && ",
# "($dt instanceof Date)",
# );
#
# $res->{expr_coerce} = "isNaN($dt) ? ['Invalid date'] : [null, $dt]";
#
# $res;
#}
#
#1;
#
#__END__
#
### Data/Sah/Coerce/js/date/str.pm ###
#package Data::Sah::Coerce::js::date::str;
#
#our $DATE = '2019-01-26';
#our $VERSION = '0.033';
#
#use 5.010001;
#use strict;
#use warnings;
#
#sub meta {
# +{
# v => 4,
# might_fail => 1,
# prio => 50,
# };
#}
#
#sub coerce {
# my %args = @_;
#
# my $dt = $args{data_term};
#
# my $res = {};
#
# $res->{expr_match} = join(
# " && ",
# "typeof($dt)=='string'",
# );
#
# $res->{expr_coerce} = "(function (_m) { _m = new Date($dt); if (isNaN(_m)) { return ['Invalid date'] } else { return [null, _m] } })()";
#
# $res;
#}
#
#1;
#
#__END__
#
### Data/Sah/Coerce/js/datenotime/float_epoch.pm ###
#package Data::Sah::Coerce::js::datenotime::float_epoch;
#
#our $DATE = '2019-01-26';
#our $VERSION = '0.033';
#
#use 5.010001;
#use strict;
#use warnings;
#
#use subroutines 'Data::Sah::Coerce::js::date::float_epoch';
#
#1;
#
#__END__
#
### Data/Sah/Coerce/js/datenotime/obj_Date.pm ###
#package Data::Sah::Coerce::js::datenotime::obj_Date;
#
#our $DATE = '2019-01-26';
#our $VERSION = '0.033';
#
#use 5.010001;
#use strict;
#use warnings;
#
#use subroutines 'Data::Sah::Coerce::js::date::obj_Date';
#
#1;
#
#__END__
#
### Data/Sah/Coerce/js/datenotime/str.pm ###
#package Data::Sah::Coerce::js::datenotime::str;
#
#our $DATE = '2019-01-26';
#our $VERSION = '0.033';
#
#use 5.010001;
#use strict;
#use warnings;
#
#use subroutines 'Data::Sah::Coerce::js::date::str';
#
#1;
#
#__END__
#
### Data/Sah/Coerce/js/datetime/float_epoch.pm ###
#package Data::Sah::Coerce::js::datetime::float_epoch;
#
#our $DATE = '2019-01-26';
script/rsybak view on Meta::CPAN
#package Data::Sah::Coerce::js::datetime::obj_Date;
#
#our $DATE = '2019-01-26';
#our $VERSION = '0.033';
#
#use 5.010001;
#use strict;
#use warnings;
#
#use subroutines 'Data::Sah::Coerce::js::date::obj_Date';
#
#1;
#
#__END__
#
### Data/Sah/Coerce/js/datetime/str.pm ###
#package Data::Sah::Coerce::js::datetime::str;
#
#our $DATE = '2019-01-26';
#our $VERSION = '0.033';
#
#use 5.010001;
#use strict;
#use warnings;
#
#use subroutines 'Data::Sah::Coerce::js::date::str';
#
#1;
#
#__END__
#
### Data/Sah/Coerce/js/duration/float_secs.pm ###
#package Data::Sah::Coerce::js::duration::float_secs;
#
#our $DATE = '2019-01-26';
#our $VERSION = '0.033';
#
#use 5.010001;
#use strict;
#use warnings;
#
#sub meta {
# +{
# v => 4,
# prio => 50,
# };
#}
#
#sub coerce {
# my %args = @_;
#
# my $dt = $args{data_term};
# my $coerce_to = $args{coerce_to};
#
# my $res = {};
#
# $res->{expr_match} = join(
# " && ",
# "(typeof($dt)=='number' || typeof($dt)=='string' && $dt.match(/^[0-9]+(?:\\.[0-9]+)?\$/))",
# "parseFloat($dt) >= 0",
# "!isNaN(parseFloat($dt))",
# "isFinite(parseFloat($dt))",
# );
#
# $res->{expr_coerce} = "parseFloat($dt)";
#
# $res;
#}
#
#1;
#
#__END__
#
### Data/Sah/Coerce/js/duration/str_iso8601.pm ###
#package Data::Sah::Coerce::js::duration::str_iso8601;
#
#our $DATE = '2019-01-26';
#our $VERSION = '0.033';
#
#use 5.010001;
#use strict;
#use warnings;
#
#sub meta {
# +{
# v => 4,
# prio => 50,
# };
#}
#
#sub coerce {
# my %args = @_;
#
# my $dt = $args{data_term};
# my $coerce_to = $args{coerce_to};
#
# my $res = {};
#
# my $re_num = '[0-9]+(?:\\.[0-9]+)?';
# my $expr_re_match = "$dt.match(/^P(?:($re_num)Y)?(?:($re_num)M)?(?:($re_num)W)?(?:($re_num)D)?(?:T(?:($re_num)H)?(?:($re_num)M)?(?:($re_num)S)?)?\$/)";
# $res->{expr_match} = join(
# " && ",
# "typeof($dt)=='string'",
# $expr_re_match,
# );
#
#
# $res->{expr_coerce} = "(function(_m) { _m = $expr_re_match; return ((_m[1]||0)*365.25*86400 + (_m[2]||0)*30.4375*86400 + (_m[3]||0)*7*86400 + (_m[4]||0)*86400 + (_m[5]||0)*3600 + (_m[6]||0)*60 + (_m[7]||0)*1) })()";
#
# $res;
#}
#
#1;
#
#__END__
#
### Data/Sah/Coerce/js/timeofday/str_hms.pm ###
#package Data::Sah::Coerce::js::timeofday::str_hms;
#
#our $DATE = '2019-01-26';
#our $VERSION = '0.033';
script/rsybak view on Meta::CPAN
#use Role::Tiny::With;
#
#extends 'Data::Sah::Compiler::human::TH';
#with 'Data::Sah::Compiler::human::TH::Comparable';
#with 'Data::Sah::Compiler::human::TH::Sortable';
#with 'Data::Sah::Type::duration';
#
#sub name { "duration" }
#
#sub handle_type {
# my ($self, $cd) = @_;
# my $c = $self->compiler;
#
# $c->add_ccl($cd, {type=>'noun', fmt => ["duration", "durations"]});
#}
#
#1;
#
#__END__
#
### Data/Sah/Compiler/human/TH/float.pm ###
#package Data::Sah::Compiler::human::TH::float;
#
#our $DATE = '2018-12-16';
#our $VERSION = '0.895';
#
#use 5.010;
#use strict;
#use warnings;
#
#use Mo qw(build default);
#use Role::Tiny::With;
#
#extends 'Data::Sah::Compiler::human::TH';
#with 'Data::Sah::Compiler::human::TH::Comparable';
#with 'Data::Sah::Compiler::human::TH::Sortable';
#with 'Data::Sah::Type::float';
#
#sub name { "decimal number" }
#
#sub handle_type {
# my ($self, $cd) = @_;
# my $c = $self->compiler;
#
# $c->add_ccl($cd, {
# type=>'noun',
# fmt => ["decimal number", "decimal numbers"],
# });
#}
#
#sub clause_is_nan {
# my ($self, $cd) = @_;
# my $c = $self->compiler;
#
# my $cv = $cd->{cl_value};
# if ($cd->{cl_is_expr}) {
# $c->add_ccl($cd, {});
# } else {
# $c->add_ccl($cd, {
# fmt => $cv ?
# q[%(modal_verb)s be a NaN] :
# q[%(modal_verb_neg)s be a NaN],
# });
# }
#}
#
#sub clause_is_inf {
# my ($self, $cd) = @_;
# my $c = $self->compiler;
#
# my $cv = $cd->{cl_value};
# if ($cd->{cl_is_expr}) {
# $c->add_ccl($cd, {});
# } else {
# $c->add_ccl($cd, {
# fmt => $cv ?
# q[%(modal_verb)s an infinity] :
# q[%(modal_verb_neg)s an infinity],
# });
# }
#}
#
#sub clause_is_pos_inf {
# my ($self, $cd) = @_;
# my $c = $self->compiler;
#
# my $cv = $cd->{cl_value};
# if ($cd->{cl_is_expr}) {
# $c->add_ccl($cd, {});
# } else {
# $c->add_ccl($cd, {
# fmt => $cv ?
# q[%(modal_verb)s a positive infinity] :
# q[%(modal_verb_neg)s a positive infinity],
# });
# }
#}
#
#sub clause_is_neg_inf {
# my ($self, $cd) = @_;
# my $c = $self->compiler;
#
# my $cv = $cd->{cl_value};
# if ($cd->{cl_is_expr}) {
# $c->add_ccl($cd, {});
# } else {
# $c->add_ccl($cd, {
# fmt => $cv ?
# q[%(modal_verb)s a negative infinity] :
# q[%(modal_verb_neg)s a negative infinity],
# });
# }
#}
#
#1;
#
#__END__
#
### Data/Sah/Compiler/human/TH/hash.pm ###
#package Data::Sah::Compiler::human::TH::hash;
#
#our $DATE = '2018-12-16';
script/rsybak view on Meta::CPAN
#
#
# q[%(modal_verb)s be either %s],
# q[%s],
#
# q[or %s],
# q[atau %s],
#
# q[%(modal_verb)s be one of the following],
# q[%(modal_verb)s merupakan salah satu dari],
#
#
# q[array],
# q[larik],
#
# q[arrays],
# q[larik],
#
# q[%s of %s],
# q[%s %s],
#
# q[each array element %(modal_verb)s be],
# q[setiap elemen larik %(modal_verb)s],
#
# q[%s %(modal_verb)s be],
# q[%s %(modal_verb)s],
#
# q[element],
# q[elemen],
#
# q[each array subscript %(modal_verb)s be],
# q[setiap subskrip larik %(modal_verb)s],
#
#
# q[boolean value],
# q[nilai boolean],
#
# q[boolean values],
# q[nilai boolean],
#
# q[%(modal_verb)s be true],
# q[%(modal_verb)s bernilai benar],
#
# q[%(modal_verb)s be false],
# q[%(modal_verb)s bernilai salah],
#
#
# q[code],
# q[kode],
#
# q[codes],
# q[kode],
#
#
# q[decimal number],
# q[bilangan desimal],
#
# q[decimal numbers],
# q[bilangan desimal],
#
# q[%(modal_verb)s be a NaN],
# q[%(modal_verb)s NaN],
#
# q[%(modal_verb_neg)s be a NaN],
# q[%(modal_verb_neg)s NaN],
#
# q[%(modal_verb)s be an infinity],
# q[%(modal_verb)s tak hingga],
#
# q[%(modal_verb_neg)s be an infinity],
# q[%(modal_verb_neg)s tak hingga],
#
# q[%(modal_verb)s be a positive infinity],
# q[%(modal_verb)s positif tak hingga],
#
# q[%(modal_verb_neg)s be a positive infinity],
# q[%(modal_verb_neg)s positif tak hingga],
#
# q[%(modal_verb)s be a negative infinity],
# q[%(modal_verb)s negatif tak hingga],
#
# q[%(modal_verb)s be a negative infinity],
# q[%(modal_verb)s negatif tak hingga],
#
#
# q[hash],
# q[hash],
#
# q[hashes],
# q[hash],
#
# q[field %s %(modal_verb)s be],
# q[field %s %(modal_verb)s],
#
# q[field name %(modal_verb)s be],
# q[nama field %(modal_verb)s],
#
# q[each field %(modal_verb)s be],
# q[setiap field %(modal_verb)s],
#
# q[hash contains unknown field(s) (%s)],
# q[hash mengandung field yang tidak dikenali (%s)],
#
# q[hash contains unknown field(s) (%s)],
# q[hash mengandung field yang tidak dikenali (%s)],
#
# q[%(modal_verb)s have required fields %s],
# q[%(modal_verb)s mengandung field wajib %s],
#
# q[hash has missing required field(s) (%s)],
# q[hash kekurangan field wajib (%s)],
#
# q[%(modal_verb)s have %s in its field values],
# q[%(modal_verb)s mengandung %s di nilai field],
#
# q[%(modal_verb)s only have these allowed fields %s],
# q[%(modal_verb)s hanya mengandung field yang diizinkan %s],
#
# q[%(modal_verb)s only have fields matching regex pattern %s],
# q[%(modal_verb)s hanya mengandung field yang namanya mengikuti pola regex %s],
#
# q[%(modal_verb_neg)s have these forbidden fields %s],
# q[%(modal_verb_neg)s mengandung field yang dilarang %s],
#
# q[%(modal_verb_neg)s have fields matching regex pattern %s],
script/rsybak view on Meta::CPAN
#=item other references
#
#Other unblessed references are generally not allowed and will cause an
#exception to be thrown, except for references to the integers C<0> and
#C<1>, which get turned into C<false> and C<true> atoms in JSON. You can
#also use C<JSON::false> and C<JSON::true> to improve readability.
#
# encode_json [\0,JSON::true] # yields [false,true]
#
#=item JSON::true, JSON::false, JSON::null
#
#These special values become JSON true and JSON false values,
#respectively. You can also use C<\1> and C<\0> directly if you want.
#
#=item blessed objects
#
#Blessed objects are not directly representable in JSON, but C<JSON::XS>
#allows various ways of handling objects. See L<OBJECT SERIALISATION>,
#below, for details.
#
#=item simple scalars
#
#Simple Perl scalars (any scalar that is not a reference) are the most
#difficult objects to encode: this module will encode undefined scalars as
#JSON C<null> values, scalars that have last been used in a string context
#before encoding as JSON strings, and anything else as number value:
#
# # dump as number
# encode_json [2] # yields [2]
# encode_json [-3.0e17] # yields [-3e+17]
# my $value = 5; encode_json [$value] # yields [5]
#
# # used as string, so dump as string
# print $value;
# encode_json [$value] # yields ["5"]
#
# # undef becomes null
# encode_json [undef] # yields [null]
#
#You can force the type to be a string by stringifying it:
#
# my $x = 3.1; # some variable containing a number
# "$x"; # stringified
# $x .= ""; # another, more awkward way to stringify
# print $x; # perl does it for you, too, quite often
#
#You can force the type to be a number by numifying it:
#
# my $x = "3"; # some variable containing a string
# $x += 0; # numify it, ensuring it will be dumped as a number
# $x *= 1; # same thing, the choice is yours.
#
#You can not currently force the type in other, less obscure, ways. Tell me
#if you need this capability (but don't forget to explain why it's needed
#:).
#
#Note that numerical precision has the same meaning as under Perl (so
#binary to decimal conversion follows the same rules as in Perl, which
#can differ to other languages). Also, your perl interpreter might expose
#extensions to the floating point numbers of your platform, such as
#infinities or NaN's - these cannot be represented in JSON, and it is an
#error to pass those in.
#
#=back
#
#=head2 OBJECT SERIALISATION
#
#As for Perl objects, this module only supports a pure JSON representation
#(without the ability to deserialise the object automatically again).
#
#=head3 SERIALISATION
#
#What happens when this module encounters a Perl object depends on the
#C<allow_blessed> and C<convert_blessed> settings, which are used in
#this order:
#
#=over 4
#
#=item 1. C<convert_blessed> is enabled and the object has a C<TO_JSON> method.
#
#In this case, the C<TO_JSON> method of the object is invoked in scalar
#context. It must return a single scalar that can be directly encoded into
#JSON. This scalar replaces the object in the JSON text.
#
#For example, the following C<TO_JSON> method will convert all L<URI>
#objects to JSON strings when serialised. The fact that these values
#originally were L<URI> objects is lost.
#
# sub URI::TO_JSON {
# my ($uri) = @_;
# $uri->as_string
# }
#
#=item 2. C<allow_blessed> is enabled.
#
#The object will be serialised as a JSON null value.
#
#=item 3. none of the above
#
#If none of the settings are enabled or the respective methods are missing,
#this module throws an exception.
#
#=back
#
#=head1 ENCODING/CODESET FLAG NOTES
#
#This section is taken from JSON::XS.
#
#The interested reader might have seen a number of flags that signify
#encodings or codesets - C<utf8>, C<latin1> and C<ascii>. There seems to be
#some confusion on what these do, so here is a short comparison:
#
#C<utf8> controls whether the JSON text created by C<encode> (and expected
#by C<decode>) is UTF-8 encoded or not, while C<latin1> and C<ascii> only
#control whether C<encode> escapes character values outside their respective
#codeset range. Neither of these flags conflict with each other, although
#some combinations make less sense than others.
#
#Care has been taken to make all flags symmetrical with respect to
#C<encode> and C<decode>, that is, texts encoded with any combination of
#these flag values will be correctly decoded when the same flags are used
( run in 0.600 second using v1.01-cache-2.11-cpan-39bf76dae61 )