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   855 use utf8;
  50         158  
4 50     50   257 use namespace::autoclean;
  50         107  
  50         265  
5 50     50   999 use Moo;
  50         104  
  50         289  
6 50     50   2886 use App::Sqitch::Types qw(Str);
  50         132  
  50         314  
7 50     50   15021 extends 'App::Sqitch::Plan::Line';
  50         124  
  50         451  
8              
9             our $VERSION = 'v1.3.1'; # 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 731     731 0 173167 $p->{value} =~ s/\s+$// if $p->{value};
25 731 50 33     7472 $p->{op} //= '';
  0         0  
26 731 100       2918 return $p;
27 731   50     3450 }
28 731         10778  
29             my $self = shift;
30             return '%' . $self->hspace . $self->name;
31             }
32 105     105 1 950  
33 105         600 shift->value // '';
34             }
35              
36             my $self = shift;
37 105   100 105 1 704 join '', $self->format_name, $self->format_operator, $self->format_value;
38             }
39              
40             my $self = shift;
41 104     104 1 149 return $self->lspace
42 104         250 . $self->format_content
43             . $self->rspace
44             . $self->format_note;
45             }
46 104     104 1 1492  
47 104         428 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