| 1 | package FAIR::CoreFunctions; | ||
| 2 | $FAIR::CoreFunctions::VERSION = '1.0'; | ||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 | |||
| 7 | use strict; | ||
| 8 | use Moose::Role; | ||
| 9 | |||
| 10 | sub statement { | ||
| 11 | my ($s, $p, $o) = @_; | ||
| 12 | unless (ref($s) =~ /Trine/){ | ||
| 13 | $s =~ s/[\<\>]//g; | ||
| 14 | $s = RDF::Trine::Node::Resource->new($s); | ||
| 15 | } | ||
| 16 | unless (ref($p) =~ /Trine/){ | ||
| 17 | $p =~ s/[\<\>]//g; | ||
| 18 | $p = RDF::Trine::Node::Resource->new($p); | ||
| 19 | } | ||
| 20 | unless (ref($o) =~ /Trine/){ | ||
| 21 | |||
| 22 | if ($o =~ /^http\:\/\// || $o =~ /^https\:\/\//){ | ||
| 23 | $o = RDF::Trine::Node::Resource->new($o); | ||
| 24 | } elsif ($o =~ /^<http\:\/\//){ | ||
| 25 | $o =~ s/[\<\>]//g; | ||
| 26 | $o = RDF::Trine::Node::Resource->new($o); | ||
| 27 | } elsif ($o =~ /"(.*?)"\^\^\<http\:/) { | ||
| 28 | $o = RDF::Trine::Node::Literal->new($1); | ||
| 29 | } else { | ||
| 30 | $o = RDF::Trine::Node::Literal->new($o); | ||
| 31 | } | ||
| 32 | } | ||
| 33 | my $statement = RDF::Trine::Statement->new($s, $p, $o); | ||
| 34 | return $statement; | ||
| 35 | } | ||
| 36 | |||
| 37 | 1; | ||
| 38 | |||
| 39 | __END__ | ||
| 40 | |||
| 41 | =pod | ||
| 42 | |||
| 43 | =encoding UTF-8 | ||
| 44 | |||
| 45 | =head1 NAME | ||
| 46 | |||
| 47 | FAIR::CoreFunctions | ||
| 48 | |||
| 49 | =head1 VERSION | ||
| 50 | |||
| 51 | version 1.0 | ||
| 52 | |||
| 53 | =head1 Name FAIR::CoreFunctions | ||
| 54 | |||
| 55 | =head1 Description | ||
| 56 | |||
| 57 | a Moose Role that contains things that various modules need to do | ||
| 58 | |||
| 59 | =head1 AUTHOR | ||
| 60 | |||
| 61 | Mark Denis Wilkinson (markw [at] illuminae [dot] com) | ||
| 62 | |||
| 63 | =head1 COPYRIGHT AND LICENSE | ||
| 64 | |||
| 65 | This software is Copyright (c) 2016 by Mark Denis Wilkinson. | ||
| 66 | |||
| 67 | This is free software, licensed under: | ||
| 68 | |||
| 69 | The Apache License, Version 2.0, January 2004 | ||
| 70 | |||
| 71 | =cut |