class Transpec::ProcessedSource
Attributes
ast[R]
buffer[R]
error[R]
path[R]
Public Class Methods
from_file(path)
click to toggle source
# File lib/transpec/processed_source.rb, line 14 def self.from_file(path) source = File.read(path) new(source, path) end
new(source, path = nil)
click to toggle source
# File lib/transpec/processed_source.rb, line 19 def initialize(source, path = nil) @path = path parse(source) end
Public Instance Methods
to_s()
click to toggle source
# File lib/transpec/processed_source.rb, line 24 def to_s buffer.source end
Private Instance Methods
parse(source)
click to toggle source
# File lib/transpec/processed_source.rb, line 30 def parse(source) @buffer = Parser::Source::Buffer.new(@path || '(string)') @buffer.source = source builder = AST::Builder.new parser = Parser::CurrentRuby.new(builder) parser.diagnostics.all_errors_are_fatal = true @ast = parser.parse(@buffer) rescue Parser::SyntaxError, EncodingError => error @error = error end