From 443ec0ef239fbe7613270d233ee7ac431a4456c5 Mon Sep 17 00:00:00 2001 From: Gregory Todd Williams Date: Sun, 29 Nov 2020 20:57:38 -0800 Subject: [PATCH] Switch UUID dependency from Data::UUID to UUID::Tiny (#145). --- Makefile.PL | 2 +- lib/Attean.pm | 4 ++-- lib/Attean/Blank.pm | 6 +++--- lib/Attean/Plan.pm | 10 ++++------ lib/Attean/SimpleQueryEvaluator.pm | 7 +++---- lib/Attean/TermMap.pm | 6 +++--- lib/Attean/TreeRewriter.pm | 1 - lib/Attean/Variable.pm | 6 +++--- meta/changes.ttl | 16 ++++++++++++++++ t/term-map.t | 2 +- 10 files changed, 36 insertions(+), 24 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 01cfb4a5..a0783286 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -20,7 +20,7 @@ test_requires 'XML::Simple' => 0; perl_version '5.014'; requires 'Algorithm::Combinatorics' => 0; -requires 'Data::UUID' => 0; +requires 'UUID::Tiny' => 0; requires 'DateTime::Format::W3CDTF' => 0; requires 'Exporter::Tiny' => 1.000000; requires 'File::Slurp' => 0; diff --git a/lib/Attean.pm b/lib/Attean.pm index 2c9194b9..31da4bab 100644 --- a/lib/Attean.pm +++ b/lib/Attean.pm @@ -4,7 +4,7 @@ Attean - A Semantic Web Framework =head1 VERSION -This document describes Attean version 0.027 +This document describes Attean version 0.027_01 =head1 SYNOPSIS @@ -51,7 +51,7 @@ Semantic Web (RDF and SPARQL) data. package Attean { use v5.14; use warnings; - our $VERSION = '0.027'; + our $VERSION = '0.027_01'; use Attean::API; use Attean::Blank; diff --git a/lib/Attean/Blank.pm b/lib/Attean/Blank.pm index 95f95b9b..74b721f0 100644 --- a/lib/Attean/Blank.pm +++ b/lib/Attean/Blank.pm @@ -36,7 +36,7 @@ This role consumes L, which provides the following methods: package Attean::Blank 0.027 { use Moo; use Types::Standard qw(Str); - use Data::UUID; + use UUID::Tiny ':std'; use namespace::clean; has 'value' => (is => 'ro', isa => Str, required => 1); @@ -49,8 +49,8 @@ package Attean::Blank 0.027 { my $class = shift; if (scalar(@_) == 0) { - my $uuid = Data::UUID->new->create_hex; - return $class->$orig(value => $uuid); + my $uuid = unpack('H*', create_uuid()); + return $class->$orig(value => 'b' . $uuid); } elsif (scalar(@_) == 1) { my $value = shift // ''; return $class->$orig(value => $value); diff --git a/lib/Attean/Plan.pm b/lib/Attean/Plan.pm index 334de353..6d1a7cbe 100644 --- a/lib/Attean/Plan.pm +++ b/lib/Attean/Plan.pm @@ -706,7 +706,7 @@ expressions, binding the produced values to new variables. package Attean::Plan::Extend 0.027 { use Moo; use Encode; - use Data::UUID; + use UUID::Tiny ':std'; use URI::Escape; use Data::Dumper; use I18N::LangTags; @@ -1230,12 +1230,10 @@ package Attean::Plan::Extend 0.027 { my $seconds = int($offset); return Attean::Literal->new(value => sprintf('%s%02d:%02d', $minus, $hours, $minutes)); } elsif ($func eq 'UUID') { - my $u = Data::UUID->new(); - my $uuid = 'urn:uuid:' . $u->to_string( $u->create() ); + my $uuid = 'urn:uuid:' . uc(uuid_to_string(create_uuid())); return Attean::IRI->new(value => $uuid); } elsif ($func eq 'STRUUID') { - my $u = Data::UUID->new(); - return Attean::Literal->new(value => $u->to_string( $u->create() )); + return Attean::Literal->new(value => uc(uuid_to_string(create_uuid()))); } elsif ($func eq 'BNODE') { if (scalar(@{ $expr->children })) { my $string = $self->evaluate_expression($model, $expr->children->[0], $r); @@ -2029,7 +2027,7 @@ package Attean::Plan::Exists 0.027 { package Attean::Plan::Aggregate 0.027 { use Moo; use Encode; - use Data::UUID; + use UUID::Tiny ':std'; use URI::Escape; use I18N::LangTags; use POSIX qw(ceil floor); diff --git a/lib/Attean/SimpleQueryEvaluator.pm b/lib/Attean/SimpleQueryEvaluator.pm index bda11551..038a7b13 100644 --- a/lib/Attean/SimpleQueryEvaluator.pm +++ b/lib/Attean/SimpleQueryEvaluator.pm @@ -538,7 +538,7 @@ package Attean::SimpleQueryEvaluator::ExpressionEvaluator 0.027 { use Encode qw(encode); use POSIX qw(ceil floor); use Digest; - use Data::UUID; + use UUID::Tiny ':std'; use List::MoreUtils qw(zip); use DateTime::Format::W3CDTF; use I18N::LangTags; @@ -875,9 +875,8 @@ package Attean::SimpleQueryEvaluator::ExpressionEvaluator 0.027 { my $value = DateTime::Format::W3CDTF->new->format_datetime( DateTime->now ); return Attean::Literal->new( value => $value, datatype => 'http://www.w3.org/2001/XMLSchema#dateTime' ); } elsif ($func =~ /^(?:STR)?UUID$/) { - my $u = Data::UUID->new(); - return Attean::Literal->new($u->to_string( $u->create() )) if ($func eq 'STRUUID'); - return Attean::IRI->new('urn:uuid:' . $u->to_string( $u->create() )); + return Attean::Literal->new(uc(uuid_to_string(create_uuid()))) if ($func eq 'STRUUID'); + return Attean::IRI->new('urn:uuid:' . uc(uuid_to_string(create_uuid()))); } elsif ($func =~ /^(MD5|SHA1|SHA256|SHA384|SHA512)$/) { my $hash = $func =~ s/SHA/SHA-/r; my $digest = eval { Digest->new($hash)->add(encode('UTF-8', $operands[0]->value, Encode::FB_CROAK))->hexdigest }; diff --git a/lib/Attean/TermMap.pm b/lib/Attean/TermMap.pm index fd6c81bc..0022fe53 100644 --- a/lib/Attean/TermMap.pm +++ b/lib/Attean/TermMap.pm @@ -46,7 +46,7 @@ package Attean::TermMap 0.027 { use Moo; use Types::Standard qw(CodeRef); use Attean::API::Binding; - use Data::UUID; + use UUID::Tiny ':std'; use namespace::clean; with 'Attean::Mapper'; @@ -99,8 +99,8 @@ Returns a new L that renames blank nodes with UUID values. my $id = $term->value; return $map{$id} if (defined($map{$id})); - my $uuid = Data::UUID->new->create_hex; - my $new = Attean::Blank->new( $uuid ); + my $uuid = unpack('H*', create_uuid()); + my $new = Attean::Blank->new( 'b' . $uuid ); $map{$id} = $new; return $new; }); diff --git a/lib/Attean/TreeRewriter.pm b/lib/Attean/TreeRewriter.pm index bd0d23e1..1dab37e9 100644 --- a/lib/Attean/TreeRewriter.pm +++ b/lib/Attean/TreeRewriter.pm @@ -37,7 +37,6 @@ None. package Attean::TreeRewriter 0.027 { use Moo; use Types::Standard qw(CodeRef ArrayRef Str); - use Data::UUID; use Scalar::Util qw(blessed refaddr); use namespace::clean; with 'MooX::Log::Any'; diff --git a/lib/Attean/Variable.pm b/lib/Attean/Variable.pm index be73a664..75c5c787 100644 --- a/lib/Attean/Variable.pm +++ b/lib/Attean/Variable.pm @@ -36,7 +36,7 @@ It conforms to the L role. package Attean::Variable 0.027 { use Moo; use Types::Standard qw(Str); - use Data::UUID; + use UUID::Tiny ':std'; use namespace::clean; has 'value' => (is => 'ro', isa => Str, required => 1); @@ -49,8 +49,8 @@ package Attean::Variable 0.027 { my $orig = shift; my $class = shift; if (scalar(@_) == 0) { - my $uuid = Data::UUID->new->create_hex; - return $class->$orig(value => $uuid); + my $uuid = unpack('H*', create_uuid()); + return $class->$orig(value => 'v' . $uuid); } elsif (scalar(@_) == 1) { return $class->$orig(value => shift); } diff --git a/meta/changes.ttl b/meta/changes.ttl index 49787a71..ca26fa74 100644 --- a/meta/changes.ttl +++ b/meta/changes.ttl @@ -36,6 +36,22 @@ my:project my:v_0-026 , my:v_0-027 ; . +my:v_0-028 + a :Version ; + dc:issued "2020-11-XX"^^xsd:date ; + :revision "0.028" ; + dcterms:replaces my:v_0-027 ; + dcs:changeset [ + dcs:item + [ a dcs:Addition ; rdfs:label "Add uniq method on iterators over objects with an as_string method." ], + [ a dcs:Update ; rdfs:label "Improve documentation about statement projection accessors (e.g. subjects) not being unique (#152)." ], + [ a dcs:Update ; rdfs:label "Fix utf8 handling of syntax tests in dawg test harness." ], + [ a dcs:Update ; rdfs:label "Fix Attean::QuadModel->get_quads when called with an empty term set in some position." ], + [ a dcs:Update ; rdfs:label "Remove AtteanX::Store::DBI which was not a real DBI store and was accidentally checked-in (#134)." ] + ] + . + + my:v_0-027 a :Version ; dc:issued "2020-11-06"^^xsd:date ; diff --git a/t/term-map.t b/t/term-map.t index 6c44e827..3ae8e645 100644 --- a/t/term-map.t +++ b/t/term-map.t @@ -44,7 +44,7 @@ subtest 'short blank node label mapping' => sub { subtest 'UUID blank node label mapping' => sub { my $mapper = Attean::TermMap->uuid_blank_map; my $bindings_mapper = $mapper->binding_mapper; - my $uuid_blank = qr/^_:0x[0-9A-Za-z]{32}$/; + my $uuid_blank = qr/^_:b[0-9A-Za-z]{32}$/; { note('Mapping Iterator'); my $iter = Attean::ListIterator->new(values => [blank('a'), blank('zzz')], item_type => 'Attean::API::Term');