« blib/lib/UR/Namespace/Command/Show/Schema.pm
↑ Summary
blib/lib/UR/Namespace/Command/Test/Compile.pm »
| 1 | package UR::Namespace::Command::Test::Callcount::List; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use UR; | ||
| 7 | our $VERSION = "0.46"; # UR $VERSION; | ||
| 8 | |||
| 9 | # Transient class that represents the file as a datasource | ||
| 10 | our $TheFile = '/dev/null'; # This will be filled in during create() below | ||
| 11 | UR::DataSource::FileMux->create( | ||
| 12 | id => 'Test::Callcount::List::DataSource', | ||
| 13 | column_order => ['count','subname','subloc','callers'], | ||
| 14 | delimiter => "\t", | ||
| 15 | file_resolver => sub { return $TheFile }, | ||
| 16 | required_for_get => [], | ||
| 17 | constant_values => [], | ||
| 18 | ); | ||
| 19 | |||
| 20 | #class Test::Callcount::List::DataSource { | ||
| 21 | # is => 'UR::DataSource::File', | ||
| 22 | # column_order => ['count','subname','subloc','callers'], | ||
| 23 | # delimiter => "\t", | ||
| 24 | #}; | ||
| 25 | |||
| 26 | # Transient class that represents the data in the callcount files | ||
| 27 | class Test::Callcount::List::Items { | ||
| 28 | id_by => 'subname', | ||
| 29 | has => [ | ||
| 30 | count => { is => 'Integer' }, | ||
| 31 | subname => { is => 'String' }, | ||
| 32 | subloc => { is => 'String' }, | ||
| 33 | callers => { is => 'String' }, | ||
| 34 | ], | ||
| 35 | data_source => 'Test::Callcount::List::DataSource', | ||
| 36 | }; | ||
| 37 | |||
| 38 | # Class for this command | ||
| 39 | class UR::Namespace::Command::Test::Callcount::List { | ||
| 40 | is => 'UR::Object::Command::List', | ||
| 41 | has => [ | ||
| 42 | file => { is => 'String', doc => 'Specify the .callcount file', default_value => '/dev/null' }, | ||
| 43 | subject_class_name => { is_constant => 1, value => 'Test::Callcount::List::Items' }, | ||
| 44 | show => { default_value => 'count,subname,subloc,callers' }, | ||
| 45 | # filter => { default_value => '' }, | ||
| 46 | |||
| 47 | ], | ||
| 48 | doc => 'Filter and list Callcount items', | ||
| 49 | }; | ||
| 50 | |||
| 51 | |||
| 52 | sub _resolve_boolexpr { | ||
| 53 | my $self = shift; | ||
| 54 | |||
| 55 | my $filename = $self->file; | ||
| 56 | unless (-r $filename ) { | ||
| 57 | $self->error_message("File $filename does not exist or is not readable"); | ||
| 58 | return; | ||
| 59 | } | ||
| 60 | $TheFile = $filename; | ||
| 61 | |||
| 62 | $self->SUPER::_resolve_boolexpr(@_); | ||
| 63 | } | ||
| 64 | |||
| 65 | |||
| 66 | 1; |