App-Sqitch

 view release on metacpan or  search on metacpan

lib/App/Sqitch/Plan/Tag.pm  view on Meta::CPAN

        my $plan = $self->plan;

        return join "\n", (
            'project ' . $self->project,
            ( $self->uri ? ( 'uri ' . $self->uri->canonical ) : () ),
            'tag '     . $self->format_name,
            'change '  . $self->change->id,
            'planner ' . $self->format_planner,
            'date '    . $self->timestamp->as_string,
            ( $self->note ? ('', $self->note) : ()),
        );
    }
);

has id => (
    is       => 'ro',
    isa      => Str,
    lazy     => 1,
    default  => sub {
        my $content = encode_utf8 shift->info;
        require Digest::SHA;
        return Digest::SHA->new(1)->add(
            'tag ' . length($content) . "\0" . $content
        )->hexdigest;
    }
);

has change => (
    is       => 'ro',
    isa      => Change,
    weak_ref => 1,
    required => 1,
);

has timestamp => (
    is       => 'ro',
    isa      => DateTime,
    default  => sub { require App::Sqitch::DateTime && App::Sqitch::DateTime->now },
);

has planner_name => (
    is       => 'ro',
    isa      => Str,
    default  => sub { shift->sqitch->user_name },
);

has planner_email => (
    is       => 'ro',
    isa      => UserEmail,
    default  => sub { shift->sqitch->user_email },
);

sub format_planner {
    my $self = shift;
    return join ' ', $self->planner_name, '<' . $self->planner_email . '>';
}

sub format_content {
    my $self = shift;
    return join ' ',
        $self->SUPER::format_content,
        $self->timestamp->as_string,
        $self->format_planner;
}

1;

__END__

=head1 Name

App::Sqitch::Plan::Tag - Sqitch deployment plan tag

=head1 Synopsis

  my $plan = App::Sqitch::Plan->new( sqitch => $sqitch );
  for my $line ($plan->lines) {
      say $line->as_string;
  }

=head1 Description

A App::Sqitch::Plan::Tag represents a tag as parsed from a plan file. In
addition to the interface inherited from L<App::Sqitch::Plan::Line>, it offers
interfaces fetching and formatting timestamp and planner information.

=head1 Interface

See L<App::Sqitch::Plan::Line> for the basics.

=head2 Accessors

=head3 C<change>

Returns the L<App::Sqitch::Plan::Change> object with which the tag is
associated.

=head3 C<timestamp>

Returns the an L<App::Sqitch::DateTime> object representing the time at which
the tag was added to the plan.

=head3 C<planner_name>

Returns the name of the user who added the tag to the plan.

=head3 C<planner_email>

Returns the email address of the user who added the tag to the plan.

=head3 C<info>

Information about the tag, returned as a string. Includes the tag ID, the ID
of the associated change, the name and email address of the user who added the
tag to the plan, and the timestamp for when the tag was added to the plan.

=head3 C<id>

A SHA1 hash of the data returned by C<info()>, which can be used as a
globally-unique identifier for the tag.



( run in 1.759 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )