package GO::Object::ToolPreview; =head1 NAME GO::Object::ToolPreview - represents a tool on the preview page of the GO tools tool. =cut use strict; use Data::Dumper; use Exporter; use lib '/Users/gwg/go/scratch/tools'; use vars qw(@ISA); use base qw(GO::Object::Tool); #GO::MiniTests); use GO::Object::Developer; use GO::Object::URL; use GO::TestSet qw(dfv_test); sub _specification { my $self = shift; my @tool_spec = $self->SUPER::_specification; my %tool_h = ( @tool_spec ); my $extra = { # developer is a free text field # should contain an URL "developer" => { test => [ dfv_test('is_a_string_p', { this => 1 }), qr/\bhttp:\/\//ism, ], }, "license" => { dependencies => { "other_license" => [ 'other_license_text' ], } }, "other_license_text" => { human_name => 'License type', # dependencies => { # # license must be 'other_license' # }, }, "feature" => { dependencies => { 'other_feature' => [ 'other_feature_text' ], }, } "other_feature_text" => { human_name => 'Other tool features', # dependencies => { # # 'other_feature' must be ticked # }, }, # publication is a free text field # "publication" => { # test => dfv_test('is_a_string_p', { this => 1 }), # }, "comments" => { human_name => 'Any other information or comments', test => dfv_test('is_a_string_p', { this => 1 }), # allow_multiple => 1, }, }; foreach my $p (keys %$extra) { if ($tool_h{$p}) { foreach my $x (keys %{$extra->{$p}}) { $tool_h{$p}{$x} = $extra->{$p}{$x}; } } else { $tool_h{$p} = $extra->{$p}; } } my @field_order = qw(name url email developer license other_license_text description is_online_tool is_standalone_tool compatible_os feature other_feature_text publication go_data_used go_data_update_frequency is_open_source comments); return ( map { ( $_, $tool_h{$_} ) } @field_order ); } 1;