File: Code.pm

package info (click to toggle)
libur-perl 0.470%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,184 kB
  • sloc: perl: 61,813; javascript: 255; xml: 108; sh: 13; makefile: 9
file content (46 lines) | stat: -rw-r--r-- 1,455 bytes parent folder | download | duplicates (3)
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
36
37
38
39
40
41
42
43
44
45
46

package UR::DataSource::Code;

use strict;
use warnings;
require UR;
our $VERSION = "0.47"; # UR $VERSION;
use File::Copy qw//;
##- use UR;

UR::Object::Type->define(
    class_name => 'UR::DataSource::Code',
    is => ['UR::DataSource::SQLite'],
);

sub server { 
    my $self = shift->_singleton_object();
    my $path = $self->__meta__->module_path;
    $path =~ s/\.pm$/.db/ or Carp::confess("Bad module path for resolving server!");
    unless (-e $path) {
        # initialize a new database from the one in the base class
        # should this be moved to connect time?
        my $template_database_file = UR::DataSource::Code->server();
        if ($self->class eq __PACKAGE__) {
            Carp::confess("Missing template database file: $path!");
        }
        unless (-e $template_database_file) {
            Carp::confess("Missing template database file: $path!  Cannot initialize database for " . $self->class);
        }
        unless(File::Copy::copy($template_database_file,$path)) {
            Carp::confess("Error copying $path to $template_database_file to initialize database!");
        }
        unless(-e $path) {
            Carp::confess("File $path not found after copy from $template_database_file. Cannot initialize database!");
        }
    }
    return $path;
}

sub resolve_class_name_for_table_name_fixups {
    my $self = shift->_singleton_object;
    print "fixup @_";
    return $self->class . "::", @_;
}

1;