lib/atp/processors/pre_cleaner.rb in atp-0.2.0 vs lib/atp/processors/pre_cleaner.rb in atp-0.2.1
- old
+ new
@@ -6,16 +6,24 @@
class PreCleaner < Processor
def initialize
@group_ids = []
end
+ # Make all IDs lower cased symbols
def on_id(node)
- id = node.to_a.first
- id = id.to_s.downcase.to_sym
- node.updated(nil, [id])
+ id = node.to_a[0]
+ node.updated(nil, [clean(id)])
end
+ # Make all ID references use the lower case symbols
+ def on_test_executed(node)
+ children = node.children.dup
+ children[0] = clean(children[0])
+ node.updated(nil, process_all(children))
+ end
+ alias_method :on_test_result, :on_test_executed
+
def on_group(node)
if id = node.children.find { |n| n.type == :id }
@group_ids << process(id).value
else
@group_ids << nil
@@ -35,9 +43,17 @@
end
else
children = node.children
end
node.updated(nil, process_all(children))
+ end
+
+ def clean(id)
+ if id.is_a?(Array)
+ id.map { |i| clean(i) }
+ else
+ id.to_s.downcase.to_sym
+ end
end
end
end
end