File Coverage

blib/lib/App/Sqitch/Plan/Pragma.pm
Criterion Covered Total %
statement 26 27 96.3
branch 3 4 75.0
condition 4 7 57.1
subroutine 10 10 100.0
pod 4 5 80.0
total 47 53 88.6


line stmt bran cond sub pod time code
1              
2             use 5.010;
3 50     50   881 use utf8;
  50         159  
4 50     50   289 use namespace::autoclean;
  50         96  
  50         274  
5 50     50   1107 use Moo;
  50         93  
  50         306  
6 50     50   2993 use App::Sqitch::Types qw(Str);
  50         112  
  50         336  
7 50     50   15060 extends 'App::Sqitch::Plan::Line';
  50         113  
  50         442  
8              
9             our $VERSION = 'v1.3.0'; # VERSION
10              
11             has value => (
12             is => 'ro',
13             isa => Str,
14             );
15              
16             has hspace => (
17             is => 'ro',
18             isa => Str,
19             default => '',
20             );
21              
22             my $class = shift;
23             my $p = @_ == 1 && ref $_[0] ? { %{ +shift } } : { @_ };
24 725     725 0 176140 $p->{value} =~ s/\s+$// if $p->{value};
25 725 50 33     7683 $p->{op} //= '';
  0         0  
26 725 100       3206 return $p;
27 725   50     3610 }
28 725         10524  
29             my $self = shift;
30             return '%' . $self->hspace . $self->name;
31             }
32 105     105 1 1321  
33 105         608 shift->value // '';
34             }
35              
36             my $self = shift;
37 105   100 105 1 753 join '', $self->format_name, $self->format_operator, $self->format_value;
38             }
39              
40             my $self = shift;
41 104     104 1 165 return $self->lspace
42 104         234 . $self->format_content
43             . $self->rspace
44             . $self->format_note;
45             }
46 104     104 1 1593  
47 104         460 1;
48              
49              
50             =head1 Name
51              
52             App::Sqitch::Plan::Pragma.pm - Sqitch deployment plan blank line
53              
54             =head1 Synopsis
55              
56             my $plan = App::Sqitch::Plan->new( sqitch => $sqitch );
57             for my $line ($plan->lines) {
58             say $line->as_string;
59             }
60              
61             =head1 Description
62              
63             An App::Sqitch::Plan::Pragma represents a plan file pragma. See
64             L<App::Sqitch::Plan::Line> for its interface.
65              
66             =head1 Interface
67              
68             In addition to the interface inherited from L<App::Sqitch::Plan::Line>,
69             App::Sqitch::Plan::Line::Pragma adds a few methods of its own.
70              
71             =head2 Accessors
72              
73             =head3 C<value>
74              
75             The value of the pragma.
76              
77             =head3 C<op>
78              
79             The operator, including surrounding white space.
80              
81             =head3 C<hspace>
82              
83             The horizontal space between the pragma and its value.
84              
85             =head2 Instance Methods
86              
87             =head3 C<format_value>
88              
89             Formats the value for output. If there is no value, an empty string is
90             returned. Otherwise the value is returned as-is.
91              
92             =head1 Author
93              
94             David E. Wheeler <david@justatheory.com>
95              
96             =head1 License
97              
98             Copyright (c) 2012-2022 iovation Inc., David E. Wheeler
99              
100             Permission is hereby granted, free of charge, to any person obtaining a copy
101             of this software and associated documentation files (the "Software"), to deal
102             in the Software without restriction, including without limitation the rights
103             to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
104             copies of the Software, and to permit persons to whom the Software is
105             furnished to do so, subject to the following conditions:
106              
107             The above copyright notice and this permission notice shall be included in all
108             copies or substantial portions of the Software.
109              
110             THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
111             IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
112             FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
113             AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
114             LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
115             OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
116             SOFTWARE.
117              
118             =cut