p5-moosex-semantic / t / rdf_metabuilder.t

use Test::More;
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::MetaBuilder::Class;
use MooseX::Semantic::MetaBuilder::Attribute;


my $MOOSE = 'http://moose.perl.org/onto#';
my $moose = RDF::Trine::Namespace->new($MOOSE);
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 $classes;

warn ser_dump( $test_model );

{ 
    package EmptyMoosePackage;
    use Moose;
    1;
}

my $classes_iter = $test_model->subjects( $rdf->type, $moose->Class );
while (my $res = $classes_iter->next) {
    my $metaclass = MooseX::Semantic::MetaBuilder::Class->new_from_model( $test_model, $res );
    # warn Dumper $metaclass;
    $metaclass->add_attributes_to_class( 'EmptyMoosePackage' );
}
# 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.