Skip to content

Commit

Permalink
create_buffer(filename) method to make buffer creation more accessible
Browse files Browse the repository at this point in the history
  • Loading branch information
eliotsykes committed Aug 22, 2015
1 parent 6ab0ee6 commit d655423
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/real_world_rails/inspectors/inspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions lib/real_world_rails/inspectors/view_specs_inspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down

0 comments on commit d655423

Please sign in to comment.