File Coverage

lib/Ubic/Service.pm
Criterion Covered Total %
statement 28 42 66.6
branch 6 6 100.0
condition n/a
subroutine 9 19 47.3
pod 15 15 100.0
total 58 82 70.7


line stmt bran cond sub pod time code
1             package Ubic::Service;
2             $Ubic::Service::VERSION = '1.58_01'; # TRIAL
3 28     28   10468 use strict;
  28         51  
  28         872  
4 28     28   125 use warnings;
  28         30  
  28         1019  
5              
6 28     28   7846 use Ubic::Settings;
  28         59  
  28         992  
7              
8             # ABSTRACT: interface and the base class for any ubic service
9              
10              
11 28     28   669 use Ubic::Result qw(result);
  28         45  
  28         13265  
12              
13             sub start {
14 0     0 1 0 die "not implemented";
15             }
16              
17             sub stop {
18 0     0 1 0 die "not implemented";
19             }
20              
21             sub status {
22 0     0 1 0 my ($self) = @_;
23 0         0 die "not implemented";
24             }
25              
26             sub reload {
27 0     0 1 0 my ($self) = @_;
28 0         0 return result('unknown', 'not implemented');
29             }
30              
31             sub port {
32 0     0 1 0 my ($self) = @_;
33 0         0 return; # by default, service has no port
34             }
35              
36             sub user {
37 101     101 1 128 my $self = shift;
38 101         641 return Ubic::Settings->default_user;
39             }
40              
41             sub group {
42 101     101 1 281 return ();
43             }
44              
45             sub check_period {
46 0     0 1 0 my ($self) = @_;
47 0         0 return 60;
48             }
49              
50             sub check_timeout {
51 0     0 1 0 return 60;
52             }
53              
54             sub custom_commands {
55 0     0 1 0 return ();
56             }
57              
58             sub do_custom_command {
59 0     0 1 0 die "No such command";
60             }
61              
62             sub name($;$) {
63 368     368 1 1674 my ($self, $name) = @_;
64 368 100       784 if (defined $name) {
65 46         226 $self->{name} = $name;
66             }
67             else {
68 322         1934 return $self->{name};
69             }
70             }
71              
72             sub full_name($) {
73 258     258 1 555 my ($self) = @_;
74 258         845 my $parent_name = $self->parent_name;
75 258 100       706 if (defined $parent_name) {
76 15         52 return $parent_name.".".$self->name;
77             }
78             else {
79 243         931 return $self->name;
80             }
81             }
82              
83             sub parent_name($;$) {
84 311     311 1 476 my ($self, $name) = @_;
85 311 100       944 if (defined $name) {
86 12         34 $self->{parent_name} = $name;
87             }
88             else {
89 299         843 return $self->{parent_name};
90             }
91             }
92              
93             sub auto_start($) {
94 0     0 1   return 0;
95             }
96              
97              
98             1;
99              
100             __END__