[Bast-commits] r7043 - in DBIx-Class-QueryLog/1.0/trunk: . lib/DBIx/Class lib/DBIx/Class/QueryLog

gphat at dev.catalyst.perl.org gphat at dev.catalyst.perl.org
Tue Jul 14 04:52:55 GMT 2009


Author: gphat
Date: 2009-07-14 04:52:54 +0000 (Tue, 14 Jul 2009)
New Revision: 7043

Modified:
   DBIx-Class-QueryLog/1.0/trunk/Changes
   DBIx-Class-QueryLog/1.0/trunk/Makefile.PL
   DBIx-Class-QueryLog/1.0/trunk/README
   DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog.pm
   DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog/Analyzer.pm
   DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog/Query.pm
   DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog/Transaction.pm
Log:
Mooseify QueryLog


Modified: DBIx-Class-QueryLog/1.0/trunk/Changes
===================================================================
--- DBIx-Class-QueryLog/1.0/trunk/Changes	2009-07-13 22:56:31 UTC (rev 7042)
+++ DBIx-Class-QueryLog/1.0/trunk/Changes	2009-07-14 04:52:54 UTC (rev 7043)
@@ -1,5 +1,8 @@
 Revision history for DBIx-Class-QueryLog
 
+1.2.0
+    - Mooseification
+
 1.1.5
     - Correct behavior of reset (thanks to Dmitry Bigunyak)
 

Modified: DBIx-Class-QueryLog/1.0/trunk/Makefile.PL
===================================================================
--- DBIx-Class-QueryLog/1.0/trunk/Makefile.PL	2009-07-13 22:56:31 UTC (rev 7042)
+++ DBIx-Class-QueryLog/1.0/trunk/Makefile.PL	2009-07-14 04:52:54 UTC (rev 7043)
@@ -3,10 +3,12 @@
 name    'DBIx-Class-QueryLog';
 all_from    'lib/DBIx/Class/QueryLog.pm';
 
-requires    'Test::More'       => 0;
-requires    'Class::Accessor'  => 0;
-requires    'Time::HiRes'      => 0;
-requires    'DBIx::Class'      => 0;
+requires    'Test::More'        => 0;
+requires    'Class::Accessor'   => 0;
+requires    'Moose'             => 0;
+requires    'MooseX::AttributeHelpers' => 0;
+requires    'Time::HiRes'       => 0;
+requires    'DBIx::Class'       => 0;
 
 auto_install;
 

Modified: DBIx-Class-QueryLog/1.0/trunk/README
===================================================================
--- DBIx-Class-QueryLog/1.0/trunk/README	2009-07-13 22:56:31 UTC (rev 7042)
+++ DBIx-Class-QueryLog/1.0/trunk/README	2009-07-14 04:52:54 UTC (rev 7043)
@@ -43,7 +43,7 @@
 
 COPYRIGHT AND LICENCE
 
-Copyright (C) 2007 Cory 'G' Watson
+Copyright (C) 2009 Cory G Watson
 
 This program is free software; you can redistribute it and/or modify it
 under the same terms as Perl itself.

Modified: DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog/Analyzer.pm
===================================================================
--- DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog/Analyzer.pm	2009-07-13 22:56:31 UTC (rev 7042)
+++ DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog/Analyzer.pm	2009-07-14 04:52:54 UTC (rev 7043)
@@ -1,11 +1,11 @@
 package DBIx::Class::QueryLog::Analyzer;
+use Moose;
 
-use warnings;
-use strict;
+has querylog => (
+    is => 'rw',
+    isa => 'DBIx::Class::QueryLog'
+);
 
-use base qw(Class::Accessor);
-__PACKAGE__->mk_accessors(qw(querylog));
-
 =head1 NAME
 
 DBIx::Class::QueryLog::Analyzer - Query Analysis
@@ -32,15 +32,6 @@
 
 Create a new DBIx::Class::QueryLog::Analyzer
 
-=cut
-
-sub new {
-    my $proto = shift;
-    my $self = $proto->SUPER::new(@_);
-
-    return $self;
-}
-
 =head2 get_sorted_queries
 
 Returns a list of all Query objects, sorted by elapsed time (descending).
@@ -186,10 +177,13 @@
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2007 Cory G Watson, all rights reserved.
+Copyright 2009 Cory G Watson, all rights reserved.
 
 This program is free software; you can redistribute it and/or modify it
 under the same terms as Perl itself.
 
 =cut
+
+__PACKAGE__->meta->make_immutable;
+
 1;

Modified: DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog/Query.pm
===================================================================
--- DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog/Query.pm	2009-07-13 22:56:31 UTC (rev 7042)
+++ DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog/Query.pm	2009-07-14 04:52:54 UTC (rev 7043)
@@ -1,11 +1,31 @@
 package DBIx::Class::QueryLog::Query;
+use Moose;
 
-use warnings;
-use strict;
+has bucket => (
+    is => 'rw',
+    isa => 'Str'
+);
 
-use base qw(Class::Accessor);
-__PACKAGE__->mk_accessors(qw(bucket start_time end_time sql params));
+has end_time => (
+    is => 'rw',
+    isa => 'Num'
+);
 
+has params => (
+    is => 'rw',
+    isa => 'ArrayRef'
+);
+
+has sql => (
+    is => 'rw',
+    isa => 'Str'
+);
+
+has start_time => (
+    is => 'rw',
+    isa => 'Num'
+);
+
 =head1 NAME
 
 DBIx::Class::QueryLog::Query - A Query
@@ -97,11 +117,13 @@
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2007 Cory G Watson, all rights reserved.
+Copyright 2009 Cory G Watson, all rights reserved.
 
 This program is free software; you can redistribute it and/or modify it
 under the same terms as Perl itself.
 
 =cut
 
+__PACKAGE__->meta->make_immutable;
+
 1;
\ No newline at end of file

Modified: DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog/Transaction.pm
===================================================================
--- DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog/Transaction.pm	2009-07-13 22:56:31 UTC (rev 7042)
+++ DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog/Transaction.pm	2009-07-14 04:52:54 UTC (rev 7043)
@@ -1,11 +1,30 @@
 package DBIx::Class::QueryLog::Transaction;
+use Moose;
+use MooseX::AttributeHelpers;
 
-use warnings;
-use strict;
+extends 'DBIx::Class::QueryLog::Query';
 
-use base qw(Class::Accessor);
-__PACKAGE__->mk_accessors(qw(bucket start_time end_time queries committed rolledback));
+has committed => (
+    is => 'rw',
+    isa => 'Bool'
+);
 
+has queries => (
+    metaclass => 'Collection::Array',
+    is => 'rw',
+    isa => 'ArrayRef',
+    default => sub { [] },
+    provides => {
+        count => 'count',
+        push => 'add_to_queries'
+    }
+);
+
+has rolledback => (
+    is => 'rw',
+    isa => 'Bool'
+);
+
 =head1 NAME
 
 DBIx::Class::QueryLog::Transaction - A Transaction
@@ -22,17 +41,6 @@
 
 Create a new DBIx::Class::QueryLog::Transcation
 
-=cut
-
-sub new {
-    my $proto = shift;
-    my $self = $proto->SUPER::new(@_);
-
-	$self->queries([]);
-
-	return $self;
-}
-
 =head2 bucket
 
 The bucket this tranaction is in.
@@ -77,25 +85,10 @@
 
 Add the provided query to this transactions list.
 
-=cut
-sub add_to_queries {
-	my $self = shift;
-	my $query = shift;
-
-	push(@{ $self->queries }, $query);
-}
-
 =head2 count
 
 Returns the number of queries in this Transaction
 
-=cut
-sub count {
-    my $self = shift;
-
-    return scalar(@{ $self->queries });
-}
-
 =head2 get_sorted_queries([ $sql ])
 
 Returns all the queries in this Transaction, sorted by elapsed time.
@@ -126,10 +119,13 @@
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2007 Cory G Watson, all rights reserved.
+Copyright 2009 Cory G Watson, all rights reserved.
 
 This program is free software; you can redistribute it and/or modify it
 under the same terms as Perl itself.
 
 =cut
+
+__PACKAGE__->meta->make_immutable;
+
 1;
\ No newline at end of file

Modified: DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog.pm
===================================================================
--- DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog.pm	2009-07-13 22:56:31 UTC (rev 7042)
+++ DBIx-Class-QueryLog/1.0/trunk/lib/DBIx/Class/QueryLog.pm	2009-07-14 04:52:54 UTC (rev 7043)
@@ -1,12 +1,47 @@
 package DBIx::Class::QueryLog;
+use Moose;
+use MooseX::AttributeHelpers;
 
-use warnings;
-use strict;
+has bucket => (
+    is => 'rw',
+    isa => 'Str',
+    default => sub { 'default' }
+);
 
+has current_query => (
+    is => 'rw',
+    isa => 'Maybe[DBIx::Class::QueryLog::Query]'
+);
+
+has current_transaction => (
+    is => 'rw',
+    isa => 'Maybe[DBIx::Class::QueryLog::Transaction]'
+);
+
+has log => (
+    metaclass => 'Collection::Array',
+    is => 'rw',
+    isa => 'ArrayRef',
+    default => sub { [] },
+    provides => {
+        push => 'add_to_log',
+        clear => 'reset'
+    }
+);
+
+has passthrough => (
+    is => 'rw',
+    isa => 'Bool',
+    default => sub { 0 }
+);
+
+before 'add_to_log' => sub {
+    my ($self, $thing) = @_;
+
+    $thing->bucket($self->bucket);
+};
+
 use base qw(DBIx::Class::Storage::Statistics);
-__PACKAGE__->mk_group_accessors(simple => qw(
-    bucket current_transaction current_query log  passthrough
-));
 
 use Time::HiRes;
 
@@ -19,7 +54,7 @@
 
 =cut
 
-our $VERSION = '1.1.5';
+our $VERSION = '1.2.0';
 
 =head1 SYNOPSIS
 
@@ -79,17 +114,6 @@
 
 Create a new DBIx::Class::QueryLog.
 
-=cut
-sub new {
-    my $proto = shift;
-    my $self = $proto->SUPER::new(@_);
-
-    $self->log([]);
-    $self->bucket('default');
-
-    return $self;
-}
-
 =head2 bucket
 
 Set the current bucket for this QueryLog.  This bucket will be copied to any
@@ -131,26 +155,10 @@
 
 Reset this QueryLog by removing all transcations and queries.
 
-=cut
-sub reset {
-    my $self = shift;
-
-    $self->log([]);
-}
-
 =head2 add_to_log
 
 Add this provided Transaction or Query to the log.
 
-=cut
-sub add_to_log {
-    my $self = shift;
-    my $thing = shift;
-
-    $thing->bucket($self->bucket);
-    push(@{ $self->log }, $thing);
-}
-
 =head2 txn_begin
 
 Called by DBIx::Class when a transaction is begun.
@@ -262,51 +270,15 @@
 
 Cory G Watson, C<< <gphat at cpan.org> >>
 
-=head1 BUGS
-
-Please report any bugs or feature requests to
-C<bug-dbix-class-querylog at rt.cpan.org>, or through the web interface at
-L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-QueryLog>.
-I will be notified, and then you'll automatically be notified of progress on
-your bug as I make changes.
-
-=head1 SUPPORT
-
-You can find documentation for this module with the perldoc command.
-
-    perldoc DBIx::Class::QueryLog
-
-You can also look for information at:
-
-=over 4
-
-=item * AnnoCPAN: Annotated CPAN documentation
-
-L<http://annocpan.org/dist/DBIx-Class-QueryLog>
-
-=item * CPAN Ratings
-
-L<http://cpanratings.perl.org/d/DBIx-Class-QueryLog>
-
-=item * RT: CPAN's request tracker
-
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class-QueryLog>
-
-=item * Search CPAN
-
-L<http://search.cpan.org/dist/DBIx-Class-QueryLog>
-
-=back
-
-=head1 ACKNOWLEDGEMENTS
-
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2007 Cory G Watson, all rights reserved.
+Copyright 2009 Cory G Watson, all rights reserved.
 
 This program is free software; you can redistribute it and/or modify it
 under the same terms as Perl itself.
 
 =cut
 
-1; # End of DBIx::Class::QueryLog
+__PACKAGE__->meta->make_immutable;
+
+1;




More information about the Bast-commits mailing list