class CucumberReports::AstCleaner

Public Instance Methods

clean(ast, filename) click to toggle source
# File lib/cucumber-reports/ast_cleaner.rb, line 3
def clean(ast, filename)
  # Return files with only one instruction
  return nil if invalid?(ast)
  return [ast] if ast.type == :block

  # Remove modules
  array_with_steps = ast.children.filter {|block| !invalid?(block)}
  array_with_steps
end
invalid?(ast) click to toggle source
# File lib/cucumber-reports/ast_cleaner.rb, line 13
def invalid?(ast)
  return true if ast.nil?
  return true if ast.type == :class
  return true if ast.type == :def
  return true if ast.type == :module
end