lib/read_source.rb in read_source-0.1.0 vs lib/read_source.rb in read_source-0.2.0
- old
+ new
@@ -1,31 +1,9 @@
-require "read_source/version"
+require 'read_source/version'
+require 'read_source/vim_source'
+require 'read_source/read_source'
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