Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Deprecated goodie test
Browse files Browse the repository at this point in the history
  • Loading branch information
Getty committed Jun 7, 2012
1 parent a846344 commit a8cd7e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 91 deletions.
89 changes: 2 additions & 87 deletions lib/App/DuckPAN/Cmd/Goodie.pm
Expand Up @@ -17,93 +17,8 @@ sub run {
exit 1; exit 1;
} }
if ($args[0] eq 'test') { if ($args[0] eq 'test') {
print "\n[WARNING] Please use duckpan query to cover all plugins!\n"; print "\n[DEPRECATED] Please use \"duckpan query\"!\n";
shift @args; exit 1;
if (defined $args[0] and $args[0] eq 'all') {
my $finder = Module::Pluggable::Object->new(
search_path => ['DDG::Goodie'],
);
@args = $finder->plugins;
unless (@args) {
print "\n[ERROR] No DDG::Goodie::* packages found\n";
print "\nHint: The 'all' parameter does not automatically include your lib path.\n\n";
exit 1;
}
} elsif (!@args) {
my $finder = Module::Pluggable::Object->new(
search_path => ['lib/DDG/Goodie'],
);
@args = $finder->plugins;
@args = map {
$_ =~ s!/!::!g;
my @parts = split('::',$_);
shift @parts;
join('::',@parts);
} @args;
require lib;
lib->import('lib');
}
unless (@args) {
print "\n[ERROR] No DDG::Goodie::* packages found\n";
print "\nHint: You must be in the root of your repository so that this works.\n\n";
exit 1;
}
print "\nUsing the following DDG::Goodie plugins:\n\n";
for (@args) {
load_class($_);
print " - ".$_;
print " (".$_->triggers_block_type.")\n";
}
my %blocks_plugins;
for (@args) {
unless ($blocks_plugins{$_->triggers_block_type}) {
$blocks_plugins{$_->triggers_block_type} = [];
}
push @{$blocks_plugins{$_->triggers_block_type}}, $_;
}
my @blocks;
for (keys %blocks_plugins) {
my $block_class = 'DDG::Block::'.$_;
load_class($block_class);
push @blocks, $block_class->new( plugins => $blocks_plugins{$_} );
}
load_class('DDG::Request');
print "\n(Empty query for ending test)\n";
while (my $query = $self->app->term->get_reply( prompt => 'Query: ' ) ) {
my $request = DDG::Request->new( query_raw => $query );
my $hit;
for (@blocks) {
my ($result) = $_->request($request);
if ($result) {
$hit = 1;
print "\n";
p($result);
print "\n";
last;
}
}
unless ($hit) {
print "\nSorry, no hit on your goodies\n\n";
}
}
print "\n\n\\_o< Thanks for testing!\n\n";
exit 0;
} elsif ($args[0] eq 'new') {
unless ($self->app->get_config) {
print "\n[ERROR] Please run 'duckpan setup' first\n\n";
exit 1;
}
shift @args;
if (scalar @args != 1) {
print "\n[ERROR] You need to give the name of your Goodie (no spaces allowed, please uppercase first letter)\n\n";
exit 1;
}
my $name = shift @args;
$name = ucfirst($name);
my $package = 'DDG::Goodie::'.$name;
my $dir = 'p5-ddg-goodie-'.lc($name);
print "\nGenerating ".$package." in ".$dir." ...\n\n";
exit 0;
} }
} }
print $self->app->help->goodie; print $self->app->help->goodie;
Expand Down
10 changes: 6 additions & 4 deletions lib/App/DuckPAN/Help.pm
Expand Up @@ -29,14 +29,16 @@ duckpan check
Check if you fulfill all requirements for the development Check if you fulfill all requirements for the development
environment (will automatically gets fired on setup) environment (will automatically gets fired on setup)
duckpan installdeps
-------------
Install all requirements of the specific DuckDuckHack project (if
possible), like zeroclickinfo-spice, zeroclickinfo-goodie, duckduckgo
or community-platform
duckpan query duckpan query
------------- -------------
Test your plugins if they match a specific query (interactive) Test your plugins if they match a specific query (interactive)
duckpan goodie
--------------
More help there about DDG::Goodie
duckpan release duckpan release
--------------- ---------------
Release the project of the current directory to DuckPAN [TODO] Release the project of the current directory to DuckPAN [TODO]
Expand Down

0 comments on commit a8cd7e4

Please sign in to comment.