File Coverage

lib/UR/Namespace/Command/Old/Info.pm
Criterion Covered Total %
statement 10 39 25.6
branch 0 12 0.0
condition 0 6 0.0
subroutine 4 6 66.6
pod 0 2 0.0
total 14 65 21.5


line stmt bran cond sub pod time code
1             package UR::Namespace::Command::Old::Info;
2              
3 1     1   22 use strict;
  1         2  
  1         26  
4 1     1   3 use warnings;
  1         1  
  1         20  
5 1     1   4 use UR;
  1         1  
  1         6  
6             our $VERSION = "0.46"; # UR $VERSION;
7              
8             UR::Object::Type->define(
9             class_name => __PACKAGE__,
10             is => 'UR::Namespace::Command::Base',
11             has => [
12             subject => {
13             is_optional => 1,
14             is_many => 1,
15             shell_args_position => 1
16             }
17             ]
18             );
19              
20              
21             sub help_brief {
22 0     0 0 0 "Outputs description(s) of UR entities such as classes and tables to stdout";
23             }
24              
25 2     2 0 5 sub is_sub_command_delegator { 0;}
26              
27              
28             sub execute {
29 0     0     my($self, $params) = @_;
30              
31 0           my $namespace = $self->namespace_name;
32             # FIXME why dosen't require work here?
33 0           eval "use $namespace";
34 0 0         if ($@) {
35 0           $self->error_message("Failed to load module for $namespace: $@");
36 0           return;
37             }
38              
39             # Loop through each command line parameter and see what kind of thing it is
40             # create a view and display it
41 0           my @class_aspects = qw( );
42 0           my @table_aspects = qw( );
43 0           my %already_printed;
44              
45             my %views;
46 0           foreach my $item ( $self->subject ) {
47 0           my @meta_objs = ();
48              
49 0 0 0       if ($item eq $namespace or $item =~ m/::/) {
50             # Looks like a class name?
51 0           my $class_meta = eval { UR::Object::Type->get(class_name => $item)};
  0            
52 0 0         push(@meta_objs, $class_meta) if $class_meta;
53              
54             } else {
55              
56 0           push @meta_objs, ( UR::DataSource::RDBMS::Table->get(table_name => $item, namespace => $namespace) );
57 0           push @meta_objs, ( UR::DataSource::RDBMS::Table->get(table_name => uc($item), namespace => $namespace) );
58 0           push @meta_objs, ( UR::DataSource::RDBMS::Table->get(table_name => lc($item), namespace => $namespace) );
59              
60 0 0         push @meta_objs, map { ( $_ and UR::DataSource::RDBMS::Table->get(table_name => $_->table_name, namespace => $namespace) ) }
  0            
61             ( UR::DataSource::RDBMS::TableColumn->get(column_name => $item, namespace => $namespace),
62             UR::DataSource::RDBMS::TableColumn->get(column_name => uc($item), namespace => $namespace),
63             UR::DataSource::RDBMS::TableColumn->get(column_name => lc($item), namespace => $namespace)
64             );
65              
66             }
67            
68             ## A property search requires loading all the classes first, at least until class
69             ## metadata is in the meta DB
70             # Something is making this die, so I'll comment it out for now
71             #$namespace->get_material_class_names;
72             #my @properties = UR::Object::Property->get(property_name => $item);
73             #next unless @properties;
74             #push @meta_objs, UR::Object::Type->get(class_name => [ map { $_->class_name }
75             # @properties ]);
76              
77 0           foreach my $obj ( @meta_objs ) {
78 0 0         next unless $obj;
79 0 0         next if ($already_printed{$obj}++);
80              
81 0   0       $views{$obj->class} ||= UR::Object::View->create(
82             subject_class_name => $obj->class,
83             perspective => 'default',
84             toolkit => 'text',
85             );
86            
87              
88 0           my $view = $views{$obj->class};
89 0           $view->subject($obj);
90 0           $view->show();
91 0           print "\n";
92             }
93            
94             }
95             }
96              
97            
98             1;