line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UR::Namespace::Command::Define::Datasource::Sqlite; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1172
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
59
|
|
4
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
54
|
|
5
|
2
|
|
|
2
|
|
8
|
use UR; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
13
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.46"; # UR $VERSION; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
8
|
use IO::File; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
806
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
UR::Object::Type->define( |
11
|
|
|
|
|
|
|
class_name => __PACKAGE__, |
12
|
|
|
|
|
|
|
is => [ 'UR::Namespace::Command::Define::Datasource::Rdbms' ], |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub help_brief { |
16
|
0
|
|
|
0
|
0
|
0
|
"Add a SQLite data source to the current namespace." |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub help_synopsis { |
20
|
|
|
|
|
|
|
return <
|
21
|
|
|
|
|
|
|
cd Acme |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
ur define datasource sqlite --dsname MyDB1 |
24
|
|
|
|
|
|
|
# writes Acme::DataSource::MyDB1 to work with Acme/DataSource/MyDB1.sqlite3 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
ur define datasource sqlite --dsname MyDB2 --server /var/lib/acmeapp/mydb2.sqlite3 |
27
|
|
|
|
|
|
|
# writes Acme::DataSource::MyDB2 to work with the specified sqlite file |
28
|
|
|
|
|
|
|
EOS |
29
|
0
|
|
|
0
|
0
|
0
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _data_source_sub_class_name { |
32
|
2
|
|
|
2
|
|
5
|
"UR::DataSource::SQLite" |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub server { |
36
|
10
|
|
|
10
|
0
|
15
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
10
|
|
|
|
|
81
|
my $super_server = $self->super_can('server'); |
39
|
10
|
50
|
|
|
|
19
|
if (@_) { |
40
|
|
|
|
|
|
|
# unusual case, setting the server |
41
|
0
|
|
|
|
|
0
|
return $super_server($self,@_); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
10
|
|
|
|
|
27
|
my $server = $super_server->($self); |
45
|
10
|
100
|
|
|
|
22
|
unless ($server) { |
46
|
2
|
|
|
|
|
36
|
$server = $self->data_source_module_pathname(); |
47
|
2
|
|
|
|
|
10
|
$server =~ s/\.pm$/.sqlite3/; |
48
|
2
|
|
|
|
|
6
|
$super_server->($self,$server); |
49
|
|
|
|
|
|
|
} |
50
|
10
|
|
|
|
|
25
|
return $server; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _post_module_written { |
54
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Create a new, empty DB if it dosen't exist yet |
57
|
2
|
|
|
|
|
5
|
my $pathname = $self->server; |
58
|
2
|
|
|
|
|
5
|
$pathname =~ s/\.pm$/.sqlite3/; |
59
|
2
|
100
|
|
|
|
42
|
IO::File->new($pathname, O_WRONLY | O_CREAT) unless (-f $pathname); |
60
|
2
|
|
|
|
|
105
|
$self->status_message("A $pathname (empty database schame)"); |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
5
|
return 1; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|