File Coverage

lib/UR/Namespace/Command/Test/Eval.pm
Criterion Covered Total %
statement 9 18 50.0
branch 0 2 0.0
condition n/a
subroutine 3 7 42.8
pod 0 3 0.0
total 12 30 40.0


line stmt bran cond sub pod time code
1              
2             package UR::Namespace::Command::Test::Eval;
3              
4 1     1   22 use strict;
  1         2  
  1         23  
5 1     1   4 use warnings;
  1         1  
  1         19  
6 1     1   4 use UR;
  1         1  
  1         4  
7             our $VERSION = "0.46"; # UR $VERSION;
8              
9             UR::Object::Type->define(
10             class_name => __PACKAGE__,
11             is => 'UR::Namespace::Command::Base',
12             has => [
13             bare_args => {
14             is_optional => 1,
15             is_many => 1,
16             shell_args_position => 1
17             }
18             ]
19             );
20              
21              
22             sub help_brief {
23 0     0 0   "Evaluate a string of Perl source";
24             }
25              
26             sub help_synopsis {
27 0     0 0   return <<'EOS';
28             ur test eval 'print "hello\n"'
29             ur test eval 'print "hello\n"' 'print "goodbye\n"'
30             ur test eval 'print "Testing in the " . \$self->namespace_name . " namespace.\n"'
31             EOS
32             }
33              
34             sub help_detail {
35 0     0 0   return <
36             This command is for testing and debugging. It simply eval's the Perl
37             source supplied on the command line, after using the current namespace.
38              
39             A \$self object is in scope representing the current context.
40             EOS
41             }
42              
43             sub execute {
44 0     0     my $self = shift;
45 0           for my $src ($self->bare_args) {
46 0           eval "use Data::Dumper; use YAML; no strict; no warnings; \n" . $src;
47 0 0         if ($@) {
48 0           print STDERR "EXCEPTION:\n$@";
49             }
50             }
51 0           return 1;
52             }
53              
54             1;