diff --git a/lib/base/base_template.rb b/lib/base/base_template.rb
index 9a7813c2a..8dfb30b82 100644
--- a/lib/base/base_template.rb
+++ b/lib/base/base_template.rb
@@ -100,19 +100,27 @@ def inline_css(css)
# @return String
# An anchor link to a textmate reference or a file reference
def link_to_filename(name, line = nil, link_content = nil)
- link_content ||= "#{name}:#{line}"
- "#{link_content}"
+ "#{link_content(name, line, link_content)}"
end
- def file_url(name, line)
+ def link_content(name, line=nil, link_content=nil) # :nodoc:
+ if link_content
+ link_content
+ elsif line
+ "#{name}:#{line}"
+ else
+ name
+ end
+ end
+
+ def file_url(name, line) # :nodoc:
filename = File.expand_path(name.gsub(/^\//, ''))
if MetricFu.configuration.platform.include?('darwin')
- "txmt://open/?url=file://#{filename}&line=#{line}"
+ "txmt://open/?url=file://#{filename}" << (line ? "&line=#{line}" : "")
else
"file://#{filename}"
end
end
-
# Provides a brain dead way to cycle between two values during
# an iteration of some sort. Pass in the first_value, the second_value,
diff --git a/spec/base/base_template_spec.rb b/spec/base/base_template_spec.rb
index aab9cc4c6..6274bca5b 100644
--- a/spec/base/base_template_spec.rb
+++ b/spec/base/base_template_spec.rb
@@ -95,14 +95,14 @@
File.stub(:expand_path).with('filename').and_return('/expanded/filename')
result = @template.send(:link_to_filename, 'filename')
result.should eql("filename:")
+ + "/expanded/filename'>filename")
end
it "should do the right thing with a filename that starts with a slash" do
File.stub(:expand_path).with('filename').and_return('/expanded/filename')
result = @template.send(:link_to_filename, '/filename')
result.should eql("/filename:")
+ + "/expanded/filename'>/filename")
end
it "should include a line number" do
@@ -133,7 +133,7 @@
it 'should return a file protocol link' do
name = "filename"
result = @template.send(:link_to_filename, name)
- result.should == "filename:"
+ result.should == "filename"
end
end
end