--- /dev/null
+package System::Introspector::Puppet;
+use Moo;
+
+has classes_file => (
+ is => 'ro',
+ default => sub { '/var/lib/puppet/state/classes.txt' },
+);
+
+has resources_file => (
+ is => 'ro',
+ default => sub { '/var/lib/puppet/state/resources.txt' },
+);
+
+sub gather {
+ my ($self) = @_;
+ return {
+ classes => $self->_gather_classes,
+ resources => $self->_gather_resources,
+ };
+}
+
+sub _gather_resources {
+ my ($self) = @_;
+ my $file = $self->resources_file;
+ open my $fh, '<', $file
+ or return { error => "Unable to read $file: $!" };
+ my @lines = <$fh>;
+ chomp @lines;
+ return [ map {
+ m{^(\w+)\[(.*)\]$}
+ ? [$1, $2]
+ : [error => $_];
+ } @lines ];
+}
+
+sub _gather_classes {
+ my ($self) = @_;
+ my $file = $self->classes_file;
+ open my $fh, '<', $file
+ or return { error => "Unable to read $file: $!" };
+ my @lines = <$fh>;
+ chomp @lines;
+ return \@lines;
+}
+
+1;