line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Gnats::Field; |
2
|
40
|
|
|
40
|
|
183
|
use strictures; |
|
40
|
|
|
|
|
60
|
|
|
40
|
|
|
|
|
195
|
|
3
|
|
|
|
|
|
|
BEGIN { |
4
|
40
|
|
|
40
|
|
2957
|
$Net::Gnats::Field::VERSION = '0.20'; |
5
|
|
|
|
|
|
|
} |
6
|
40
|
|
|
40
|
|
185
|
use vars qw($VERSION); |
|
40
|
|
|
|
|
56
|
|
|
40
|
|
|
|
|
1312
|
|
7
|
|
|
|
|
|
|
|
8
|
40
|
|
|
40
|
|
14745
|
use Net::Gnats::FieldInstance; |
|
40
|
|
|
|
|
90
|
|
|
40
|
|
|
|
|
19501
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Net::Gnats::Field |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Base class for a PR's metadata |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
In a given session, for a given field, this should have to be run once |
19
|
|
|
|
|
|
|
and stashed somewhere for reuse. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 EXAMPLES |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Construct an empty field |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $f = Net::Gnats::Field->new; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Initialize from server |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $f = Net::Gnats::Field->new( name => 'myfield' )->initialize($session); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Manual initialization |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $f = Net::Gnats::Field |
34
|
|
|
|
|
|
|
->new( name => 'myfield', |
35
|
|
|
|
|
|
|
description => 'description', |
36
|
|
|
|
|
|
|
type => type, |
37
|
|
|
|
|
|
|
default => default, |
38
|
|
|
|
|
|
|
flags => flags, |
39
|
|
|
|
|
|
|
validators => validators ); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
44
|
914
|
|
|
914
|
0
|
1231
|
my ( $class, %o ) = @_; |
45
|
914
|
50
|
|
|
|
3575
|
return bless {}, $class if not %o; |
46
|
0
|
|
|
|
|
0
|
return bless \%o, $class; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub change_reason_field { |
50
|
4
|
|
|
4
|
0
|
6
|
my ($self) = @_; |
51
|
4
|
50
|
|
|
|
9
|
return undef if not $self->requires_change_reason; |
52
|
4
|
100
|
|
|
|
14
|
$self->_create_change_reason if not defined $self->{change_reason}; |
53
|
4
|
|
|
|
|
11
|
return $self->{change_reason}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub default { |
57
|
1024
|
|
|
1024
|
0
|
1168
|
my ( $self, $value ) = @_; |
58
|
1024
|
100
|
|
|
|
2001
|
$self->{default} = $value if defined $value; |
59
|
1024
|
|
|
|
|
1520
|
$self->{default}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub description { |
63
|
918
|
|
|
918
|
0
|
987
|
my ( $self, $value ) = @_; |
64
|
918
|
100
|
|
|
|
1985
|
$self->{description} = $value if defined $value; |
65
|
918
|
|
|
|
|
1283
|
$self->{description}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub flags { |
69
|
945
|
|
|
945
|
0
|
930
|
my ( $self, $value ) = @_; |
70
|
945
|
100
|
|
|
|
1903
|
$self->{flags} = $value if defined $value; |
71
|
945
|
|
|
|
|
1377
|
$self->{flags}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub name { |
75
|
970
|
|
|
970
|
0
|
950
|
my ( $self, $value ) = @_; |
76
|
970
|
100
|
|
|
|
2301
|
$self->{name} = $value if defined $value; |
77
|
970
|
|
|
|
|
1424
|
$self->{name}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub requires_change_reason { |
81
|
31
|
100
|
|
31
|
0
|
57
|
return 1 if shift->flags =~ /requireChangeReason/; |
82
|
19
|
|
|
|
|
46
|
return 0; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub type { |
86
|
977
|
|
|
977
|
0
|
978
|
my ( $self, $value ) = @_; |
87
|
977
|
100
|
|
|
|
1943
|
$self->{type} = $value if defined $value; |
88
|
977
|
|
|
|
|
1467
|
$self->{type}; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub validators { |
92
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $value ) = @_; |
93
|
0
|
0
|
|
|
|
0
|
$self->{validators} = $value if defined $value; |
94
|
0
|
|
|
|
|
0
|
$self->{validators}; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 METHODS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 initialize |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub initialize { |
104
|
0
|
|
|
0
|
1
|
0
|
my ( $self ) = @_; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 instance |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Creates an instance of this meta field. Represents a literal field in a PR. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub instance { |
114
|
60
|
|
|
60
|
1
|
126
|
my ( $self, %options ) = @_; |
115
|
60
|
50
|
|
|
|
121
|
my $name = defined $options{for_name} ? $options{for_name} : $self->name; |
116
|
60
|
|
|
|
|
146
|
my $fi = Net::Gnats::FieldInstance->new( schema => $self, name => $name ); |
117
|
60
|
50
|
|
|
|
115
|
$fi->value( $options{value} ) if defined $options{value}; |
118
|
60
|
|
|
|
|
127
|
return $fi; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _create_change_reason { |
122
|
2
|
|
|
2
|
|
3
|
my ($self) = @_; |
123
|
2
|
|
|
|
|
6
|
my $f = Net::Gnats::Field->new; |
124
|
2
|
|
|
|
|
5
|
$f->name($self->name . '-Changed-Why'); |
125
|
2
|
|
|
|
|
5
|
$f->description($self->description . ' - Reason for Change'); |
126
|
2
|
|
|
|
|
4
|
$f->type('multiText'); |
127
|
2
|
|
|
|
|
5
|
$self->{change_reason} = $f; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |