File Coverage

lib/UR/Namespace/Command/Update/RewriteClassHeader.pm
Criterion Covered Total %
statement 6 20 30.0
branch 0 6 0.0
condition 0 3 0.0
subroutine 2 6 33.3
pod 0 4 0.0
total 8 39 20.5


line stmt bran cond sub pod time code
1              
2             package UR::Namespace::Command::Update::RewriteClassHeader;
3              
4 1     1   22 use strict;
  1         2  
  1         23  
5 1     1   3 use warnings;
  1         1  
  1         205  
6              
7             require UR;
8             our $VERSION = "0.46"; # UR $VERSION;
9              
10             UR::Object::Type->define(
11             class_name => __PACKAGE__,
12             is => 'UR::Namespace::Command::RunsOnModulesInTree',
13             has => [
14             force => { is => 'Boolean', is_optional => 1 },
15             ]
16             );
17              
18             sub params_as_getopt_specification
19             {
20 0     0 0   my $self = shift;
21 0           my @spec = $self->SUPER::params_as_getopt_specification(@_);
22 0           return (@spec, "force!");
23             }
24              
25             sub help_brief
26             {
27 0     0 0   "Update::RewriteClassHeaders class descriptions headers to normalize manual changes."
28             }
29              
30             sub help_detail
31             {
32 0     0 0   qq|
33              
34             UR classes have a header at the top which defines the class in terms of its metadata.
35             This command replaces that text in the source module with a fresh copy.
36              
37             It is most useful to fix formatting problems, since the data from which the new
38             version is made is the data supplied by the old version of the file.
39              
40             It's somewhat of a "perltidy" for the module header.
41              
42             |
43             }
44              
45             sub for_each_class_object
46             {
47             #$DB::single = 1;
48 0     0 0   my $self = shift;
49 0           my $class = shift;
50 0           my $old = $class->module_header_source;
51 0           my $new = $class->resolve_module_header_source;
52 0 0 0       if ($self->force or ($old ne $new)) {
53 0           print "Updating:\t", $class->module_base_name, "\n";
54 0 0         $class->rewrite_module_header and return 1;
55            
56 0 0         print STDERR "Error rewriting header!" and return 0;
57            
58             }
59             else {
60             #print $class->class_name . " has no source changes. "
61             # . "Ignoring " . $class->module_base_name . ".\n";
62 0           return 1;
63             }
64             }
65              
66             1;
67             #$Header$