Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add configurable file prefix instead of just file:// and txmt:// #51

Closed
wants to merge 2 commits into from

2 participants

@dj2

I'm setup my build box to run metric_fu but none of the file link paths work correctly as they're all generated as file://.

This patch adds a configuration flag link_prefix that I can set to something like http://example.org/files and the links will then become something like http://example.org/files/app/controllers/application_controller.rb instead of file:///users/dj2/foo/app/controllers/application_controller.rb.

@bf4 bf4 referenced this pull request in metricfu/metric_fu
Closed

Add configurable file prefix instead of just file:// and txmt:// #28

@bf4
Collaborator
bf4 commented

Gem no longer maintained, See https://github.com/metricfu/metric_fu

@bf4 bf4 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
1  HISTORY
@@ -1,6 +1,7 @@
=== MetricFu 2.0.2 / ???
* Flog gemspec version was >= 2.2.0, which was too early and didn't work. Changed too >= 2.3.0 - Chris Griego
+* Added link_prefix to configuration to allow URIs specified in config instead of file or txmt - dan sinclair
=== MetricFu 2.0.1 / 2010-11-13
View
5 lib/base/base_template.rb
@@ -137,7 +137,10 @@ def display_location(location, stat)
def file_url(name, line) # :nodoc:
return '' unless name
filename = File.expand_path(name.gsub(/^\//, ''))
- if MetricFu.configuration.platform.include?('darwin')
+ link_prefix = MetricFu.configuration.link_prefix
+ if link_prefix
+ "#{link_prefix}/#{name.gsub(/:.*$/, '')}"
+ elsif MetricFu.configuration.platform.include?('darwin')
"txmt://open/?url=file://#{filename}" << (line ? "&line=#{line}" : "")
else
"file://#{filename}"
View
2  lib/base/configuration.rb
@@ -145,6 +145,8 @@ def reset
@hotspots = {}
@file_globs_to_ignore = []
+ @link_prefix = nil
+
@graph_engine = :bluff # can be :bluff or :gchart
end
View
17 spec/base/base_template_spec.rb
@@ -88,6 +88,7 @@
before(:each) do
config = mock("configuration")
config.stub!(:platform).and_return('universal-darwin-9.0')
+ config.stub!(:link_prefix).and_return(nil)
MetricFu.stub!(:configuration).and_return(config)
end
@@ -126,6 +127,7 @@
before(:each) do
config = mock("configuration")
config.should_receive(:platform).and_return('other')
+ config.stub!(:link_prefix).and_return(nil)
MetricFu.stub!(:configuration).and_return(config)
File.should_receive(:expand_path).and_return('filename')
end
@@ -136,6 +138,21 @@
result.should == "<a href='file://filename'>filename</a>"
end
end
+
+ describe "when configured with a link_prefix" do
+ before(:each) do
+ config = mock("configuration")
+ config.should_receive(:link_prefix).and_return('http://example.org/files')
+ MetricFu.stub!(:configuration).and_return(config)
+ File.should_receive(:expand_path).and_return('filename')
+ end
+
+ it 'should return a http protocol link' do
+ name = "filename"
+ result = @template.send(:link_to_filename, name)
+ result.should == "<a href='http://example.org/files/filename'>filename</a>"
+ end
+ end
end
describe "#cycle" do
Something went wrong with that request. Please try again.