| 1 | package App::Workflow::Lint::YAML; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use YAML::PP; | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | App::Workflow::Lint::YAML - YAML loader for GitHub Actions workflows | ||
| 10 | |||
| 11 | =head1 SYNOPSIS | ||
| 12 | |||
| 13 | use App::Workflow::Lint::YAML; | ||
| 14 | |||
| 15 | my ($data, $positions) = | ||
| 16 | App::Workflow::Lint::YAML->load_yaml($yaml_text); | ||
| 17 | |||
| 18 | =head1 DESCRIPTION | ||
| 19 | |||
| 20 | C<App::Workflow::Lint::YAML> provides a lightweight YAML loader used by | ||
| 21 | the workflow linter. It loads YAML using L<YAML::PP> and returns the | ||
| 22 | parsed data structure. | ||
| 23 | |||
| 24 | Earlier versions attempted to extract line numbers from the YAML parser, | ||
| 25 | but this is no longer supported. The C<$positions> hashref is returned | ||
| 26 | for API compatibility and is always empty. | ||
| 27 | |||
| 28 | =head1 METHODS | ||
| 29 | |||
| 30 | =head2 load_yaml | ||
| 31 | |||
| 32 | my ($data, $positions) = App::Workflow::Lint::YAML->load_yaml($yaml_text); | ||
| 33 | |||
| 34 | Parses the YAML string and returns the resulting Perl data structure. | ||
| 35 | The second return value is an empty hashref reserved for future use. | ||
| 36 | |||
| 37 | =cut | ||
| 38 | |||
| 39 | # ---------------------------------------------------------------------- | ||
| 40 | # load_yaml | ||
| 41 | # | ||
| 42 | # Loads a GitHub Actions workflow YAML file/string and returns: | ||
| 43 | # - $data : the parsed Perl structure | ||
| 44 | # - {} : an empty position map (line numbers removed) | ||
| 45 | # | ||
| 46 | # This keeps the API stable for callers that expect two return values, | ||
| 47 | # but no longer attempts to compute line numbers. | ||
| 48 | # ---------------------------------------------------------------------- | ||
| 49 | |||
| 50 | sub load_yaml { | ||
| 51 | my ($class, $yaml_text) = @_; | ||
| 52 | |||
| 53 | my $ypp = YAML::PP->new; | ||
| 54 | my $data = $ypp->load_string($yaml_text); | ||
| 55 | |||
| 56 | # No line numbers available → return empty map | ||
| 57 | my %positions; | ||
| 58 | |||
| 59 | return ($data, \%positions); | ||
| 60 | } | ||
| 61 | |||
| 62 | 1; |