line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Gnats::Field; |
2
|
40
|
|
|
40
|
|
205
|
use strictures; |
|
40
|
|
|
|
|
76
|
|
|
40
|
|
|
|
|
219
|
|
3
|
|
|
|
|
|
|
BEGIN { |
4
|
40
|
|
|
40
|
|
8880
|
$Net::Gnats::Field::VERSION = '0.22'; |
5
|
|
|
|
|
|
|
} |
6
|
40
|
|
|
40
|
|
203
|
use vars qw($VERSION); |
|
40
|
|
|
|
|
77
|
|
|
40
|
|
|
|
|
1355
|
|
7
|
|
|
|
|
|
|
|
8
|
40
|
|
|
40
|
|
20566
|
use Net::Gnats::FieldInstance; |
|
40
|
|
|
|
|
114
|
|
|
40
|
|
|
|
|
24849
|
|
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
|
915
|
|
|
915
|
0
|
1640
|
my ( $class, %o ) = @_; |
45
|
915
|
50
|
|
|
|
3803
|
return bless {}, $class if not %o; |
46
|
0
|
|
|
|
|
0
|
return bless \%o, $class; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub change_reason_field { |
50
|
5
|
|
|
5
|
0
|
11
|
my ( $self, $name ) = @_; |
51
|
5
|
50
|
|
|
|
13
|
return undef if not $self->requires_change_reason; |
52
|
5
|
100
|
|
|
|
25
|
$self->_create_change_reason($name) if not defined $self->{change_reason}; |
53
|
5
|
|
|
|
|
19
|
return $self->{change_reason}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub default { |
57
|
1042
|
|
|
1042
|
0
|
1553
|
my ( $self, $value ) = @_; |
58
|
1042
|
100
|
|
|
|
2892
|
$self->{default} = $value if defined $value; |
59
|
1042
|
|
|
|
|
2318
|
$self->{default}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub description { |
63
|
920
|
|
|
920
|
0
|
1372
|
my ( $self, $value ) = @_; |
64
|
920
|
100
|
|
|
|
2494
|
$self->{description} = $value if defined $value; |
65
|
920
|
|
|
|
|
1964
|
$self->{description}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub flags { |
69
|
948
|
|
|
948
|
0
|
1406
|
my ( $self, $value ) = @_; |
70
|
948
|
100
|
|
|
|
2603
|
$self->{flags} = $value if defined $value; |
71
|
948
|
|
|
|
|
2032
|
$self->{flags}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub name { |
75
|
970
|
|
|
970
|
0
|
1461
|
my ( $self, $value ) = @_; |
76
|
970
|
100
|
|
|
|
3047
|
$self->{name} = $value if defined $value; |
77
|
970
|
|
|
|
|
2141
|
$self->{name}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub requires_change_reason { |
81
|
34
|
100
|
|
34
|
0
|
77
|
return 1 if shift->flags =~ /requireChangeReason/; |
82
|
19
|
|
|
|
|
68
|
return 0; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub type { |
86
|
978
|
|
|
978
|
0
|
1519
|
my ( $self, $value ) = @_; |
87
|
978
|
100
|
|
|
|
2736
|
$self->{type} = $value if defined $value; |
88
|
978
|
|
|
|
|
2166
|
$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
|
77
|
|
|
77
|
1
|
186
|
my ( $self, %options ) = @_; |
115
|
77
|
50
|
|
|
|
173
|
my $name = defined $options{for_name} ? $options{for_name} : $self->name; |
116
|
77
|
|
|
|
|
229
|
my $fi = Net::Gnats::FieldInstance->new( schema => $self, name => $name ); |
117
|
77
|
50
|
|
|
|
201
|
$fi->value( $options{value} ) if defined $options{value}; |
118
|
77
|
|
|
|
|
232
|
return $fi; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _create_change_reason { |
122
|
3
|
|
|
3
|
|
5
|
my ($self, $name) = @_; |
123
|
3
|
|
|
|
|
10
|
my $f = Net::Gnats::Field->new; |
124
|
3
|
|
|
|
|
19
|
$f->name($name . '-Changed-Why'); |
125
|
3
|
|
|
|
|
12
|
$f->description($self->description . ' - Reason for Change'); |
126
|
3
|
|
|
|
|
11
|
$f->type('multiText'); |
127
|
3
|
|
|
|
|
9
|
$self->{change_reason} = $f; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |