Planets: Inital Build
parent
29028dd8f2
commit
d4fb773082
|
@ -0,0 +1,41 @@
|
|||
package DDG::Goodie::Planets;
|
||||
# ABSTRACT: Return various attributes of a planet
|
||||
|
||||
use DDG::Goodie;
|
||||
use YAML::XS qw( Load );
|
||||
|
||||
zci answer_type => "planets";
|
||||
zci is_cached => 1;
|
||||
|
||||
triggers startend => 'size of', 'planet size', 'what size is', 'volume';
|
||||
|
||||
name "Planets";
|
||||
primary_example_queries 'size of venus';
|
||||
secondary_example_queries 'what is the size of venus', 'volume of venus';
|
||||
description 'Lookup various attributes of planets';
|
||||
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Planets.pm";
|
||||
category 'conversions';
|
||||
topics 'special_interest';
|
||||
attribution github => 'chrisjwilsoncom',
|
||||
twitter => 'chrisjwilsoncom';
|
||||
|
||||
my $planets = Load(scalar share('planets.yml')->slurp);
|
||||
|
||||
# Handle statement
|
||||
handle remainder_lc => sub {
|
||||
|
||||
return unless $_;
|
||||
|
||||
my $value = $planets->{$_};
|
||||
|
||||
return unless $value;
|
||||
|
||||
return $value,
|
||||
structured_answer => {
|
||||
input => [$_],
|
||||
operation => 'planet attributes',
|
||||
result => $value
|
||||
};
|
||||
};
|
||||
|
||||
1;
|
|
@ -0,0 +1,65 @@
|
|||
---
|
||||
mercury:
|
||||
mean_distance_sun_km: 57,909,175
|
||||
equatorial_radius: 2,439.64
|
||||
surface_area: 75,000,000
|
||||
volume: 6.083×1010
|
||||
mass: 3.302×1023
|
||||
density: 5.43
|
||||
known_moons: 0
|
||||
venus:
|
||||
mean_distance_sun_km: 108,208,930
|
||||
equatorial_radius: 6,051.59
|
||||
surface_area: 460,000,000
|
||||
volume: 9.28×1011
|
||||
mass: 4.8690×1024
|
||||
density: 5.24
|
||||
known_moons: 0
|
||||
earth:
|
||||
mean_distance_sun_km: 149,597,890
|
||||
equatorial_radius: 6,378.1
|
||||
surface_area: 510,000,000
|
||||
volume: 1.083×1012
|
||||
mass: 5.9742×1024
|
||||
density: 5.515
|
||||
known_moons: 1
|
||||
mars:
|
||||
mean_distance_sun_km: 227,936,640
|
||||
equatorial_radius: 3,397.00
|
||||
surface_area: 75,000,000
|
||||
volume: 6.083×1010
|
||||
mass: 3.302×1023
|
||||
density: 5.43
|
||||
known_moons: 0
|
||||
jupiter:
|
||||
mean_distance_sun_km: 57,909,175
|
||||
equatorial_radius: 2,439.64
|
||||
surface_area: 75,000,000
|
||||
volume: 6.083×1010
|
||||
mass: 3.302×1023
|
||||
density: 5.43
|
||||
known_moons: 0
|
||||
saturn:
|
||||
mean_distance_sun_km: 57,909,175
|
||||
equatorial_radius: 2,439.64
|
||||
surface_area: 75,000,000
|
||||
volume: 6.083×1010
|
||||
mass: 3.302×1023
|
||||
density: 5.43
|
||||
known_moons: 0
|
||||
uranus:
|
||||
mean_distance_sun_km: 57,909,175
|
||||
equatorial_radius: 2,439.64
|
||||
surface_area: 75,000,000
|
||||
volume: 6.083×1010
|
||||
mass: 3.302×1023
|
||||
density: 5.43
|
||||
known_moons: 0
|
||||
neptune:
|
||||
mean_distance_sun_km: 57,909,175
|
||||
equatorial_radius: 2,439.64
|
||||
surface_area: 75,000,000
|
||||
volume: 6.083×1010
|
||||
mass: 3.302×1023
|
||||
density: 5.43
|
||||
known_moons: 0
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
use DDG::Test::Goodie;
|
||||
|
||||
zci answer_type => "planets";
|
||||
zci is_cached => 1;
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw( DDG::Goodie::Planets )],
|
||||
# At a minimum, be sure to include tests for all:
|
||||
# - primary_example_queries
|
||||
# - secondary_example_queries
|
||||
'example query' => test_zci('query'),
|
||||
# Try to include some examples of queries on which it might
|
||||
# appear that your answer will trigger, but does not.
|
||||
'bad example query' => undef,
|
||||
);
|
||||
|
||||
done_testing;
|
Loading…
Reference in New Issue