App-DuckPAN

 view release on metacpan or  search on metacpan

lib/App/DuckPAN.pm  view on Meta::CPAN


sub _build_ia_types {
	my $ddg_path = path('lib', 'DDG');
	my $t_dir = path('t');
	return [{
			name          => 'Goodie',
			dir           => $ddg_path->child('Goodie'),
			supported     => 1,
			path_basename => 'zeroclickinfo-goodies',
			templates     => {
				code => {
					in  => path('template', 'lib', 'DDG', 'Goodie', 'Example.pm'),
					out => $ddg_path->child('Goodie')
				},
				test => {
					in  => path('template', 't', 'Example.t'),
					out => $t_dir
				},
			},
		},
		{
			name          => 'Spice',
			dir           => $ddg_path->child('Spice'),
			supported     => 1,
			path_basename => 'zeroclickinfo-spice',
			templates     => {
				code => {
					in  => path('template', 'lib', 'DDG', 'Spice', 'Example.pm'),
					out => $ddg_path->child('Spice')
				},
				test => {
					in  => path('template', 't', 'Example.t'),
					out => $t_dir
				},
				handlebars => {
					in  => path('template', 'share', 'spice', 'example', 'example.handlebars'),
					out => path('share',    'spice')
				},
				js => {
					in  => path('template', 'share', 'spice', 'example', 'example.js'),
					out => path('share',    'spice')
				},
			},
		},
		{
			name          => 'Fathead',
			dir           => $ddg_path->child('Fathead'),
			supported     => 1,
			path_basename => 'zeroclickinfo-fathead',
		},
		{
			name          => 'Longtail',
			dir           => $ddg_path->child('Longtail'),
			supported     => 0,
			path_basename => 'zeroclickinfo-longtail',
		},
	];
}

sub get_reply {
	my ( $self, $prompt, %params ) = @_;
	my $return = $self->term->get_reply( prompt => $prompt, %params );
	Encode::_utf8_on($return);
	return $return;
}

sub ask_yn {
	my ( $self, $prompt, %params ) = @_;

	return $self->term->ask_yn( prompt => $prompt, %params );
}

has http => (
	is => 'ro',
	builder => 1,
	lazy => 1,
);

sub _build_http {
	my ( $self ) = @_;
	my $agent = LWP::UserAgent->new;
	$agent->agent($self->_ua_string);
	$agent->env_proxy;
	$agent->proxy( http => $self->http_proxy ) if $self->has_http_proxy;
	return $agent;
}

has server_hostname => (
	is => 'ro',
	lazy => 1,
	builder => 1,
);

sub _build_server_hostname { defined $ENV{APP_DUCKPAN_SERVER_HOSTNAME} ? $ENV{APP_DUCKPAN_SERVER_HOSTNAME} : 'duckduckgo.com' }

has cfg => (
	is => 'ro',
	lazy => 1,
	builder => 1,
	handles => [qw(
		config_path
		config_file
		set_config
		get_config
	)]
);

sub _build_cfg {
	my ( $self ) = @_;
	App::DuckPAN::Config->new(
		$self->has_config ? ( config_path => $self->config ) : (),
		$self->has_cache ? ( cache_path => $self->cache ) : (),
	);
}

has perl => (
	is => 'ro',
	builder => 1,
	lazy => 1,
);

sub _build_perl {
	load_class('App::DuckPAN::Perl');
	App::DuckPAN::Perl->new( app => shift );
}

has ddg => (
	is => 'ro',
	builder => 1,
	lazy => 1,



( run in 1.080 second using v1.01-cache-2.11-cpan-6aa56a78535 )