| 1 | package App::PRT::Command::IntroduceVariables; | ||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use PPI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 4 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 7 | 4 | my ($class) = @_; | |||||||||
| 8 | 4 | bless {}, $class; | |||||||||
| 9 | } | ||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | sub parse_arguments { | ||||||||
|
Subroutine
parse_arguments: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 12 | 1 | my ($self, @arguments) = @_; | |||||||||
| 13 | 2 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 1 | @arguments; | |||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | 1 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 18 | 1 | my ($self, $file, $out) = @_; | |||||||||
| 19 | |||||||||||
| 20 | 1 | my $variables = $self->collect_variables($file); | |||||||||
| 21 | 1 | for my $variable (@$variables) { | |||||||||
| 22 | 6 | say $out $variable; | |||||||||
| 23 | } | ||||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 2 | ▶ | sub collect_variables { | ||||||||
|
Subroutine
collect_variables: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 27 | 2 | my ($self, $file) = @_; | |||||||||
| 28 | 2 | my $document = PPI::Document->new($file); | |||||||||
| 29 | |||||||||||
| 30 | 2 | my $knowns = {}; | |||||||||
| 31 | 2 | my $variables = []; | |||||||||
| 32 | 2 | my $tokens = $document->find('PPI::Token::Symbol'); | |||||||||
| 33 | 2 | ▶ | return [] unless $tokens; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | 2 | for my $token (@$tokens) { | |||||||||
| 36 | 20 | ▶ | next if $knowns->{$token}++; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | |||||||||||
| 38 | 12 | push @$variables, $token->content; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 2 | $variables; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 2 | 1; | |||||||||