Skip to content

Commit

Permalink
updated to put in Dist::Zilla scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
ioncache committed Jun 22, 2012
1 parent 513b8d8 commit bda8b3b
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 122 deletions.
4 changes: 4 additions & 0 deletions MANIFEST.SKIP
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.komodotools
utils
DBIx-Class-AuditLog.komodoproject
MANIFEST.SKIP
2 changes: 1 addition & 1 deletion README.pod
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ The Audit Log schema ca be accessed from your main schema by calling the audit_l

=head1 TODO

=over4
=over 4

=item add convenience method(s) for retrieving changes from the Audit Log schema

Expand Down
34 changes: 34 additions & 0 deletions dist.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name = DBIx-Class-AuditLog
author = Mark Jubenville <ioncache@gmail.com>
license = Perl_5
copyright_holder = Mark Jubenville
copyright_year = 2012
version = 0.1.0
main_module = lib/DBIx/Class/AuditLog.pm

[AutoPrereqs]
[ConfirmRelease]
[CopyReadmeFromBuild]
[ExecDir]
[ExtraTests]
[GatherDir]
[GithubMeta]
[InstallGuide]
[License]
[MakeMaker]
[Manifest]
[ManifestSkip]
[MetaResources]
bugtracker.web = https://github.com/ioncache/DBIx-Class-AuditLog/issues
[MetaJSON]
[ModuleBuild]
[PkgVersion]
[PodWeaver]
[PodSyntaxTests]
[PruneCruft]
[ReadmeFromPod]
filename = README.pod
[ShareDir]
[Test::Perl::Critic]
[TestRelease]
[UploadToCPAN]
4 changes: 4 additions & 0 deletions lib/DBIx/Class/AuditLog.pm
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ sub delete {
Returns the AuditLog schema from storage.
my $al_schema = $schmea->audit_log_schema;
=cut

sub _audit_log_schema {
Expand Down Expand Up @@ -180,4 +182,6 @@ sub _do_audit {
return defined $info->{audit_log_column} && $info->{audit_log_column} == 0 ? 0 : 1;
}

# ABSTRACT: Simple activity audit logging for DBIx::Class

1;
245 changes: 124 additions & 121 deletions utils/test_schema.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,126 +10,129 @@
use DBIx::Class::AuditLog;

my $schema = AuditTest::Schema->connect( "DBI:mysql:database=audit_test",
"root", "Pa55..", { RaiseError => 1, PrintError => 0 } );

$schema->audit_log_schema->deploy;

#$schema->txn_do(
# sub {
# $schema->resultset('User')->create(
# { name => "JohnSample",
# email => 'jsample@sample.com',
# phone => '999-888-7777',
# }
# );
# },
# { description => "adding new user: JohnSample",
# user => "TestAdminUser",
# },
#);

#$schema->txn_do(
# sub {
# my $user
# = $schema->resultset('User')->search( { name => "JohnSample" } )
# ->first;
# $user->email('johnsample@sample.com');
# $user->update();
# },
# { description => "updating username: JaneSample",
# user => "TestAdminUser",
# },
#);
#
#$schema->txn_do(
# sub {
# $schema->resultset('User')->search( { name => "JohnSample" } )
# ->first->delete;
# },
# { description => "delete user: JohnSample",
# user => "YetAnotherAdminUser",
# },
#);
#
#$schema->txn_do(
# sub {
# $schema->resultset('User')->create(
# { name => "TehPnwerer",
# email => 'jeremy@purepwnage.com',
# phone => '999-888-7777',
# }
# );
# },
# { description => "adding new user: TehPwnerer -- no admin user", },
#);
#
#$schema->txn_do(
# sub {
# my $superman = $schema->resultset('User')->create(
# { name => "Superman",
# email => 'ckent@dailyplanet.com',
# phone => '123-456-7890',
# }
# );
# $superman->update(
# { name => "Superman",
# email => 'ckent@dailyplanet.com',
# phone => '123-456-7890',
# }
# );
# my $spiderman = $schema->resultset('User')->create(
# { name => "Spiderman",
# email => 'ppaker@dailybugle.com',
# phone => '987-654-3210',
# }
# );
# $schema->resultset('User')->search( { name => "Spiderman" } )
# ->first->update(
# { name => "Spiderman",
# email => 'pparker@dailybugle.com',
# phone => '987-654-3210',
# }
# );
# $schema->resultset('User')->search( { name => "TehPnwerer" } )
# ->first->update(
# { name => 'TehPwnerer', phone => '416-123-4567' } );
# },
# { description => "multi-action changeset",
# user => "ioncache",
# },
#);
#
#$schema->resultset('User')->create(
# { name => "NonChangesetUser",
# email => 'ncu@oanda.com',
# phone => '987-654-3210',
# }
#);
#
#$schema->txn_do(
# sub {
# $schema->resultset('User')->create(
# { name => "Drunk Hulk",
# email => 'drunkhulk@twitter.com',
# phone => '123-456-7890',
# }
# );
# $schema->resultset('User')->search( { name => "Drunk hulk" } )
# ->first->update( { email => 'drunkhulk@everywhere.com' } );
# },
# { user => "markj", },
#);
#
#$schema->resultset('User')->search( { name => "NonChangesetUser" } )
# ->first->update( { phone => '543-210-9876' } );
#
#my $atbdu = $schema->resultset('User')->create(
# { name => "AboutToBeDeletedUser",
# email => 'atbdu@oanda.com',
# phone => '987-654-3210',
# }
#);
#
#$atbdu->delete;
"root", "angU1da", { RaiseError => 1, PrintError => 1 } );

#my $user = $schema->resultset('User')->first();
#p $user;

#$schema->audit_log_schema->deploy;

$schema->txn_do(
sub {
$schema->resultset('User')->create(
{ name => "JohnSample",
email => 'jsample@sample.com',
phone => '999-888-7777',
}
);
},
{ description => "adding new user: JohnSample",
user => "TestAdminUser",
},
);

$schema->txn_do(
sub {
my $user
= $schema->resultset('User')->search( { name => "JohnSample" } )
->first;
$user->email('johnsample@sample.com');
$user->update();
},
{ description => "updating username: JaneSample",
user => "TestAdminUser",
},
);

$schema->txn_do(
sub {
$schema->resultset('User')->search( { name => "JohnSample" } )
->first->delete;
},
{ description => "delete user: JohnSample",
user => "YetAnotherAdminUser",
},
);

$schema->txn_do(
sub {
$schema->resultset('User')->create(
{ name => "TehPnwerer",
email => 'jeremy@purepwnage.com',
phone => '999-888-7777',
}
);
},
{ description => "adding new user: TehPwnerer -- no admin user", },
);

$schema->txn_do(
sub {
my $superman = $schema->resultset('User')->create(
{ name => "Superman",
email => 'ckent@dailyplanet.com',
phone => '123-456-7890',
}
);
$superman->update(
{ name => "Superman",
email => 'ckent@dailyplanet.com',
phone => '123-456-7890',
}
);
my $spiderman = $schema->resultset('User')->create(
{ name => "Spiderman",
email => 'ppaker@dailybugle.com',
phone => '987-654-3210',
}
);
$schema->resultset('User')->search( { name => "Spiderman" } )
->first->update(
{ name => "Spiderman",
email => 'pparker@dailybugle.com',
phone => '987-654-3210',
}
);
$schema->resultset('User')->search( { name => "TehPnwerer" } )
->first->update(
{ name => 'TehPwnerer', phone => '416-123-4567' } );
},
{ description => "multi-action changeset",
user => "ioncache",
},
);

$schema->resultset('User')->create(
{ name => "NonChangesetUser",
email => 'ncu@oanda.com',
phone => '987-654-3210',
}
);

$schema->txn_do(
sub {
$schema->resultset('User')->create(
{ name => "Drunk Hulk",
email => 'drunkhulk@twitter.com',
phone => '123-456-7890',
}
);
$schema->resultset('User')->search( { name => "Drunk hulk" } )
->first->update( { email => 'drunkhulk@everywhere.com' } );
},
{ user => "markj", },
);

$schema->resultset('User')->search( { name => "NonChangesetUser" } )
->first->update( { phone => '543-210-9876' } );

my $atbdu = $schema->resultset('User')->create(
{ name => "AboutToBeDeletedUser",
email => 'atbdu@oanda.com',
phone => '987-654-3210',
}
);

$atbdu->delete;

1;

0 comments on commit bda8b3b

Please sign in to comment.