edouard-metric_fu 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +1 -1
- data/Rakefile +4 -4
- data/spec/base/configuration_spec.rb +1 -1
- data/spec/base/generator_spec.rb +0 -22
- data/spec/generators/churn_spec.rb +7 -7
- data/spec/generators/flay_spec.rb +0 -3
- data/spec/generators/flog_spec.rb +1 -9
- data/spec/generators/reek_spec.rb +0 -1
- data/spec/generators/saikuro_spec.rb +11 -21
- metadata +18 -56
- data/lib/base/base_template.rb +0 -134
- data/lib/base/configuration.rb +0 -207
- data/lib/base/generator.rb +0 -160
- data/lib/base/graph.rb +0 -37
- data/lib/base/md5_tracker.rb +0 -52
- data/lib/base/report.rb +0 -100
- data/lib/generators/churn.rb +0 -91
- data/lib/generators/flay.rb +0 -34
- data/lib/generators/flog.rb +0 -133
- data/lib/generators/rcov.rb +0 -87
- data/lib/generators/reek.rb +0 -37
- data/lib/generators/roodi.rb +0 -31
- data/lib/generators/saikuro.rb +0 -209
- data/lib/generators/stats.rb +0 -43
- data/lib/graphs/flay_grapher.rb +0 -34
- data/lib/graphs/flog_grapher.rb +0 -37
- data/lib/graphs/rcov_grapher.rb +0 -34
- data/lib/graphs/reek_grapher.rb +0 -44
- data/lib/graphs/roodi_grapher.rb +0 -34
- data/lib/metric_fu.rb +0 -24
- data/lib/templates/awesome/awesome_template.rb +0 -30
- data/lib/templates/awesome/churn.html.erb +0 -19
- data/lib/templates/awesome/default.css +0 -66
- data/lib/templates/awesome/flay.html.erb +0 -27
- data/lib/templates/awesome/flog.html.erb +0 -46
- data/lib/templates/awesome/index.html.erb +0 -28
- data/lib/templates/awesome/layout.html.erb +0 -27
- data/lib/templates/awesome/rcov.html.erb +0 -36
- data/lib/templates/awesome/reek.html.erb +0 -34
- data/lib/templates/awesome/roodi.html.erb +0 -21
- data/lib/templates/awesome/saikuro.html.erb +0 -71
- data/lib/templates/awesome/stats.html.erb +0 -41
- data/lib/templates/standard/churn.html.erb +0 -31
- data/lib/templates/standard/default.css +0 -64
- data/lib/templates/standard/flay.html.erb +0 -34
- data/lib/templates/standard/flog.html.erb +0 -53
- data/lib/templates/standard/index.html.erb +0 -38
- data/lib/templates/standard/rcov.html.erb +0 -43
- data/lib/templates/standard/reek.html.erb +0 -42
- data/lib/templates/standard/roodi.html.erb +0 -29
- data/lib/templates/standard/saikuro.html.erb +0 -84
- data/lib/templates/standard/standard_template.rb +0 -26
- data/lib/templates/standard/stats.html.erb +0 -55
- data/tasks/metric_fu.rake +0 -19
- data/tasks/railroad.rake +0 -39
- data/vendor/_fonts/monaco.ttf +0 -0
- data/vendor/saikuro/saikuro.rb +0 -1214
data/README
CHANGED
@@ -1 +1 @@
|
|
1
|
-
See http://metric-fu.rubyforge.org/ for documentation, or the HISTORY file for a change log.
|
1
|
+
See http://metric-fu.rubyforge.org/ for documentation, or the HISTORY file for a change log.
|
data/Rakefile
CHANGED
@@ -20,8 +20,8 @@ namespace :metrics do
|
|
20
20
|
task :all do
|
21
21
|
MetricFu.metrics.each {|metric| MetricFu.report.add(metric) }
|
22
22
|
MetricFu.report.save_output(MetricFu.report.to_yaml,
|
23
|
-
MetricFu.
|
24
|
-
|
23
|
+
MetricFu.base_directory,
|
24
|
+
'report.yml')
|
25
25
|
MetricFu.report.save_templatized_report
|
26
26
|
if MetricFu.report.open_in_browser?
|
27
27
|
MetricFu.report.show_in_browser(MetricFu.output_directory)
|
@@ -34,8 +34,8 @@ namespace :metrics do
|
|
34
34
|
|
35
35
|
MetricFu.report.add(metric)
|
36
36
|
MetricFu.report.save_output(MetricFu.report.to_yaml,
|
37
|
-
MetricFu.
|
38
|
-
|
37
|
+
MetricFu.base_directory,
|
38
|
+
'report.yml')
|
39
39
|
MetricFu.report.save_templatized_report
|
40
40
|
if MetricFu.report.open_in_browser?
|
41
41
|
MetricFu.report.show_in_browser(MetricFu.output_directory)
|
@@ -129,7 +129,7 @@ describe MetricFu::Configuration do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
it 'should set @template_class to StandardTemplate' do
|
132
|
-
template_class.should ==
|
132
|
+
template_class.should == StandardTemplate
|
133
133
|
end
|
134
134
|
|
135
135
|
it 'should set @flay to {:dirs_to_flay => @code_dirs}' do
|
data/spec/base/generator_spec.rb
CHANGED
@@ -154,28 +154,6 @@ describe MetricFu::Generator do
|
|
154
154
|
@concrete_class.should_receive(:to_h)
|
155
155
|
@concrete_class.generate_report
|
156
156
|
end
|
157
|
-
|
158
|
-
it "should raise error if the concrete class is missing a required dependency" do
|
159
|
-
concrete_class_with_missing_gem = Class.new(MetricFu::Generator) do
|
160
|
-
def self.verify_dependencies!
|
161
|
-
raise 'gem install something # if you want these tasks'
|
162
|
-
end
|
163
|
-
end
|
164
|
-
lambda { concrete_class_with_missing_gem.generate_report }.should raise_error("gem install something # if you want these tasks")
|
165
|
-
end
|
166
157
|
|
167
158
|
end
|
168
|
-
|
169
|
-
describe "instantiation" do
|
170
|
-
it "should fail is dependencies not verified" do
|
171
|
-
ConcreteClass.should_receive(:verify_dependencies!).and_raise("Missing a required gem. Please 'gem install something'")
|
172
|
-
lambda { ConcreteClass.new() }.should raise_error("Missing a required gem. Please 'gem install something'")
|
173
|
-
end
|
174
|
-
|
175
|
-
it "should succeed when dependencies verified" do
|
176
|
-
ConcreteClass.should_receive(:verify_dependencies!).and_return(true)
|
177
|
-
ConcreteClass.new()
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
159
|
end
|
@@ -8,20 +8,20 @@ describe Churn do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should setup git if .git exits" do
|
11
|
-
|
11
|
+
File.should_receive(:exist?).with(".git").and_return(true)
|
12
12
|
Churn::Git.should_receive(:new)
|
13
13
|
MetricFu::Churn.new
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should setup git if .svn exits" do
|
17
|
-
|
17
|
+
File.should_receive(:exist?).with(".git").and_return(false)
|
18
18
|
File.should_receive(:exist?).with(".svn").and_return(true)
|
19
19
|
Churn::Svn.should_receive(:new)
|
20
20
|
MetricFu::Churn.new()
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should raise an error if not .svn or .git" do
|
24
|
-
|
24
|
+
File.stub!(:exist?).and_return(false)
|
25
25
|
lambda{MetricFu::Churn.new()}.should raise_error(Exception)
|
26
26
|
end
|
27
27
|
end
|
@@ -30,7 +30,7 @@ describe Churn do
|
|
30
30
|
before :each do
|
31
31
|
MetricFu::Configuration.run {|config| config.churn = {:minimum_churn_count => 2} }
|
32
32
|
File.stub!(:directory?).and_return(true)
|
33
|
-
|
33
|
+
File.should_receive(:exist?).with(".git").and_return(true)
|
34
34
|
@git = Churn::Git.new
|
35
35
|
Churn::Git.should_receive(:new).and_return(@git)
|
36
36
|
@lines = <<-HERE.gsub(/^\s*/, "")
|
@@ -73,7 +73,7 @@ describe Churn do
|
|
73
73
|
before :each do
|
74
74
|
MetricFu::Configuration.run{|config| config.churn = {:minimum_churn_count => 2} }
|
75
75
|
File.stub!(:directory?).and_return(true)
|
76
|
-
|
76
|
+
File.should_receive(:exist?).with(".git").and_return(false)
|
77
77
|
File.should_receive(:exist?).with(".svn").and_return(true)
|
78
78
|
@svn = Churn::Svn.new
|
79
79
|
Churn::Svn.should_receive(:new).and_return(@svn)
|
@@ -120,7 +120,7 @@ describe Churn do
|
|
120
120
|
before :each do
|
121
121
|
MetricFu::Configuration.run {}
|
122
122
|
File.stub!(:directory?).and_return(true)
|
123
|
-
|
123
|
+
File.should_receive(:exist?).with(".git").and_return(true)
|
124
124
|
@changes = {"lib/generators/flog.rb"=>2, "lib/metric_fu.rb"=>3}
|
125
125
|
end
|
126
126
|
|
@@ -139,7 +139,7 @@ describe Churn do
|
|
139
139
|
before :each do
|
140
140
|
MetricFu::Configuration.run {}
|
141
141
|
File.stub!(:directory?).and_return(true)
|
142
|
-
|
142
|
+
File.should_receive(:exist?).with(".git").and_return(true)
|
143
143
|
end
|
144
144
|
|
145
145
|
it "should put the changes into a hash" do
|
@@ -1,9 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
3
|
describe Flay do
|
4
|
-
before :each do
|
5
|
-
MetricFu::Flay.stub!(:verify_dependencies!).and_return(true)
|
6
|
-
end
|
7
4
|
describe "emit method" do
|
8
5
|
before :each do
|
9
6
|
MetricFu::Configuration.run {|config| config.flay = { :dirs_to_flay => ['app', 'lib'] } }
|
@@ -123,7 +123,6 @@ describe Flog do
|
|
123
123
|
1.2: assignment
|
124
124
|
1.2: all
|
125
125
|
HERE
|
126
|
-
MetricFu::Flog.stub!(:verify_dependencies!).and_return(true)
|
127
126
|
end
|
128
127
|
|
129
128
|
describe "parse method" do
|
@@ -169,13 +168,6 @@ describe Flog do
|
|
169
168
|
flog_page = flog.parse(text)
|
170
169
|
flog_page.scanned_methods.first.name.should == "SomeNamespace::UsersController#create"
|
171
170
|
end
|
172
|
-
|
173
|
-
it "should parse empty flog files" do
|
174
|
-
text = ""
|
175
|
-
flog = MetricFu::Flog.new('base_dir')
|
176
|
-
flog_page = flog.parse(text)
|
177
|
-
flog_page.should be_nil
|
178
|
-
end
|
179
171
|
end
|
180
172
|
|
181
173
|
describe "to_h function" do
|
@@ -205,4 +197,4 @@ describe Flog do
|
|
205
197
|
@flog_hash[:flog][:pages].first[:path].should == "/app/controllers/user_controller.rb"
|
206
198
|
end
|
207
199
|
end
|
208
|
-
end
|
200
|
+
end
|
@@ -3,7 +3,6 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
3
3
|
describe Reek do
|
4
4
|
describe "analyze method" do
|
5
5
|
before :each do
|
6
|
-
MetricFu::Reek.stub!(:verify_dependencies!).and_return(true)
|
7
6
|
@lines = <<-HERE
|
8
7
|
"app/controllers/activity_reports_controller.rb" -- 4 warnings:
|
9
8
|
ActivityReportsController#authorize_user calls current_user.primary_site_ids multiple times (Duplication)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
2
|
+
|
3
3
|
describe Saikuro do
|
4
4
|
describe "to_h method" do
|
5
5
|
before :all do
|
@@ -10,54 +10,44 @@ describe Saikuro do
|
|
10
10
|
saikuro.analyze
|
11
11
|
@output = saikuro.to_h
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
it "should find the filename of a file" do
|
15
15
|
@output[:saikuro][:files].first[:filename].should == 'users_controller.rb'
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it "should find the name of the classes" do
|
19
19
|
@output[:saikuro][:classes].first[:name].should == "UsersController"
|
20
20
|
@output[:saikuro][:classes][1][:name].should == "SessionsController"
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should put the most complex method first" do
|
24
24
|
@output[:saikuro][:methods].first[:name].should == "UsersController#create"
|
25
25
|
@output[:saikuro][:methods].first[:complexity].should == 4
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "should find the complexity of a method" do
|
29
29
|
@output[:saikuro][:methods].first[:complexity].should == 4
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
it "should find the lines of a method" do
|
33
33
|
@output[:saikuro][:methods].first[:lines].should == 15
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
describe "emit method" do
|
38
38
|
it "should format the directories" do
|
39
39
|
MetricFu::Configuration.run {}
|
40
40
|
File.stub!(:directory?).and_return(true)
|
41
41
|
saikuro = MetricFu::Saikuro.new
|
42
|
-
|
42
|
+
|
43
43
|
MetricFu.saikuro[:input_directory] = ["app", "lib"]
|
44
|
-
|
44
|
+
|
45
45
|
File.stub!(:dirname).and_return('..')
|
46
46
|
File.stub!(:expand_path)
|
47
|
-
|
47
|
+
|
48
48
|
saikuro.should_receive(:sh).with(/"app \| lib"/)
|
49
|
-
|
49
|
+
|
50
50
|
saikuro.emit
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
54
|
-
describe Saikuro::SFile do
|
55
|
-
describe "getting elements from a Saikuro result file" do
|
56
|
-
it "should parse nested START/END sections" do
|
57
|
-
path = File.join(File.dirname(__FILE__), "..", "resources", "saikuro_sfiles", "thing.rb_cyclo.html")
|
58
|
-
sfile = Saikuro::SFile.new path
|
59
|
-
sfile.elements.map { |e| e.complexity }.sort.should eql(["0","0","2"])
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edouard-metric_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Scruggs
|
@@ -10,7 +10,6 @@ authors:
|
|
10
10
|
- Petrik de Heus
|
11
11
|
- Grant McInnes
|
12
12
|
- Nick Quaranto
|
13
|
-
- "\xC3\x89douard Bri\xC3\xA8re"
|
14
13
|
autorequire:
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
@@ -39,34 +38,44 @@ dependencies:
|
|
39
38
|
version: 2.1.0
|
40
39
|
version:
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
41
|
+
name: rcov
|
42
|
+
type: :runtime
|
43
|
+
version_requirement:
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.8.3
|
49
|
+
version:
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: reek
|
43
52
|
type: :runtime
|
44
53
|
version_requirement:
|
45
54
|
version_requirements: !ruby/object:Gem::Requirement
|
46
55
|
requirements:
|
47
56
|
- - ">="
|
48
57
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
58
|
+
version: 1.0.0
|
50
59
|
version:
|
51
60
|
- !ruby/object:Gem::Dependency
|
52
|
-
name:
|
61
|
+
name: roodi
|
53
62
|
type: :runtime
|
54
63
|
version_requirement:
|
55
64
|
version_requirements: !ruby/object:Gem::Requirement
|
56
65
|
requirements:
|
57
66
|
- - ">="
|
58
67
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
68
|
+
version: 1.3.5
|
60
69
|
version:
|
61
70
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
71
|
+
name: chronic
|
63
72
|
type: :runtime
|
64
73
|
version_requirement:
|
65
74
|
version_requirements: !ruby/object:Gem::Requirement
|
66
75
|
requirements:
|
67
76
|
- - ">="
|
68
77
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.3
|
78
|
+
version: 0.2.3
|
70
79
|
version:
|
71
80
|
description: Code metrics from Flog, Flay, RCov, Saikuro, Churn, Reek, Roodi and Rails' stats task
|
72
81
|
email: jake.scruggs@gmail.com
|
@@ -84,53 +93,6 @@ files:
|
|
84
93
|
- TODO
|
85
94
|
- MIT-LICENSE
|
86
95
|
- Rakefile
|
87
|
-
- lib/base/base_template.rb
|
88
|
-
- lib/base/configuration.rb
|
89
|
-
- lib/base/generator.rb
|
90
|
-
- lib/base/md5_tracker.rb
|
91
|
-
- lib/base/report.rb
|
92
|
-
- lib/generators/churn.rb
|
93
|
-
- lib/generators/flay.rb
|
94
|
-
- lib/generators/flog.rb
|
95
|
-
- lib/generators/rcov.rb
|
96
|
-
- lib/generators/reek.rb
|
97
|
-
- lib/generators/roodi.rb
|
98
|
-
- lib/generators/saikuro.rb
|
99
|
-
- lib/generators/stats.rb
|
100
|
-
- lib/metric_fu.rb
|
101
|
-
- lib/templates/standard/churn.html.erb
|
102
|
-
- lib/templates/standard/default.css
|
103
|
-
- lib/templates/standard/flay.html.erb
|
104
|
-
- lib/templates/standard/flog.html.erb
|
105
|
-
- lib/templates/standard/index.html.erb
|
106
|
-
- lib/templates/standard/rcov.html.erb
|
107
|
-
- lib/templates/standard/reek.html.erb
|
108
|
-
- lib/templates/standard/roodi.html.erb
|
109
|
-
- lib/templates/standard/saikuro.html.erb
|
110
|
-
- lib/templates/standard/standard_template.rb
|
111
|
-
- lib/templates/standard/stats.html.erb
|
112
|
-
- lib/templates/awesome/churn.html.erb
|
113
|
-
- lib/templates/awesome/default.css
|
114
|
-
- lib/templates/awesome/flay.html.erb
|
115
|
-
- lib/templates/awesome/flog.html.erb
|
116
|
-
- lib/templates/awesome/index.html.erb
|
117
|
-
- lib/templates/awesome/rcov.html.erb
|
118
|
-
- lib/templates/awesome/reek.html.erb
|
119
|
-
- lib/templates/awesome/roodi.html.erb
|
120
|
-
- lib/templates/awesome/saikuro.html.erb
|
121
|
-
- lib/templates/awesome/awesome_template.rb
|
122
|
-
- lib/templates/awesome/stats.html.erb
|
123
|
-
- lib/templates/awesome/layout.html.erb
|
124
|
-
- lib/base/graph.rb
|
125
|
-
- lib/graphs/flay_grapher.rb
|
126
|
-
- lib/graphs/flog_grapher.rb
|
127
|
-
- lib/graphs/rcov_grapher.rb
|
128
|
-
- lib/graphs/reek_grapher.rb
|
129
|
-
- lib/graphs/roodi_grapher.rb
|
130
|
-
- tasks/metric_fu.rake
|
131
|
-
- vendor/_fonts/monaco.ttf
|
132
|
-
- tasks/railroad.rake
|
133
|
-
- vendor/saikuro/saikuro.rb
|
134
96
|
- Manifest.txt
|
135
97
|
has_rdoc: true
|
136
98
|
homepage: http://metric-fu.rubyforge.org/
|
@@ -158,7 +120,7 @@ rubyforge_project:
|
|
158
120
|
rubygems_version: 1.2.0
|
159
121
|
signing_key:
|
160
122
|
specification_version: 2
|
161
|
-
summary: A fistful of code metrics
|
123
|
+
summary: A fistful of code metrics
|
162
124
|
test_files:
|
163
125
|
- spec/base/base_template_spec.rb
|
164
126
|
- spec/base/configuration_spec.rb
|
data/lib/base/base_template.rb
DELETED
@@ -1,134 +0,0 @@
|
|
1
|
-
module MetricFu
|
2
|
-
|
3
|
-
# The Template class is intended as an abstract class for concrete
|
4
|
-
# template classes to subclass. It provides a variety of utility
|
5
|
-
# methods to make templating a bit easier. However, classes do not
|
6
|
-
# have to inherit from here in order to provide a template. The only
|
7
|
-
# requirement for a template class is that it provides a #write method
|
8
|
-
# to actually write out the template. See StandardTemplate for an
|
9
|
-
# example.
|
10
|
-
class Template
|
11
|
-
attr_accessor :report
|
12
|
-
|
13
|
-
private
|
14
|
-
# Creates a new erb evaluated result from the passed in section.
|
15
|
-
#
|
16
|
-
# @param section String
|
17
|
-
# The section name of
|
18
|
-
#
|
19
|
-
# @return String
|
20
|
-
# The erb evaluated string
|
21
|
-
def erbify(section)
|
22
|
-
require 'erb'
|
23
|
-
erb_doc = File.read(template(section))
|
24
|
-
ERB.new(erb_doc).result(binding)
|
25
|
-
end
|
26
|
-
|
27
|
-
# Determines whether a template file exists for a given section
|
28
|
-
# of the full template.
|
29
|
-
#
|
30
|
-
# @param section String
|
31
|
-
# The section of the template to check against
|
32
|
-
#
|
33
|
-
# @return Boolean
|
34
|
-
# Does a template file exist for this section or not?
|
35
|
-
def template_exists?(section)
|
36
|
-
File.exist?(template(section))
|
37
|
-
end
|
38
|
-
|
39
|
-
# Copies an instance variable mimicing the name of the section
|
40
|
-
# we are trying to render, with a value equal to the passed in
|
41
|
-
# constant. Allows the concrete template classes to refer to
|
42
|
-
# that instance variable from their ERB rendering
|
43
|
-
#
|
44
|
-
# @param section String
|
45
|
-
# The name of the instance variable to create
|
46
|
-
#
|
47
|
-
# @param contents Object
|
48
|
-
# The value to set as the value of the created instance
|
49
|
-
# variable
|
50
|
-
def create_instance_var(section, contents)
|
51
|
-
instance_variable_set("@#{section}", contents)
|
52
|
-
end
|
53
|
-
|
54
|
-
# Generates the filename of the template file to load and
|
55
|
-
# evaluate. In this case, the path to the template directory +
|
56
|
-
# the section name + .html.erb
|
57
|
-
#
|
58
|
-
# @param section String
|
59
|
-
# A section of the template to render
|
60
|
-
#
|
61
|
-
# @return String
|
62
|
-
# A file path
|
63
|
-
def template(section)
|
64
|
-
File.join(this_directory, section.to_s + ".html.erb")
|
65
|
-
end
|
66
|
-
|
67
|
-
# Returns the filename that the template will render into for
|
68
|
-
# a given section. In this case, the section name + '.html'
|
69
|
-
#
|
70
|
-
# @param section String
|
71
|
-
# A section of the template to render
|
72
|
-
#
|
73
|
-
# @return String
|
74
|
-
# The output filename
|
75
|
-
def output_filename(section)
|
76
|
-
section.to_s + ".html"
|
77
|
-
end
|
78
|
-
|
79
|
-
# Returns the contents of a given css file in order to
|
80
|
-
# render it inline into a template.
|
81
|
-
#
|
82
|
-
# @param css String
|
83
|
-
# The name of a css file to open
|
84
|
-
#
|
85
|
-
# @return String
|
86
|
-
# The contents of the css file
|
87
|
-
def inline_css(css)
|
88
|
-
open(File.join(this_directory, css)) { |f| f.read }
|
89
|
-
end
|
90
|
-
|
91
|
-
# Provides a link to open a file through the textmate protocol
|
92
|
-
# on Darwin, or otherwise, a simple file link.
|
93
|
-
#
|
94
|
-
# @param name String
|
95
|
-
#
|
96
|
-
# @param line Integer
|
97
|
-
# The line number to link to, if textmate is available. Defaults
|
98
|
-
# to nil
|
99
|
-
#
|
100
|
-
# @return String
|
101
|
-
# An anchor link to a textmate reference or a file reference
|
102
|
-
def link_to_filename(name, line = nil)
|
103
|
-
filename = File.expand_path(name)
|
104
|
-
if MetricFu.configuration.platform.include?('darwin')
|
105
|
-
"<a href='txmt://open/?url=file://" \
|
106
|
-
+"#{filename}&line=#{line}'>#{name}:#{line}</a>"
|
107
|
-
else
|
108
|
-
"<a href='file://#{filename}'>#{name}:#{line}</a>"
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
|
113
|
-
# Provides a brain dead way to cycle between two values during
|
114
|
-
# an iteration of some sort. Pass in the first_value, the second_value,
|
115
|
-
# and the cardinality of the iteration.
|
116
|
-
#
|
117
|
-
# @param first_value Object
|
118
|
-
#
|
119
|
-
# @param second_value Object
|
120
|
-
#
|
121
|
-
# @param iteration Integer
|
122
|
-
# The number of times through the iteration.
|
123
|
-
#
|
124
|
-
# @return Object
|
125
|
-
# The first_value if iteration is even. The second_value if
|
126
|
-
# iteration is odd.
|
127
|
-
def cycle(first_value, second_value, iteration)
|
128
|
-
return first_value if iteration % 2 == 0
|
129
|
-
return second_value
|
130
|
-
end
|
131
|
-
|
132
|
-
|
133
|
-
end
|
134
|
-
end
|