Skip to content

Commit

Permalink
Switch UUID dependency from Data::UUID to UUID::Tiny (#145).
Browse files Browse the repository at this point in the history
  • Loading branch information
kasei committed Nov 30, 2020
1 parent a16a900 commit 443ec0e
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions lib/Attean.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions lib/Attean/Blank.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This role consumes L<Attean::API::Blank>, 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);
Expand All @@ -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);
Expand Down
10 changes: 4 additions & 6 deletions lib/Attean/Plan.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions lib/Attean/SimpleQueryEvaluator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 };
Expand Down
6 changes: 3 additions & 3 deletions lib/Attean/TermMap.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -99,8 +99,8 @@ Returns a new L<Attean::TermMap> 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;
});
Expand Down
1 change: 0 additions & 1 deletion lib/Attean/TreeRewriter.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 3 additions & 3 deletions lib/Attean/Variable.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ It conforms to the L<Attean::API::TermOrVariable|Attean::API> 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);
Expand All @@ -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);
}
Expand Down
16 changes: 16 additions & 0 deletions meta/changes.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
Expand Down
2 changes: 1 addition & 1 deletion t/term-map.t
Original file line number Diff line number Diff line change
Expand Up @@ -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<Term>');
my $iter = Attean::ListIterator->new(values => [blank('a'), blank('zzz')], item_type => 'Attean::API::Term');
Expand Down

0 comments on commit 443ec0e

Please sign in to comment.