ACME-QuoteDB

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

# Note: this file was auto-generated by Module::Build::Compat version 0.2808_01
    
    unless (eval "use Module::Build::Compat 0.02; 1" ) {
      print "This module requires Module::Build to install itself.\n";
      
      require ExtUtils::MakeMaker;
      my $yn = ExtUtils::MakeMaker::prompt
	('  Install Module::Build now from CPAN?', 'y');
      
      unless ($yn =~ /^y/i) {
	die " *** Cannot install without Module::Build.  Exiting ...\n";
      }
      

Makefile.PL  view on Meta::CPAN

      
      # Save this 'cause CPAN will chdir all over the place.
      my $cwd = Cwd::cwd();
      
      CPAN::Shell->install('Module::Build::Compat');
      CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate
	or die "Couldn't install Module::Build, giving up.\n";
      
      chdir $cwd or die "Cannot chdir() back to $cwd: $!";
    }
    eval "use Module::Build::Compat 0.02; 1" or die $@;
    use lib '_build/lib';
    Module::Build::Compat->run_build_pl(args => \@ARGV);
    require MyModuleBuilder;
    Module::Build::Compat->write_makefile(build_class => 'MyModuleBuilder');

lib/ACME/QuoteDB/LoadDB.pm  view on Meta::CPAN

#     # hmmmm, what about priv's access, etc
#     # maybe user need to supply a db, they have 
#     # access to, already created (just the db though)
#     ## create our db
#     #my $dbhc = DBI->connect('DBI:mysql:database=mysql;host='
#     #                           .$self->{host}, $self->{user}, $self->{pass})
#     #      || croak "db cannot be accessed $! $DBI::errstr";
#
#     #my $dbn = $self->{db};
#     #my $db = qq(CREATE DATABASE $dbn CHARACTER SET utf8 COLLATE utf8_general_ci);
#     # eval {
#     #     $dbhc->do($db) or croak $dbhc->errstr;
#     # };
#     # $@ and croak 'Cannot create database!';
#     # $dbhc->disconnect; $dbhc = undef;
#
#     my $drh = DBI->install_driver('mysql');
#     my $rc = $drh->func("dropdb", $self->{db}, 
#                    [$self->{host}, $self->{user}, $self->{password}],
#                    'admin'
#                );

lib/ACME/QuoteDB/LoadDB.pm  view on Meta::CPAN

# XXX refactor with sqlite
sub create_db_tables_mysql {
    my ($self) = @_;

     # connect to our db
     my $c = $self->{db}.';host='.$self->{host};
     my $dbh = DBI->connect(
             "DBI:mysql:database=$c", $self->{user}, $self->{pass})
               || croak "db cannot be accessed $! $DBI::errstr";

    eval {
        $dbh->do('DROP TABLE IF EXISTS quote;') or croak $dbh->errstr;

        $dbh->do('CREATE TABLE IF NOT EXISTS quote (
            quot_id        INTEGER NOT NULL AUTO_INCREMENT, 
            attr_id        INTEGER,
            quote          TEXT,
            source         TEXT,
            rating         REAL,
            PRIMARY KEY(quot_id)
            );')

lib/ACME/QuoteDB/LoadDB.pm  view on Meta::CPAN


     my $db = QDBI->get_current_db_path;

     #XXX is there really no way to do this with the existing 
     # connection?!(class dbi)
     my $dbh = DBI->connect('dbi:SQLite:dbname='.$db, '', '')
       || croak "$db cannot be accessed $! $DBI::errstr";

    #-- sqlite does not have a varchar datatype: VARCHAR(255)
    #-- A column declared INTEGER PRIMARY KEY will autoincrement.
    eval {
        $dbh->do('DROP TABLE IF EXISTS quote;') or croak $dbh->errstr;

        $dbh->do('CREATE TABLE IF NOT EXISTS quote (
            quot_id        INTEGER PRIMARY KEY, 
            attr_id        INTEGER,
            quote          TEXT,
            source         TEXT,
            rating         REAL
            );')
            or croak $dbh->errstr;

t/01-load_quotes.t  view on Meta::CPAN

#!perl -T

use strict;
use warnings;

use Carp qw/croak/;

BEGIN {
    eval "use DBD::SQLite";
    $@ and croak 'DBD::SQLite is a required dependancy';
}

use ACME::QuoteDB;
use ACME::QuoteDB::LoadDB;

#use Test::More 'no_plan';
use Test::More tests => 29;
use File::Basename qw/dirname/;
use Data::Dumper qw/Dumper/;

t/02-get_quotes.t  view on Meta::CPAN


#use Test::More 'no_plan';
use Test::More tests => 33;
use File::Basename qw/dirname/;
use Data::Dumper qw/Dumper/;
use Carp qw/croak/;
use File::Spec;


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;
}

t/02-get_quotes.t  view on Meta::CPAN

                     qq{kids never learn.\n-- Chief Wiggum};
    my $res = $sq->get_quote({AttrName => 'Chief Wiggum', Rating => '9.0'});
    if ($res && $res eq $q) {
        pass 'ok';
    } 
    else {
        fail 'quote should be found';
    }
}

eval { # param mispelled
    $sq->get_quote({Charcter => 'bart'});
};
if ($@) {
    pass if $@ =~ m/unsupported argument option passed/;
} else {fail 'should alert user on non existant params' };


eval {
    $sq->get_quote({Limit => '4'}); # only avail for 'get_quotes'
};
if ($@) {
    pass if $@ =~ m/unsupported argument option passed/;
} else {fail 'should alert user on non existant params' };


eval {
    $sq->get_quote({Contain => '4'}); # only avail for 'get_quotes_contain'
};
if ($@) {
    pass if $@ =~ m/unsupported argument option passed/;
} else {fail 'should alert user on non existant params' };


# any unique part of name should work
# i.e these should all return the same results
is scalar @{$sq->get_quotes({AttrName => 'comic book guy'})}, 8;
is scalar @{$sq->get_quotes({AttrName => 'comic book'})}, 8;
is scalar @{$sq->get_quotes({AttrName => 'comic'})}, 8;
is scalar @{$sq->get_quotes({AttrName => 'book'})}, 8;
is scalar @{$sq->get_quotes({AttrName => 'book guy'})}, 8;
is scalar @{$sq->get_quotes({AttrName => 'guy'})}, 8;

eval {
    $sq->get_quotes({AttrName => 'your momma'});
};
if ($@) {
    pass 'ok' if $@ =~ m/attribution not found/;
    pass 'ok'; #'dont talk about my momma on the simpsons';
} else {fail 'attribution should not be found' };

eval {
    $sq->get_quotes({AttrName => 'chewbaccas momma'});
};
if ($@) {
    pass 'ok' if $@ =~ m/attribution not found/;
    pass 'ok'; #'now your really asking for trouble'; 
} else {fail 'attribution should not be found' };


eval { # param mispelled
    $sq->get_quotes({Charcter => 'bart'});
};
if ($@) {
    pass if $@ =~ m/unsupported argument option passed/;
} else {fail 'should alert user on non existant params' };


#sqlite> select COUNT(*) from quote where attribution_id IN (29,5);
#61 # get all family name wiggum quotes (ralph and clancy)
is scalar @{$sq->get_quotes({AttrName => 'wiggum', Rating => '2-10'})}, 15;

t/02-get_quotes.t  view on Meta::CPAN

})->[0], $gs;


is $sq->get_quotes_contain({
                  Contain =>  'til the cow',
                  Rating  => '1-5',
                  Limit   => 2
})->[0], undef;


eval {
    $sq->get_quotes_contain({
                      Contain =>  'til the cow',
                      Rating  => '-7',
                      Limit   => 2
    })};
if ($@) {
    pass if $@ =~ m/negative range not permitted/;
} else {fail 'should alert user on incorrect rating input' };


t/03-load_quotes_env.t  view on Meta::CPAN

#!perl -T

use strict;
use warnings;

use Carp qw/croak/;
use File::Temp;

BEGIN {
    eval "use DBD::SQLite";
    $@ and croak 'DBD::SQLite is a required dependancy';

    # give alternate path to the DB
    $ENV{ACME_QUOTEDB_PATH} = 
          File::Temp->new( UNLINK => 0,
                           EXLOCK => 0,
                           SUFFIX => '.dat',
                     );
}

t/04-get_quotes_more.t  view on Meta::CPAN


#use Test::More 'no_plan';
use Test::More tests => 24;
use File::Basename qw/dirname/;
use Data::Dumper qw/Dumper/;
use Carp qw/croak/;
use File::Spec;
use Readonly;

BEGIN {
    eval "use DBD::SQLite";
    $@ and croak 'DBD::SQLite is a required dependancy';
}


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.";
  

t/04-get_quotes_more.t  view on Meta::CPAN

my $sq = ACME::QuoteDB->new;

is $sq->get_quote({Rating => '8.7'}),
    "Me fail English? That's unpossible.\n-- Ralph Wiggum";

is( $sq->list_attr_sources, 'The Simpsons');
is( $sq->list_categories, 'Humor');


{
  eval { # quote is mandatory
     $sq->add_quote({
         Quote     => q{},
         AttrName  => 'Peter Griffin',
         Source    => 'Family Guy',
         Rating    => '8.6',
         Category  => 'TV Humor',
     });
  };
  if ($@) {
      if ($@ =~ m/ are mandatory parameters/){ 
         pass 'correct, exception expected'
      }
      else {fail 'unexpected exception occured'};
  } 
  else {fail 'quote and name are required'};
}


# quote does not yet exist in db
{ 
  eval { # see, not exist yet
      $sq->get_quote({AttrName => 'Griffin'});
  };
  if ($@) {
     pass 'ok' if $@ =~ m/attribution not found/;
  } else {
     fail 'attribution does not yet exist, so should not be found'
  };
}

{ # now, add new quote to the db

t/04-get_quotes_more.t  view on Meta::CPAN

  $sq->update_quote({
      QuoteId   => $qid,
      Quote     => $qu,
      AttrName  => 'Lois Simpson',
      Source    => 'The Simpsons Guys',
      Rating    => '9.6',
      Category  => 'Cartoon Noir',
  });

  $qu .= "\n-- Lois Simpson";
  eval { # see, updated, should now be 'Lois Simpson'
     $sq->get_quote({AttrName => 'Peter G'});
  };
  if ($@) {
      pass 'ok' if $@ =~ m/attribution not found/;
  } else {fail 'attribution does not yet exist, so should not be found'};

  is $sq->get_quote({AttrName => 'Lois Simpson'}), $qu;
  is $sq->get_quote({AttrName => 'Lois S'}), $qu;
  is $sq->get_quote({Rating => '9.6'}), $qu;

t/04-load_get_quote_utf8.t  view on Meta::CPAN

#use Test::More 'no_plan';
use Test::More tests => 8;
use File::Basename qw/dirname/;
use Data::Dumper qw/Dumper/;
use Carp qw/croak/;
use File::Temp;
use File::Spec;


BEGIN {
    eval "use DBD::SQLite";
    $@ and croak 'DBD::SQLite is a required dependancy';

    # give alternate path to the DB
    $ENV{ACME_QUOTEDB_PATH} = 
          File::Temp->new( UNLINK => 0,
                           EXLOCK => 0,
                           SUFFIX => '.dat',
                     );
}

t/05-load_quotes_remote.t  view on Meta::CPAN

#!perl -T

use strict;
use warnings;

#BEGIN {
#       eval "use DBD::SQLite";
#       plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 6);
#}

use Carp qw/croak/; 
use Test::More;
#use Test::More tests => 9;
#use Test::More qw/no_plan/;
use File::Basename qw/dirname/;
use DBI;
use File::Temp;
use File::Spec;

BEGIN {
    eval "use DBI";
    $@ and plan skip_all => 'DBI/mysql is required for this test';

    # have to set this to use remote database
    $ENV{ACME_QUOTEDB_REMOTE} =  'mysql';
    $ENV{ACME_QUOTEDB_DB}     =  'acme_quotedb';
    $ENV{ACME_QUOTEDB_HOST}   =  'localhost';
    $ENV{ACME_QUOTEDB_USER}   =  'acme_user';
    $ENV{ACME_QUOTEDB_PASS}   =  'acme';
}
my $database = $ENV{ACME_QUOTEDB_DB};
my $host     = $ENV{ACME_QUOTEDB_HOST};
my $user     = $ENV{ACME_QUOTEDB_USER};
my $pass     = $ENV{ACME_QUOTEDB_PASS};

# XXX these use's must happen after the BEGIN,...
use ACME::QuoteDB::LoadDB;
use ACME::QuoteDB;

eval {
  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/data/python_quotes.txt  view on Meta::CPAN

In one particular way the conflict is fundamental & eternal: the "working
scientists" generally understand the hardware du jour perfectly, and
passionately resent any attempt to prevent them from fiddling with it directly
-- while the theory folks are forever inventing new ways to hide the hardware
du jour. That two groups can both be so right and so wrong at the same time is
my seventh proof for the existence of God ...
      -- Tim Peters, 25 Mar 1997

You're going to be in a minority - you're coming to Python programming from a
language which offers you a lot more in the way of comfortable operations than
Python, instead of coming from medieval torture chambers like C or Fortran,
which offer so much less.
      -- Andrew Mullhaupt, 26 Jun 1997

...although Python uses an obsolete approach to memory management, it is a
*good* implementation of that approach, as opposed to S, which uses a
combination of bad implementation and demented design decisions to arrive at
what may very well be the worst memory behavior of any actually useful program.
      -- Andrew Mullhaupt, 26 Jun 1997

I suggested holding a "Python Object Oriented Programming Seminar", but the

t/data/python_quotes.txt  view on Meta::CPAN

      -- Tim Peters, on python-help, 16 Jun 1998

Now some people see unchecked raw power and flee from perceived danger, while
others rush toward perceived opportunity. That's up to them. But I think it's
enormously *clarifying* in either case to see just *how* raw this particular
gimmick can get.
      -- Tim Peters, 16 Jun 1998

Every language has its partisans, usually among folks deeply immersed in their
particular theology, triumphant in having divined the inner meaning of some
esoteric operations, like a medieval Jesuit hot on the trail of the final
ontological proof, whose conciseness in solving a single problem makes them
almost swoon with ecstacy at the expected savings of many keystrokes, as if
those very keystrokes represented a lot of heavy lifting and hauling on their
part.
      -- John Holmgren, 18 Jun 1998

    > In general, the situation sucks.
    mind-if-i-use-that-as-my-epitaph<wink>?-ly y'rs - tim
      -- Timothy J. Grant and Tim Peters, 22 Jun 1998

t/data/python_quotes.txt  view on Meta::CPAN

      -- Tim Peters remembering the Model 100, 10 Jan 1999

    "Heh -- all it really broke so far was my resistance to installing Tk. I
suppose wizardry is inevitable after one installs something, though <wink>."
    "Spoken like a truly obsessive-compulsive wizard! It-takes-one-to-know
-one..."
      -- Tim Peters and Guido van Rossum, 6 Jan 1999

Note, however, that architectural forms are completely declarative and can be
implemented in a highly optimized fashion. The sorts of extensions that
Microsoft has proposed for XSL (<xsl:eval>...</>) would completely destroy
those features. Architectural mapping would, in general, be as reliable and
high performance as ordinary software -- (not at all).
      -- Paul Prescod, 6 Jan 1999

Darned confusing, unless you have that magic ingredient *coffee*, of which I
can pay you Tuesday for a couple pounds of extra-special grind today.
      -- John Mitchell, 11 Jan 1999

That's so obvious that someone has already got a patent on it.
      -- Guido van Rossum, 12 Jan 1999

t/data/python_quotes.txt  view on Meta::CPAN


Python 2.0 beta 1 is now available from BeOpen PythonLabs. There is a long list
of new features since Python 1.6, released earlier today. We don't plan on any
new releases in the next 24 hours.
      -- Jeremy Hylton, in the 2.0b1 announcement, 5 Sep 2000

Fortunately, you've left that madness behind, and entered the clean, happy, and
safe Python world of transvestite lumberjacks and singing Vikings.
      -- Quinn Dunkan, 17 Sep 2000

Regular expressions are among my most valued tools, along with goto, eval,
multiple inheritance, preemptive multithreading, floating point, run-time type
identification, a big knife, a bottle of bleach, and 120VAC electricity. All of
these things suck sometimes.
      -- Kragen Sitaker, 27 Sep 2000

    IIRC, he didn't much care for regexps before, but actually writing a regexp
engine drives most people who do it to intense hatred.
    Just more of the magic of Python! Transmuting a few peoples' intense agony
into the subject of others' idle amusement <wink>.
      -- Tim Peters, 27 Sep 2000

t/data/python_quotes.txt  view on Meta::CPAN

A fruitful approach to problem solving is known as "divide and conquer", or
making problems easier by splitting their different aspects apart. Making
problems harder by joining several aspects together must be an example of an
approach known as "unite and suffer!"
      -- Alex Martelli, _Python Cookbook_

compromise-is-the-art-of-spreading-misery-ly y'rs
      -- Tim Peters, 11 Dec 2002

As for Grail, it was certainly a "hot product" in the Python community in 1995
because of the restricted execution environment which I evaluated for a project
involving mobile software agents. How priorities and trends have changed since
then! Who would have thought that Microsoft Outlook would be the premier
platform for mobile code?
      -- Paul Boddie, 16 Jan 2004

    I mean, if I think about my open-source contributions, nobody wants to see
talks with these titles:
    * The Zope API Reference: Ouch
    * A Random Handful Of Bugs I've Fixed In Other Peoples' Code
    * An Old Crufty Project I Inherited That Has Zero Relevance To You

t/data/www.amk.ca/quotations/python-quotes/index.html  view on Meta::CPAN

understand the hardware du jour perfectly, and passionately resent
any attempt to prevent them from fiddling with it directly -- while
the theory folks are forever inventing new ways to hide the
hardware du jour. That two groups can both be so right and so wrong
at the same time is my seventh proof for the existence of God
...</p>
<p class='source'>Tim Peters, 25 Mar 1997</p>
<p class='quotation' id='q35'>You're going to be in a minority -
you're coming to Python programming from a language which offers
you a lot more in the way of comfortable operations than Python,
instead of coming from medieval torture chambers like C or Fortran,
which offer so much less.</p>
<p class='source'>Andrew Mullhaupt, 26 Jun 1997</p>
<p class='quotation' id='q36'>...although Python uses an obsolete
approach to memory management, it is a <em>good</em> implementation
of that approach, as opposed to S, which uses a combination of bad
implementation and demented design decisions to arrive at what may
very well be the worst memory behavior of any actually useful
program.</p>
<p class='source'>Andrew Mullhaupt, 26 Jun 1997</p>
<hr />

t/data/www.amk.ca/quotations/python-quotes/page-10.html  view on Meta::CPAN

known as "divide and conquer", or making problems easier by
splitting their different aspects apart. Making problems harder by
joining several aspects together must be an example of an approach
known as "unite and suffer!"</p>
<p class='source'>Alex Martelli<cite>Python Cookbook</cite></p>
<p class='quotation' id='q313'>
compromise-is-the-art-of-spreading-misery-ly y'rs</p>
<p class='source'>Tim Peters, 11 Dec 2002</p>
<p class='quotation' id='q314'>As for Grail, it was certainly a
"hot product" in the Python community in 1995 because of the
restricted execution environment which I evaluated for a project
involving mobile software agents. How priorities and trends have
changed since then! Who would have thought that Microsoft Outlook
would be the premier platform for mobile code?</p>
<p class='source'>Paul Boddie, 16 Jan 2004</p>
<p class='quotation' id='q314'>I mean, if I think about my
open-source contributions, nobody wants to see talks with these
titles:
<p class='quotation'>* The Zope API Reference: Ouch
* A Random Handful Of Bugs I've Fixed In Other Peoples' Code
* An Old Crufty Project I Inherited That Has Zero Relevance To You

t/data/www.amk.ca/quotations/python-quotes/page-3.html  view on Meta::CPAN

<p class='source'>Tim Peters, on python-help, 16 Jun 1998</p>
<p class='quotation' id='q74'>Now some people see unchecked raw
power and flee from perceived danger, while others rush toward
perceived opportunity. That's up to them. But I think it's
enormously <em>clarifying</em> in either case to see just
<em>how</em> raw this particular gimmick can get.</p>
<p class='source'>Tim Peters, 16 Jun 1998</p>
<p class='quotation' id='q75'>Every language has its partisans,
usually among folks deeply immersed in their particular theology,
triumphant in having divined the inner meaning of some esoteric
operations, like a medieval Jesuit hot on the trail of the final
ontological proof, whose conciseness in solving a single problem
makes them almost swoon with ecstacy at the expected savings of
many keystrokes, as if those very keystrokes represented a lot of
heavy lifting and hauling on their part.</p>
<p class='source'>John Holmgren, 18 Jun 1998</p>
<p class='quotation' id='q76'>&gt; In general, the situation
sucks.
mind-if-i-use-that-as-my-epitaph&lt;wink&gt;?-ly y'rs - tim</p>
<p class='source'>Timothy J. Grant and Tim Peters, 22 Jun 1998</p>
<p class='quotation' id='q77'>&gt; Just for the record, on AIX, the

t/pod-coverage.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More;

# Ensure a recent version of Test::Pod::Coverage
my $min_tpc = 1.08;
eval "use Test::Pod::Coverage $min_tpc";
plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
    if $@;

# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
# but older versions don't recognize some common documentation styles
my $min_pc = 0.18;
eval "use Pod::Coverage $min_pc";
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
    if $@;

all_pod_coverage_ok();

t/pod.t  view on Meta::CPAN

#!perl -T

use strict;
use warnings;
use Test::More;

# Ensure a recent version of Test::Pod
my $min_tp = 1.22;
eval "use Test::Pod $min_tp";
plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;

all_pod_files_ok();



( run in 3.768 seconds using v1.01-cache-2.11-cpan-98e64b0badf )