BioX-Workflow-Command

 view release on metacpan or  search on metacpan

lib/BioX/Workflow/Command/inspect/Utils/ParsePlainText.pm  view on Meta::CPAN

package BioX::Workflow::Command::inspect::Utils::ParsePlainText;

use Moose::Role;
use namespace::autoclean;
use File::Slurp;

has 'workflow_plain_text' => (
    is      => 'rw',
    lazy    => 1,
    default => sub {
        my $self = shift;
        return read_file( $self->workflow, array_ref => 1 );
    }
);

has 'line_number_rules_dec' => (
    is      => 'rw',
    lazy    => 1,
    default => 1,
);

has 'line_number_global_dec' => (
    is      => 'rw',
    lazy    => 1,
    default => 2,
);

sub get_line_declarations {
    my $self = shift;

    my $line_number = 0;
    foreach my $line ( @{ $self->workflow_plain_text } ) {
        if ( $line =~ m/\s*:\s*rules\s*:/ ) {
            my $column = $self->get_column($line);
            $self->inspect_obj->{line_numbers}->{begin_rules} =
              { line => $line_number, column => $column };
            $self->line_number_rules_dec($line_number);
        }
        elsif ( $line =~ m/\s:\s*global\s:/ ) {
            my $column = $self->get_column($line);
            $self->inspect_obj->{line_numbers}->{begin_global} =
              { line => $line_number, column => $column };
            $self->line_number_global_dec($line_number);
        }
        $line_number++;
    }
}

sub get_line_number_rules {
    my $self = shift;

    $self->inspect_obj->{line_numbers}->{rules}->{ $self->rule_name }->{local}
      = {};

    my $rule_name   = $self->rule_name;
    my $found_rule  = 0;
    my $found_local = 0;

    for (
        my $x = $self->line_number_rules_dec + 1 ;
        $x < scalar @{ $self->workflow_plain_text } ;
        $x++
      )
    {



( run in 0.764 second using v1.01-cache-2.11-cpan-39bf76dae61 )