Permalink
Browse files

add MetricFu.configuration.darwin_txmt_protocol_no_thanks.

  • Loading branch information...
1 parent b05361b commit 86b0b41b48459b75720ca071e287a8f822363a99 @kakutani kakutani committed with jscruggs Nov 18, 2010
Showing with 29 additions and 5 deletions.
  1. +7 −1 lib/base/base_template.rb
  2. +4 −2 lib/base/configuration.rb
  3. +18 −2 spec/base/base_template_spec.rb
@@ -137,13 +137,19 @@ 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')
+ if render_as_txmt_protocol?
"txmt://open/?url=file://#{filename}" << (line ? "&line=#{line}" : "")
else
"file://#{filename}"
end
end
+ def render_as_txmt_protocol? # :nodoc:
+ config = MetricFu.configuration
+ return false unless config.platform.include?('darwin')
+ return !config.darwin_txmt_protocol_no_thanks
+ 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,
# and the cardinality of the iteration.
@@ -8,9 +8,9 @@ module MetricFu
AVAILABLE_METRICS = [:churn, :flog, :flay, :reek,
:roodi, :rcov,
:hotspots]
-
+
AVAILABLE_METRICS << :saikuro unless RUBY_VERSION == '1.9.2'
-
+
AVAILABLE_GRAPHS = [:flog, :flay, :reek, :roodi, :rcov, :rails_best_practices]
AVAILABLE_GRAPH_ENGINES = [:gchart, :bluff]
@@ -146,6 +146,8 @@ def reset
@file_globs_to_ignore = []
@graph_engine = :bluff # can be :bluff or :gchart
+
+ @darwin_txmt_protocol_no_thanks = false
end
# Perform a simple check to try and guess if we're running
@@ -88,6 +88,7 @@
before(:each) do
config = mock("configuration")
config.stub!(:platform).and_return('universal-darwin-9.0')
+ config.stub!(:darwin_txmt_protocol_no_thanks).and_return(false)
MetricFu.stub!(:configuration).and_return(config)
end
@@ -112,6 +113,22 @@
+ "/expanded/filename&line=6'>filename:6</a>")
end
+ describe "but no thanks for txtmt" do
+ before(:each) do
+ config = mock("configuration")
+ config.stub!(:platform).and_return('universal-darwin-9.0')
+ config.stub!(:darwin_txmt_protocol_no_thanks).and_return(true)
+ MetricFu.stub!(:configuration).and_return(config)
+ File.should_receive(:expand_path).and_return('filename')
+ end
+
+ it "should return a file protocol link" do
+ name = "filename"
+ result = @template.send(:link_to_filename, name)
+ result.should == "<a href='file://filename'>filename</a>"
+ end
+ end
+
describe "and given link text" do
it "should use the submitted link text" do
File.stub!(:expand_path).with('filename').and_return('/expanded/filename')
@@ -126,6 +143,7 @@
before(:each) do
config = mock("configuration")
config.should_receive(:platform).and_return('other')
+ config.stub!(:darwin_txmt_protocol_no_thanks).and_return(false)
MetricFu.stub!(:configuration).and_return(config)
File.should_receive(:expand_path).and_return('filename')
end
@@ -157,5 +175,3 @@
end
end
-
-

0 comments on commit 86b0b41

Please sign in to comment.