diff --git a/lib/real_world_rails/inspectors/inspector.rb b/lib/real_world_rails/inspectors/inspector.rb index cfc144530..24cab7285 100644 --- a/lib/real_world_rails/inspectors/inspector.rb +++ b/lib/real_world_rails/inspectors/inspector.rb @@ -30,12 +30,15 @@ def inspectable?(filename) end def inspect_file(filename) - buffer = Parser::Source::Buffer.new filename - buffer.read + buffer = create_buffer(filename) ast = parser.reset.parse(buffer) processor.process(ast) end + def create_buffer(filename) + Parser::Source::Buffer.new(filename).read + end + def parser @parser ||= ParserFactory.create end diff --git a/lib/real_world_rails/inspectors/view_specs_inspector.rb b/lib/real_world_rails/inspectors/view_specs_inspector.rb index 7f692da78..2233b2248 100644 --- a/lib/real_world_rails/inspectors/view_specs_inspector.rb +++ b/lib/real_world_rails/inspectors/view_specs_inspector.rb @@ -7,8 +7,7 @@ class ViewSpecsInspector < Inspector def inspect_file(filename) puts formatted_filename(filename) - buffer = Parser::Source::Buffer.new filename - buffer.read + buffer = create_buffer(filename) puts buffer.source puts # pretty print with colors!