Handle cases where the parser returns nil

The Future Parser will return nil if a manifest file contains no statements
(I.E. it is empty or full of comments). Handle these cases and ensure the
`enumerate` method of the YARD parser always returns an Array.
This commit is contained in:
Charlie Sharpsteen 2014-06-02 19:04:19 -07:00
parent afb053c03b
commit 84f31a8074
2 changed files with 9 additions and 1 deletions

View File

@ -45,5 +45,10 @@ module Puppetx::Yardoc::Pops
def transform_Positioned(o)
YARDStatement.new(o)
end
# nil in... nil out!
def transform_NilClass(o)
nil
end
end
end

View File

@ -22,7 +22,10 @@ module Puppetx::Yardoc::YARD
end
def enumerator
@transformer.transform(@parse_result)
statements = @transformer.transform(@parse_result)
# Ensure an array is returned and prune any nil values.
Array(statements).compact
end
end