Commit 0d06a13b authored by Coraline Ehmke's avatar Coraline Ehmke

Defensive coding around name extraction

parent a5be7113
......@@ -8,7 +8,7 @@ module Snuffle
attr_accessor :summaries
def initialize(summaries)
self.summaries = summaries.sort{|a,b| a.object_candidates.count <=> b.object_candidates.count}.reverse
self.summaries = summaries.sort{|a,b| a.cohorts.count <=> b.cohorts.count}.reverse
end
def header
......
......@@ -95,10 +95,13 @@ module Snuffle
return if node.nil?
return node unless node.respond_to?(:children)
if node.respond_to?(:loc) && node.loc.respond_to?(:name)
name_coords = node.loc.name
name = source[name_coords.begin_pos, name_coords.end_pos - 1]
return unless name =~ /[a-zA-Z]/
return name
if name_coords = node.loc.name
name = source[name_coords.begin_pos, name_coords.end_pos - 1]
return unless name =~ /[a-zA-Z]/
return name
else
"?"
end
else
return name_from(node.children.last)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment