App-Sqitch

 view release on metacpan or  search on metacpan

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

sub action {
    shift->is_deploy ? 'deploy' : 'revert';
}

sub format_name_with_tags {
    my $self = shift;
    return join ' ', $self->format_name, map { $_->format_name } $self->tags;
}

sub format_tag_qualified_name {
    my $self = shift;
    my ($tag) = $self->tags;
    unless ($tag) {
        ($tag) = $self->rework_tags or return $self->format_name . '@HEAD';
    }
    return join '', $self->format_name, $tag->format_name;
}

sub format_dependencies {
    my $self = shift;
    my $deps = join(
        ' ',
        map { $_->as_plan_string } $self->requires, $self->conflicts
    ) or return '';
    return "[$deps]";
}

sub format_name_with_dependencies {
    my $self = shift;
    my $dep = $self->format_dependencies or return $self->format_name;
    return $self->format_name . $self->pspace . $dep;
}

sub format_op_name_dependencies {
    my $self = shift;
    return $self->format_operator . $self->format_name_with_dependencies;
}

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

sub deploy_handle {
    my $self = shift;
    $self->plan->open_script($self->deploy_file);
}

sub revert_handle {
    my $self = shift;
    $self->plan->open_script($self->revert_file);
}

sub verify_handle {
    my $self = shift;
    $self->plan->open_script($self->verify_file);
}

sub format_content {
    my $self = shift;
    return $self->SUPER::format_content . $self->pspace . join (
        ' ',
        ($self->format_dependencies || ()),
        $self->timestamp->as_string,
        $self->format_planner
    );
}

sub requires_changes {
    my $self = shift;
    my $plan = $self->plan;
    return map { $plan->find( $_->key_name ) } $self->requires;
}

sub conflicts_changes {
    my $self = shift;
    my $plan = $self->plan;
    return map { $plan->find( $_->key_name ) } $self->conflicts;
}

sub note_prompt {
    my ( $self, %p ) = @_;

    return join(
        '',
        __x(
            "Please enter a note for your change. Lines starting with '#' will\n" .
            "be ignored, and an empty message aborts the {command}.",
            command => $p{for},
        ),
        "\n",
        __x('Change to {command}:', command => $p{for}),
        "\n\n",
        '  ', $self->format_op_name_dependencies,
        join "\n    ", '', @{ $p{scripts} },
        "\n",
    );
}

1;

__END__

=head1 Name

App::Sqitch::Plan::Change - 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::Change represents a change as parsed from a plan file. In
addition to the interface inherited from L<App::Sqitch::Plan::Line>, it offers
interfaces for parsing dependencies from the deploy script, as well as for
opening the deploy, revert, and verify scripts.



( run in 2.086 seconds using v1.01-cache-2.11-cpan-5b529ec07f3 )