Sha256: a7cf9dba2106582c05d1cd47fc9234cdaee8595236d78125e85a3070963894ad
Contents?: true
Size: 831 Bytes
Versions: 6
Compression:
Stored size: 831 Bytes
Contents
# encoding: utf-8 # author: Dominik Richter # author: Christoph Hartmann module Inspec module MethodSource def self.code_at(location, source_reader) # TODO: logger for these cases return '' if location.nil? || location[:ref].nil? || location[:line].nil? return '' unless source_reader && source_reader.target # TODO: Non-controls still need more detection ref = location[:ref] ref = ref.sub(source_reader.target.prefix, '') src = source_reader.tests[ref] return '' if src.nil? ::MethodSource.expression_at(src.lines, location[:line]).force_encoding('utf-8') rescue SyntaxError => e raise ::MethodSource::SourceNotFoundError, "Could not parse source at #{location[:ref]}:#{location[:line]}: #{e.message}" end end end
Version data entries
6 entries across 6 versions & 1 rubygems