Name
App::Sqitch::Plan::Line - Sqitch deployment plan line
Synopsis
my $plan = App::Sqitch::Plan->new( sqitch => $sqitch );
for my $line ($plan->lines) {
say $line->as_string;
}
Description
An App::Sqitch::Plan::Line represents a single line from a Sqitch plan file. Each object managed by an App::Sqitch::Plan object is derived from this class. This is actually an abstract base class. See App::Sqitch::Plan::Change, App::Sqitch::Plan::Tag, and App::Sqitch::Plan::Blank for concrete subclasses.
Interface
Constructors
new
my $plan = App::Sqitch::Plan::Line->new(%params);
Instantiates and returns a App::Sqitch::Plan::Line object. Parameters:
plan
-
The App::Sqitch::Plan object with which the line is associated.
name
-
The name of the line. Should be empty for blank lines. Tags names should not include the leading
@
. lspace
-
The white space from the beginning of the line, if any.
lopspace
-
The white space to the left of the operator, if any.
operator
-
An operator, if any.
ropspace
-
The white space to the right of the operator, if any.
rspace
-
The white space after the name until the end of the line or the start of a note.
note
-
A note. Does not include the leading
#
, but does include any white space immediate after the#
when the plan file is parsed.
Accessors
plan
my $plan = $line->plan;
Returns the plan object with which the line object is associated.
name
my $name = $line->name;
Returns the name of the line. Returns an empty string if there is no name.
lspace
my $lspace = $line->lspace.
Returns the white space from the beginning of the line, if any.
rspace
my $rspace = $line->rspace.
Returns the white space after the name until the end of the line or the start of a note.
note
my $note = $line->note.
Returns the note. Does not include the leading #
, but does include any white space immediate after the #
when the plan file is parsed. Returns the empty string if there is no note.
Instance Methods
format_name
my $formatted_name = $line->format_name;
Returns the name of the line properly formatted for output. For tags, it's the name with a leading @
. For all other lines, it is simply the name.
format_operator
my $formatted_operator = $line->format_operator;
Returns the formatted representation of the operator. This is just the operator an its associated white space. If neither the operator nor its white space exists, an empty string is returned. Used internally by as_string()
.
format_content
my $formatted_content $line->format_content;
Formats and returns the main content of the line. This consists of an operator and its associated white space, if any, followed by the formatted name.
format_note
my $note = $line->format_note;
Returns the note formatted for output. That is, with a leading #
and newlines encoded.
as_string
my $string = $line->as_string;
Returns the full stringification of the line, suitable for output to a plan file.
request_note
my $note = $line->request_note( for => 'add' );
Request the note from the user. Pass in the name of the command for which the note is requested via the for
parameter. If there is a note, it is simply returned. Otherwise, an editor will be launched and the user asked to write one. Once the editor exits, the note will be retrieved from the file, saved, and returned. If no note was written, an exception will be thrown with an exitval
of 1.
note_prompt
my $prompt = $line->note_prompt( for => 'tag' );
Returns a localized string for use in the temporary file created by request_note()
. Pass in the name of the command for which to prompt via the for
parameter.
See Also
- App::Sqitch::Plan
-
Class representing a plan.
- sqitch
-
The Sqitch command-line client.
Author
David E. Wheeler <david@justatheory.com>
License
Copyright (c) 2012-2023 iovation Inc., David E. Wheeler
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.