Sha256: 03f7b90ba1e2edcd4c9d41f268533896bea6d0f2015db0c93367c7e5634a8192
Contents?: true
Size: 875 Bytes
Versions: 1
Compression:
Stored size: 875 Bytes
Contents
require "read_source/version" module ReadSource module VimSource def vim file, line_num = send :source_location read_only = !!/#{ENV["GEM_HOME"]}/.match(file) ? "-M" : "" exec("vim %s +%s %s" % [read_only, line_num, file]) if file end end module ReadSource def read_source file, line_num = send :source_location return unless file readlines = IO.readlines(file) source = readlines[line_num-1] indent = /\A[[:space:]]*/.match(source).to_s.length source = source[indent..-1] readlines[line_num..-1].each do |l| source += l[indent..-1] if indent == /\A[[:space:]]*/.match(l).to_s.length break source end end end end ::Method.include VimSource ::Method.include ReadSource ::UnboundMethod.include VimSource ::UnboundMethod.include ReadSource end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
read_source-0.1.0 | lib/read_source.rb |