[Bast-commits] r4326 - in DBIx-Class/0.08/trunk: lib/DBIx/Class/Schema t

jnapiorkowski at dev.catalyst.perl.org jnapiorkowski at dev.catalyst.perl.org
Mon May 5 19:33:57 BST 2008


Author: jnapiorkowski
Date: 2008-05-05 19:33:57 +0100 (Mon, 05 May 2008)
New Revision: 4326

Removed:
   DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema/AtQueryInterval.pm
   DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema/QueryInterval.pm
   DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema/Role/
   DBIx-Class/0.08/trunk/t/99schema_roles.t
Log:
removed query count stuff from trunk so we can play with this on a branch instead

Deleted: DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema/AtQueryInterval.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema/AtQueryInterval.pm	2008-05-05 18:32:24 UTC (rev 4325)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema/AtQueryInterval.pm	2008-05-05 18:33:57 UTC (rev 4326)
@@ -1,91 +0,0 @@
-package DBIx::Class::Schema::AtQueryInterval;
-
-use Moose;
-
-=head1 NAME
-
-DBIx::Class::Schema::Role::AtQueryInterval; Defines a job control interval.
-
-=head1 SYNOPSIS
-
-The following example shows how to define a job control interval and assign it
-to a particular L<DBIx::Class::Schema::Job> for a L<DBIx::Class::Schema>
-
-    my $job = DBIx::Class::Schema->new(runs => sub { print 'did job'});
-    my $interval = DBIx::Class::Schema::Interval->new(every => 10);
-    
-    if($interval->matches($query_count)) {
-    	print "I indentified the query count as matching";
-    }
-    
-    ## $schema->isa(DBIx::Class::Schema);
-    $schema->create_and_add_at_query_intervals($interval => $job);
-    
-=head1 DESCRIPTION
-
-An AtQueryInterval is a plan object that will execute a certain
-
-=head1 ATTRIBUTES
-
-This package defines the following attributes.
-
-=head2 job (DBIx::Class::Schema::Job)
-
-This is the job which will run at the specified query interval
-
-=cut
-
-has 'job' => (
-  is=>'ro',
-  isa=>'DBIx::Class::Schema::Job',
-  required=>1,
-  handles=>['execute'],
-);
-
-
-=head2 interval (Int)
-
-This is the interval we are watching for
-
-=cut
-
-has 'interval' => (
-  is=>'ro',
-  isa=>'DBIx::Class::Schema::QueryInterval',
-  required=>1,
-  handles=>['matches'],
-);
-
-
-=head1 METHODS
-
-This module defines the following methods.
-
-=head2 execute_if_matches ($query_count, @args)
-
-Does the $query_count match the defined interval?  Returns a Boolean.
-
-=cut
-
-sub execute_if_matches {
-  my ($self, $query_count, @args) = @_;
-  if($self->matches($query_count)) {
-  	return $self->execute(@args);
-  } else {
-  	return;
-  }
-}
-
-
-=head1 AUTHORS
-
-See L<DBIx::Class> for more information regarding authors.
-
-=head1 LICENSE
-
-You may distribute this code under the same terms as Perl itself.
-
-=cut
-
-
-1;
\ No newline at end of file

Deleted: DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema/QueryInterval.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema/QueryInterval.pm	2008-05-05 18:32:24 UTC (rev 4325)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema/QueryInterval.pm	2008-05-05 18:33:57 UTC (rev 4326)
@@ -1,93 +0,0 @@
-package DBIx::Class::Schema::QueryInterval;
-
-use Moose;
-
-=head1 NAME
-
-DBIx::Class::Schema::Role::QueryInterval; Defines a job control interval.
-
-=head1 SYNOPSIS
-
-The following example shows how to define a job control interval and assign it
-to a particular L<DBIx::Class::Schema::Job> for a L<DBIx::Class::Schema>
-
-    my $job = DBIx::Class::Schema->new(runs => sub { print 'did job'});
-    my $interval = DBIx::Class::Schema::Interval->new(every => 10);
-    
-    if($interval->matches($query_count)) {
-    	print "I indentified the query count as matching";
-    }
-    
-    ## $schema->isa(DBIx::Class::Schema);
-    $schema->create_and_add_at_query_intervals($interval => $job);
-    
-=head1 DESCRIPTION
-
-A Query Interval defines a reoccuring period based on the query count from a
-given offset.  For example, you can define a query interval of 10 queries
-with an offset of 1 query.  This interval identifies query number 11, 21, 31,
-and so on.
-
-=head1 ATTRIBUTES
-
-This package defines the following attributes.
-
-=head2 every (Int)
-
-This is the 'size' of the gap identifying a query as matching a particular
-interval.  Think, "I match every X queries".
-
-=cut
-
-has 'every' => (
-  is=>'ro',
-  isa=>'Int',
-  required=>1,
-);
-
-
-=head2 offset (Int)
-
-This is a number of queries from the start of all queries to offset the match
-counting mechanism.  This is basically added to the L</every> attribute to 
-identify a query as matching the interval we wish to define.
-
-=cut
-
-has 'offset' => (
-  is=>'ro',
-  isa=>'Int',
-  required=>1,
-  default=>0,
-);
-
-
-=head1 METHODS
-
-This module defines the following methods.
-
-=head2 matches ($query_count)
-
-Does the $query_count match the defined interval?  Returns a Boolean.
-
-=cut
-
-sub matches {
-  my ($self, $query_count) = @_;
-  my $offset_count = $query_count - $self->offset;
-  return $offset_count % $self->every ? 0:1;
-}
-
-
-=head1 AUTHORS
-
-See L<DBIx::Class> for more information regarding authors.
-
-=head1 LICENSE
-
-You may distribute this code under the same terms as Perl itself.
-
-=cut
-
-
-1;
\ No newline at end of file

Deleted: DBIx-Class/0.08/trunk/t/99schema_roles.t
===================================================================
--- DBIx-Class/0.08/trunk/t/99schema_roles.t	2008-05-05 18:32:24 UTC (rev 4325)
+++ DBIx-Class/0.08/trunk/t/99schema_roles.t	2008-05-05 18:33:57 UTC (rev 4326)
@@ -1,192 +0,0 @@
-use strict;
-use warnings;
-use lib qw(t/lib);
-use Test::More;
-
-BEGIN {
-    eval "use Moose";
-    plan $@
-        ? ( skip_all => 'needs Moose for testing' )
-        : ( tests => 35 );
-}
-
-=head1 NAME
-
-DBICNGTest::Schema::ResultSet:Person; Example Resultset
-
-=head1 DESCRIPTION
-
-Tests for the various Schema roles you can either use or apply
-
-=head1 TESTS
-
-=head2 initialize database
-
-create a schema and setup
-
-=cut
-
-use_ok 'DBICNGTest::Schema';
-
-ok my $db_file = Path::Class::File->new(qw/t var DBIxClassNG.db/)
-    => 'created a path for the test database';
-
-unlink $db_file;
-
-ok my $schema = DBICNGTest::Schema->connect_and_setup($db_file)
-    => 'Created a good Schema';
-
-is ref $schema->source('Person'), 'DBIx::Class::ResultSource::Table'
-    => 'Found Expected Person Source';
-    
-is $schema->resultset('Person')->count, 5
-    => 'Got the correct number of people';
-
-is $schema->resultset('Gender')->count, 3
-    => 'Got the correct number of genders';
-
-
-=head2 check query counter
-
-Test the query counter role
-
-=cut
-
-use_ok 'DBIx::Class::Storage::DBI::Role::QueryCounter';
-DBIx::Class::Storage::DBI::Role::QueryCounter->meta->apply($schema->storage);
-
-is $schema->storage->query_count, 0
-    => 'Query Count is zero';
-    
-is $schema->resultset('Person')->find(1)->name, 'john'
-    => 'Found John!';
-
-is $schema->resultset('Person')->find(2)->name, 'dan'
-    => 'Found Dan!';
-
-is $schema->storage->query_count, 2
-    => 'Query Count is two'; 
-
-
-=head2 check at query interval 
-    
-Test the role for associating events with a given query interval
-
-=cut
-
-use_ok 'DBIx::Class::Schema::Role::AtQueryInterval';
-DBIx::Class::Schema::Role::AtQueryInterval->meta->apply($schema);
-
-ok my $job1 = $schema->create_job(runs=>sub { 'hello'})
-    => 'Created a job';
-
-is $job1->execute, 'hello',
-    => 'Got expected information from the job';
-
-ok my $job2 = $schema->create_job(runs=>'job_handler_echo')
-    => 'Created a job';
-
-is $job2->execute($schema, 'hello1'), 'hello1',
-    => 'Got expected information from the job';
-
-ok my $interval1 = $schema->create_query_interval(every=>10)
-    => 'Created an interval';
-
-ok $interval1->matches(10)
-    => 'correctly matched 10';
-
-ok $interval1->matches(20)
-    => 'correctly matched 20';
-
-ok !$interval1->matches(22)
-    => 'correctly didnt matched 22';
-
-ok my $interval2 = $schema->create_query_interval(every=>10, offset=>2)
-    => 'Created an interval';
-
-ok $interval2->matches(12)
-    => 'correctly matched 12';
-
-ok $interval2->matches(22)
-    => 'correctly matched 22';
-
-ok !$interval2->matches(25)
-    => 'correctly didnt matched 25';
-    
-ok my $at = $schema->create_at_query_interval(interval=>$interval2, job=>$job2)
-    => 'created the at query interval object';
-    
-is $at->execute_if_matches(32, $schema, 'hello2'), 'hello2'
-    => 'Got correct return';
-    
-ok $schema->at_query_intervals([$at])
-    => 'added job to run at a given interval';
-
-is_deeply [$schema->execute_jobs_at_query_interval(42, 'hello4')], ['hello4']
-    => 'got expected job return value';
-    
-=head2 create jobs via express method
-
-Using the express method, build a bunch of jobs
-
-=cut
-
-ok my @ats = $schema->create_and_add_at_query_intervals(
-
-    {every => 10} => {
-        runs => sub {10},
-    },
-    {every => 20} => {
-        runs => sub {20},
-    },
-    {every => 30} => {
-        runs => sub {30},
-    },
-    {every => 101} => [
-        {runs => sub {101.1}},
-        {runs => sub {101.2}},       
-    ],
-           
-) => 'created express method at query intervals';
-
-
-is_deeply [$schema->execute_jobs_at_query_interval(10)], [10]
-    => 'Got Expected return for 10';
-
-is_deeply [$schema->execute_jobs_at_query_interval(12, 'hello5')], ['hello5']
-    => 'Got Expected return for 12';
-       
-is_deeply [$schema->execute_jobs_at_query_interval(20)], [10,20]
-    => 'Got Expected return for 20';
-
-is_deeply [$schema->execute_jobs_at_query_interval(30)], [10,30]
-    => 'Got Expected return for 30';
-    
-is_deeply [$schema->execute_jobs_at_query_interval(60)], [10,20,30]
-    => 'Got Expected return for 60';    
-     
-is_deeply [$schema->execute_jobs_at_query_interval(101)], [101.1,101.2]
-    => 'Got Expected return for 101';
-   
-   
-
-
-
-=head2 cleanup
-
-Cleanup after ourselves
-
-=cut
-
-unlink $db_file;
-
-
-=head1 AUTHORS
-
-See L<DBIx::Class> for more information regarding authors.
-
-=head1 LICENSE
-
-You may distribute this code under the same terms as Perl itself.
-
-=cut
\ No newline at end of file




More information about the Bast-commits mailing list