Source

p5-moosex-semantic / t / util / schema_import / from_moose_ttl.t

use Test::More 
    # tests=>4,
    skip_all => 'This was just a Proof of Concept, dont care for it now';
use Test::Moose;
use RDF::Trine::Namespace qw(rdf);
use RDF::Trine qw(iri);
use Data::Dumper;
use MooseX::Semantic::Test::Person;
use MooseX::Semantic::Test qw(ser ser_dump diff_models);

use MooseX::Semantic::Util::SchemaImport::Class;
use MooseX::Semantic::Util::SchemaImport::Attribute;

my $base_uri = 'http://myapp/';
my $test_model = RDF::Trine::Model->temporary_model;
RDF::Trine::Parser::Turtle->parse_file_into_model(
    $base_uri,
    't/data/person_moose_definition.ttl',
    $test_model,
);

my $MOOSE = 'http://moose.perl.org/onto#';
my $moose = RDF::Trine::Namespace->new($MOOSE);
my $myapp = RDF::Trine::Namespace->new($base_uri);
# my $classes;

# warn ser_dump( $test_model );

{ 
    package EmptyMoosePackage;
    use Moose;
    1;
}

ok(
my $foaf_metaclass_builder = MooseX::Semantic::Util::SchemaImport::Class->new_from_model(
    $test_model, 
    $myapp->FoafMixin
), 'loaded FoafMixin Metaclass Builder from model');
is(scalar @{$foaf_metaclass_builder->has_attribute}, 2, 'FoafMixin Metaclass Builder has 2 attributes');

is( scalar EmptyMoosePackage->meta->get_attribute_list, 0, 'EmptyMoosePackage has 0 attributes');
# my $classes_iter = $test_model->subjects( $rdf->type, $moose->Class );
# while (my $res = $classes_iter->next) {
 # }
$foaf_metaclass_builder->add_attributes_to_class( 'EmptyMoosePackage' );
is( scalar EmptyMoosePackage->meta->get_attribute_list, 2, 'EmptyMoosePackage has 2 attributes');
# warn Dumper(
    # EmptyMoosePackage->meta->get_attribute('knows')
# );
# warn Dumper __PACKAGE__->meta;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.