Permalink
Browse files

Start building infrastructure to actually apply the parse

  • Loading branch information...
1 parent 278982a commit 1ede1fa45935e29f66f8231ad5247522e06a1884 @bobtfish committed Oct 29, 2011
@@ -0,0 +1,27 @@
+package Pegex::Puppet::ResourceRegistery;
+use Moose;
+use Moose::Util::TypeConstraints;
+use MooseX::Types::Moose qw/ HashRef /;
+use namespace::autoclean;
+
+role_type 'Pegex::Puppet::ResourceType';
+use Pegex::Puppet::ResourceType::File;
+
+has resource_types => (
+ isa => HashRef['Pegex::Puppet::ResourceType'],
+ traits => ['Hash'],
+ handles => {
+ has_resourcetype_named => 'exists',
+ get_resourcetype_named => 'get',
+ },
+ builder => '_build_resources_by_name',
+);
+
+sub _build_resources_by_name {
+ {
+ file => Pegex::Puppet::ResourceType::File->new(),
+ }
+}
+
+1;
+
@@ -0,0 +1,14 @@
+package Pegex::Puppet::ResourceType;
+use Moose::Role;
+use MooseX::Types::Moose qw/ HashRef /;
+
+requires 'name';
+
+has data => (
+ is => 'ro',
+ isa => HashRef,
+ default => sub { { } },
+);
+
+1;
+
@@ -0,0 +1,10 @@
+package Pegex::Puppet::ResourceType::File;
+use Moose;
+
+with 'Pegex::Puppet::ResourceType';
+
+sub name { 'file' }
+
+__PACKAGE__->meta->make_immutable;
+1;
+
View
@@ -0,0 +1,12 @@
+use strict;
+use warnings;
+use Test::More;
+
+use Pegex::Puppet::ResourceRegistery;
+my $rr = Pegex::Puppet::ResourceRegistery->new;
+ok $rr;
+ok $rr->has_resourcetype_named('file');
+isa_ok $rr->get_resourcetype_named('file'), 'Pegex::Puppet::ResourceType::File';
+
+done_testing;
+

0 comments on commit 1ede1fa

Please sign in to comment.