lib/code.rb in code-0.9.0 vs lib/code.rb in code-0.9.1
- old
+ new
@@ -34,11 +34,11 @@
def self.from_ruby(m)
source = m.source || ""
indent = source.match(/\A +/)
source = source.gsub(/^#{indent}/,"")
comment = m.comment && !m.comment.empty? ? "#{ m.comment }" : ""
- location = m.source_location ? "# in #{ m.source_location*':' }\n" : ""
+ location = m.source_location ? "#\n# #{ m.source_location*':' }\n#\n" : ""
display location + comment + source
end
# Find C definition of Code
@@ -49,12 +49,16 @@
raise Code::NotFound, 'Method source not found. Might be possible with core_docs gem'
elsif !(method_info = CoreDocs::MethodInfo.info_for(m))
raise Code::NotFound, 'Method source not found.'
else
source = method_info.source
- location = "// in #{method_info.file}:#{method_info.line}\n"
+ location = "//\n// #{cruby_on_github(method_info.file, method_info.line)}\n//\n"
comment = method_info.docstring ? method_info.docstring.gsub(/^/, '// ') + "\n" : ""
display location + comment + source, :c
end
+ end
+
+ def self.cruby_on_github(filename, line)
+ "https://github.com/ruby/ruby/blob/ruby_#{RUBY_VERSION[0]}_#{RUBY_VERSION[2]}/#{filename}#L#{line}"
end
end