Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
146 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
============================== | ||
2010-03-05 22:48:51 +0000 0.04 | ||
============================== | ||
|
||
commit e7cb1d37370638858d03b4f7d5b6919ee0eb340b | ||
Author: Chris Williams <chris@bingosnet.co.uk> | ||
Date: Fri Mar 5 22:48:51 2010 +0000 | ||
|
||
Fixed compile error | ||
|
||
commit f96c1ab41925d8b12885d3c341539637b219e7a2 | ||
Author: Chris Williams <chris@bingosnet.co.uk> | ||
Date: Fri Mar 5 22:39:03 2010 +0000 | ||
|
||
Refactored stuff into modules | ||
|
||
============== | ||
End of Excerpt | ||
============== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ use warnings; | |
|
||
use vars qw($VERSION); | ||
|
||
$VERSION = '0.04'; | ||
$VERSION = '0.06'; | ||
|
||
1; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package App::CPANIDX::Tables; | ||
|
||
use strict; | ||
use warnings; | ||
use vars qw[$VERSION]; | ||
|
||
$VERSION = '0.06'; | ||
|
||
my $tables = { | ||
mods => [ | ||
'mod_name VARCHAR(300) NOT NULL', | ||
'dist_name VARCHAR(190) NOT NULL', | ||
'dist_vers VARCHAR(20)', | ||
'cpan_id VARCHAR(20) NOT NULL', | ||
'mod_vers VARCHAR(30)', | ||
], | ||
dists => [ | ||
'dist_name VARCHAR(190) NOT NULL', | ||
'cpan_id VARCHAR(20) NOT NULL', | ||
'dist_file VARCHAR(400) NOT NULL', | ||
'dist_vers VARCHAR(20)', | ||
], | ||
auths => [ | ||
'cpan_id VARCHAR(20) NOT NULL', | ||
'fullname VARCHAR(60) NOT NULL', | ||
'email TEXT', | ||
], | ||
timestamp => [ | ||
'timestamp VARCHAR(30) NOT NULL', | ||
], | ||
}; | ||
|
||
sub table { | ||
return unless @_; | ||
my $table = shift; | ||
$table = shift if $table->isa(__PACKAGE__); | ||
return unless $table; | ||
return unless exists $tables->{ $table }; | ||
my $sql = 'CREATE TABLE IF NOT EXISTS ' . $table . ' ( '; | ||
$sql .= join ', ', @{ $tables->{$table} }; | ||
$sql .= ' )'; | ||
return $sql; | ||
} | ||
|
||
sub tables { | ||
return sort keys %{ $tables }; | ||
} | ||
|
||
1; | ||
|
||
__END__ | ||
=head1 NAME | ||
App::CPANIDX::Tables - Provide table definitions for App::CPANIDX | ||
=head1 SYNOPSIS | ||
my @tables = App::CPANIDX::Tables->tables(); | ||
my $sql = App::CPANIDX::Tables->table('dists'); | ||
=head1 DESCRIPTION | ||
App::CPANIDX::Tables provides the SQL to create the tables that App::CPANIDX uses. | ||
=head1 FUNCTIONS | ||
=over | ||
=item C<tables> | ||
Returns a list of the available tables. | ||
=item C<table> | ||
Takes one argument, the name of a table to lookup. | ||
Returns a SQL statement that can be used to create the table. | ||
=back | ||
=head1 AUTHOR | ||
Chris C<BinGOs> Williams <chris@bingosnet.co.uk> | ||
=head1 LICENSE | ||
Copyright E<copy> Chris Williams | ||
This module may be used, modified, and distributed under the same terms as Perl itself. Please see the license that came with your Perl distribution for details. | ||
=head1 SEE ALSO | ||
L<App::CPANIDX> | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
use Test::More tests => 3; | ||
use Test::More tests => 4; | ||
use_ok('App::CPANIDX'); | ||
use_ok('App::CPANIDX::Renderer'); | ||
use_ok('App::CPANIDX::Queries'); | ||
use_ok('App::CPANIDX::Tables'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use strict; | ||
use warnings; | ||
use Test::More; | ||
|
||
my $tests = { | ||
auths => 'CREATE TABLE IF NOT EXISTS auths ( cpan_id VARCHAR(20) NOT NULL, fullname VARCHAR(60) NOT NULL, email TEXT )', | ||
dists => 'CREATE TABLE IF NOT EXISTS dists ( dist_name VARCHAR(190) NOT NULL, cpan_id VARCHAR(20) NOT NULL, dist_file VARCHAR(400) NOT NULL, dist_vers VARCHAR(20) )', | ||
mods => 'CREATE TABLE IF NOT EXISTS mods ( mod_name VARCHAR(300) NOT NULL, dist_name VARCHAR(190) NOT NULL, dist_vers VARCHAR(20), cpan_id VARCHAR(20) NOT NULL, mod_vers VARCHAR(30) )', | ||
timestamp => 'CREATE TABLE IF NOT EXISTS timestamp ( timestamp VARCHAR(30) NOT NULL )', | ||
}; | ||
|
||
plan tests => 2 + ( scalar keys %$tests ); | ||
|
||
use_ok('App::CPANIDX::Tables'); | ||
|
||
my @origs = sort keys %$tests; | ||
my @types = sort App::CPANIDX::Tables->tables(); | ||
|
||
is_deeply( \@origs, \@types, 'We got the right tables back' ); | ||
|
||
foreach my $table ( sort keys %$tests ) { | ||
my $sql = App::CPANIDX::Tables->table( $table ); | ||
is( $sql, $tests->{$table}, qq{SQL for '$table' is correct} ); | ||
} |