lib/todo_next/parser.rb in todo_next-0.0.1 vs lib/todo_next/parser.rb in todo_next-0.0.2

- old
+ new

@@ -1,26 +1,31 @@ require File.dirname(__FILE__) + '/tree' require File.dirname(__FILE__) + '/line' -require File.dirname(__FILE__) + '/rspec_generator_visitor' require File.dirname(__FILE__) + '/cli' module TodoNext - class Parser - def self.parse(text) + + def self.parse(text, prune_example_nodes=true) lines = extract_meaningful_lines(text) tree = Tree::Factory.build(lines) + if prune_example_nodes + tree.visit(TodoNext::Tree::Visitor::ExampleNodesRemover.new) + tree.visit(TodoNext::Tree::Visitor::LeafMaker .new) + end + tree end def self.extract_meaningful_lines(text) text. split("\n"). collect do |text| col_offset = text =~ /\S/ Line.new(text.strip, col_offset) end. reject{|l| l.blank? }. - reject{|l| l.comment?} + reject{|l| l.comment?}. + reject{|l| l.passed?} end - end + end end \ No newline at end of file