File: make-subclass-tests.pl

package info (click to toggle)
librose-db-perl 0.786-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 840 kB
  • sloc: perl: 12,269; makefile: 9
file content (35 lines) | stat: -rwxr-xr-x 734 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl

use strict;

use FindBin qw($Bin);

chdir($Bin) or die "chdir($Bin) - $!";

opendir(my $dir, '.') or die "Could not opendir(.) - $!";

while(my $file = readdir($dir))
{
  next  if($file !~ /\.t$/ || $file =~ /fork-|subclass|warning|pod|storable|pk-columns|no-registry|setup|db_cache/);

  my $new_file = "subclass-$file";

  open(my $old, $file) or die "Could not open $file - $!";
  open(my $new, ">$new_file") or die "Could not create $new_file - $!";

  while(<$old>)
  {
    # I know, I know...
    unless(/^\s*use_ok|Rose::DB::(\w+)|->isa\(/)
    {
      s/\bRose::DB([^:A-Za-z0-9_])/My::DB2$1/g;
    }

    print $new $_;
  }

  close($old);
  close($new) or die "Could not write $new - $!";
}

closedir($dir);