ACME-QuoteDB
view release on metacpan or search on metacpan
use strict;
use warnings;
use Module::Build;
my $class = Module::Build->subclass(code => <<'EOF');
use File::Spec;
use File::Copy;
use File::Basename qw/dirname/;
sub process_db_files {
my $self = shift;
my $qdb = File::Spec->catfile(qw(lib ACME QuoteDB DB quotedb), 'quotes.db');
my $_t = File::Spec->catfile(qw(blib lib ACME QuoteDB DB quotedb), 'quotes.db');
mkdir dirname($_t);
chmod(0777, dirname($_t));
copy($qdb, $_t);
chmod(0666, $_t);
}
lib/ACME/QuoteDB.pm view on Meta::CPAN
Q: Why did you put it in the ACME namespace?
A: Seemed appropriate. I emailed modules@cpan.org and didn't get a
different reaction.
Q: Why did you write this?
A: At a past company, a team I worked on a project with had a test suite,
in which at the completion of successful tests (100%), a 'wisenheimer'
success message would be printed. (Like a quote or joke or the like)
(Interestingly, it added a 'fun' factor to testing, not that one is needed
of course ;). It was hard to justify spending company time to find and
add decent content to the hand rolled process, this would have helped.
Q: Don't you have anything better to do, like some non-trivial work?
A: Yup
Q: Hey Dood! why are u uzing Class::DBI as your ORM!? Haven't your heard
of L<DBIx::Class>?
A: Yup, and I'm aware of 'the new hotness' L<Rose::DB>. If you use this
module and are unhappy with the ORM, feel free to change it.
So far L<Class::DBI> is working for my needs.
lib/ACME/QuoteDB/LoadDB.pm view on Meta::CPAN
}
return;
}
sub _parse_file {
my ($self, $file) = @_;
if (!-f $file) { croak "file not found: $file" }
if ($self->{verbose}){warn "processing file: $file\n"};
if (($self->{file_format} eq 'csv') || ($self->{file_format} eq 'tsv')){
$self->dbload_from_csv($file);
}
elsif (($self->{file_format} eq 'html') || ($self->{file_format} eq 'custom')){
# not supported, too many possibilities
# supply your own
$self->dbload($file);
}
else {
lib/ACME/QuoteDB/LoadDB.pm view on Meta::CPAN
}
return;
}
sub _parse_data {
my ($self, $data) = @_;
if (!$data) {croak "data empty $data"}
if ($self->{verbose}){carp 'processing data:'};
if ($self->{file_format} =~ /(?:csv|tsv)/sm) {
croak 'TODO: not yet supported';
#$self->dbload_from_csv($data);
}
elsif (($self->{file_format} eq 'html') || ($self->{file_format} eq 'custom')){
# not supported, too many possibilities
# supply your own
$self->dbload($data);
}
lib/ACME/QuoteDB/LoadDB.pm view on Meta::CPAN
example:
{create_db => 1}
=back
=head2 data_to_db
takes the data input provided to new, process' it and writes to the database.
should appropriatly blow up if not successful
=head2 dbload_from_csv
takes a csv file (in our defined format) as an argument, parses it and writes
the data to the database. (uses L<Text::CSV> with pure perl parser)
utf-8 safe. (opens file as utf8)
will croak with message if not successful
t/02-get_quotes.t view on Meta::CPAN
BEGIN {
eval "use DBD::SQLite";
$@ and croak 'DBD::SQLite is a required dependancy';
}
#make test db writeable
sub make_test_db_rw {
use ACME::QuoteDB::DB::DBI;
# yeah, this is supposed to be covered by the build process
# but is failing sometimes,...
chmod 0666, ACME::QuoteDB::DB::DBI->get_current_db_path;
}
{
make_test_db_rw;
my $q = File::Spec->catfile((dirname(__FILE__),'data'), 'simpsons_quotes.csv');
my $load_db = ACME::QuoteDB::LoadDB->new({
file => $q,
t/04-get_quotes_more.t view on Meta::CPAN
Readonly my $FG_QUOTE => 'Lois: Peter, what did you promise me?' .
"\nPeter: That I wouldn't drink at the stag party." .
"\nLois: And what did you do?" .
"\nPeter: Drank at the stag pa-- ... Whoa. I almost walked into that one.";
{
#make test db writeable
use ACME::QuoteDB::DB::DBI;
# yeah, this is supposed to be covered by the build process
# but is failing sometimes,...
chmod 0666, ACME::QuoteDB::DB::DBI->get_current_db_path;
my $q = File::Spec->catfile((dirname(__FILE__),'data'),
'simpsons_quotes.csv'
);
my $load_db = ACME::QuoteDB::LoadDB->new({
file => $q,
file_format => 'csv',
create_db => 1,
t/04-load_get_quote_utf8.t view on Meta::CPAN
'ëë ì 리를 먹ì ì ìì´ì. ê·¸ëë ìíì§ ììì',
'Tsésǫʼ yishÄ
ÌÄ
go bÃÃnÃshghah dóó doo shiÅ neezgai da. ',
'ÎÏοÏÏ Î½Î± ÏÎ¬Ï ÏÏαÏμÎνα γÏ
αλιά ÏÏÏÎ¯Ï Î½Î± ÏÎ¬Î¸Ï ÏίÏοÏα.',
'मà¥à¤ à¤à¤¾à¤à¤ à¤à¤¾ सà¤à¤¤à¤¾ हà¥à¤, मà¥à¤à¥ à¤à¤¸ सॠà¤à¥à¤ पà¥à¤¡à¤¾ नहà¥à¤ हà¥à¤¤à¥.',
'×× × ×××× ××××× ×××××ת ××× ×× ××××§ ××',
];# any takers for specifying each multibyte code sequence for the above,.. ;)
{
#make test db writeable
use ACME::QuoteDB::DB::DBI;
# yeah, this is supposed to be covered by the build process
# but is failing sometimes,...
chmod 0666, ACME::QuoteDB::DB::DBI->get_current_db_path;
my $q = File::Spec->catfile((dirname(__FILE__),'data'),
'utf8.csv'
);
my $load_db = ACME::QuoteDB::LoadDB->new({
file => $q,
file_format => 'csv',
delimiter => "\t",
t/data/python_quotes.txt view on Meta::CPAN
I don't know a lot about this artificial life stuff -- but I'm suspicious
of anything Newsweek gets goofy about -- and I suspect its primary use is as
another money extraction tool to be applied by ai labs to the department of
defense (and more power to 'em).
Nevertheless in wondering why free software is so good these days it
occurred to me that the propagation of free software is one gigantic artificial
life evolution experiment, but the metaphor isn't perfect.
Programs are thrown out into the harsh environment, and the bad ones die.
The good ones adapt rapidly and become very robust in short order.
The only problem with the metaphor is that the process isn't random at all.
Python *chooses* to include Tk's genes; Linux decides to make itself more
suitable for symbiosis with X, etcetera.
Free software is artificial life, but better.
-- Aaron Watters, 29 Sep 1994
I claim complete innocence and ignorance! It must have been Tim. I wouldn't
know a Trondheim Hammer if it fell on my foot!
-- Steve Majewski, 10 Jan 1995
(Aieee! Yet another thing on my TODO pile!)
t/data/python_quotes.txt view on Meta::CPAN
testing and say that types only catch a small portion of possible errors. The
static people retort that they don't trust tests to cover everything or not
have bugs and why write tests for stuff the compiler should test for you, so
you shouldn't rely on *only* tests, and besides static types don't catch a
small portion, but a large portion of errors. The dynamic people say no program
or test is perfect and static typing is not worth the cost in language
complexity and design difficulty for the gain in eliminating a few tests that
would have been easy to write anyway, since static types catch a small portion
of errors, not a large portion. The static people say static types don't add
that much language complexity, and it's not design "difficulty" but an
essential part of the process, and they catch a large portion, not a small
portion. The dynamic people say they add enormous complexity, and they catch a
small portion, and point out that the static people have bad breath. The static
people assert that the dynamic people must be too stupid to cope with a real
language and rigorous requirements, and are ugly besides.
This is when both sides start throwing rocks.
-- Quinn Dunkan, 13 Jul 2001
I am becoming convinced that Unicode is a multi-national plot to take over the
minds of our most gifted (and/or most obsessive) programmers, in pursuit of an
elusive, unresolvable, and ultimately, undefinable goal.
t/data/www.amk.ca/quotations/python-quotes/index.html view on Meta::CPAN
<p class='quotation' id='q21'>I don't know a lot about this
artificial life stuff -- but I'm suspicious of anything Newsweek
gets goofy about -- and I suspect its primary use is as another
money extraction tool to be applied by ai labs to the department of
defense (and more power to 'em). Nevertheless in wondering why free software is
so good these days it occurred to me that the propagation of free
software is one gigantic artificial life evolution experiment, but
the metaphor isn't perfect. Programs are thrown out into the harsh
environment, and the bad ones die. The good ones adapt rapidly and
become very robust in short order. The only problem with the metaphor is that the
process isn't random at all. Python <em>chooses</em> to include
Tk's genes; Linux decides to make itself more suitable for
symbiosis with X, etcetera. Free software is artificial life, but
better.</p>
<p class='source'>Aaron Watters, 29 Sep 1994</p>
<p class='quotation' id='q22'>I claim complete innocence and
ignorance! It must have been Tim. I wouldn't know a Trondheim
Hammer if it fell on my foot!</p>
<p class='source'>Steve Majewski, 10 Jan 1995</p>
<p class='quotation' id='q23'>(Aieee! Yet another thing on my TODO
pile!)</p>
( run in 0.422 second using v1.01-cache-2.11-cpan-8d75d55dd25 )