metric_fu 4.4.4 → 4.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +14 -6
  2. checksums.yaml.gz.sig +3 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +1 -0
  5. data/.metrics +0 -3
  6. data/.travis.yml +1 -1
  7. data/.yardopts +0 -1
  8. data/CONTRIBUTING.md +1 -0
  9. data/CONTRIBUTORS +61 -2
  10. data/Gemfile +14 -11
  11. data/Gemfile.devtools +40 -0
  12. data/Guardfile +30 -0
  13. data/HISTORY.md +54 -1
  14. data/README.md +86 -56
  15. data/bin/mf-cane +8 -6
  16. data/bin/mf-churn +8 -7
  17. data/bin/mf-flay +8 -7
  18. data/bin/mf-reek +8 -7
  19. data/bin/mf-roodi +8 -7
  20. data/bin/mf-saikuro +8 -6
  21. data/certs/bf4.pem +22 -0
  22. data/checksum/metric_fu-4.4.4.gem.sha512 +1 -0
  23. data/checksum/metric_fu-4.5.0.gem.sha512 +1 -0
  24. data/etc/README.md +16 -0
  25. data/etc/erd.dot +173 -0
  26. data/etc/erd.png +0 -0
  27. data/lib/metric_fu.rb +56 -12
  28. data/lib/metric_fu/cli/helper.rb +8 -2
  29. data/lib/metric_fu/cli/parser.rb +86 -50
  30. data/lib/metric_fu/configuration.rb +4 -31
  31. data/lib/metric_fu/environment.rb +1 -1
  32. data/lib/metric_fu/formatter/html.rb +5 -5
  33. data/lib/metric_fu/gem_run.rb +68 -0
  34. data/lib/metric_fu/gem_version.rb +57 -0
  35. data/lib/metric_fu/io.rb +1 -1
  36. data/lib/metric_fu/load_files.rb +3 -5
  37. data/lib/metric_fu/loader.rb +31 -2
  38. data/lib/metric_fu/logging/mf_debugger.rb +1 -0
  39. data/lib/metric_fu/metric.rb +23 -1
  40. data/lib/metric_fu/metrics/cane/cane.rb +7 -3
  41. data/lib/metric_fu/metrics/cane/cane_grapher.rb +19 -0
  42. data/lib/metric_fu/metrics/cane/template_awesome/cane.html.erb +0 -4
  43. data/lib/metric_fu/metrics/churn/churn.rb +6 -7
  44. data/lib/metric_fu/metrics/flay/flay.rb +2 -4
  45. data/lib/metric_fu/metrics/flay/flay_grapher.rb +19 -0
  46. data/lib/metric_fu/metrics/flay/template_awesome/flay.html.erb +0 -4
  47. data/lib/metric_fu/metrics/flog/flog.rb +0 -2
  48. data/lib/metric_fu/metrics/flog/flog_grapher.rb +19 -0
  49. data/lib/metric_fu/metrics/flog/template_awesome/flog.html.erb +0 -4
  50. data/lib/metric_fu/metrics/generator.rb +34 -24
  51. data/lib/metric_fu/metrics/graph.rb +8 -14
  52. data/lib/metric_fu/metrics/hotspots/hotspot.rb +7 -5
  53. data/lib/metric_fu/metrics/hotspots/template_awesome/hotspots.html.erb +4 -6
  54. data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb +0 -2
  55. data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices_grapher.rb +19 -0
  56. data/lib/metric_fu/metrics/rails_best_practices/template_awesome/rails_best_practices.html.erb +0 -4
  57. data/lib/metric_fu/metrics/rcov/rcov_grapher.rb +19 -0
  58. data/lib/metric_fu/metrics/rcov/template_awesome/rcov.html.erb +0 -4
  59. data/lib/metric_fu/metrics/reek/init.rb +1 -1
  60. data/lib/metric_fu/metrics/reek/reek.rb +12 -8
  61. data/lib/metric_fu/metrics/reek/reek_grapher.rb +19 -0
  62. data/lib/metric_fu/metrics/reek/template_awesome/reek.html.erb +0 -4
  63. data/lib/metric_fu/metrics/roodi/roodi.rb +2 -3
  64. data/lib/metric_fu/metrics/roodi/roodi_grapher.rb +19 -0
  65. data/lib/metric_fu/metrics/roodi/template_awesome/roodi.html.erb +0 -4
  66. data/lib/metric_fu/metrics/saikuro/saikuro.rb +69 -33
  67. data/lib/metric_fu/metrics/saikuro/scratch_file.rb +8 -9
  68. data/lib/metric_fu/metrics/stats/stats_grapher.rb +20 -0
  69. data/lib/metric_fu/metrics/stats/template_awesome/stats.html.erb +0 -4
  70. data/lib/metric_fu/reporting/graphs/grapher.rb +69 -3
  71. data/lib/metric_fu/reporting/result.rb +5 -1
  72. data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +7 -3
  73. data/lib/metric_fu/run.rb +13 -7
  74. data/lib/metric_fu/tasks/metric_fu.rake +50 -3
  75. data/lib/metric_fu/utility.rb +10 -0
  76. data/lib/metric_fu/version.rb +1 -1
  77. data/metric_fu.gemspec +7 -4
  78. data/spec/dummy/.gitignore +1 -0
  79. data/spec/dummy/.gitkeep +0 -0
  80. data/spec/dummy/.metrics +4 -0
  81. data/spec/dummy/lib/.gitkeep +0 -0
  82. data/spec/dummy/spec/.gitkeep +0 -0
  83. data/spec/{resources/yml → fixtures}/20090630.yml +1 -1
  84. data/spec/{resources/yml → fixtures}/hotspots/flog.yml +0 -0
  85. data/spec/{resources/yml → fixtures}/hotspots/generator.yml +0 -0
  86. data/spec/{resources/yml → fixtures}/hotspots/generator_analysis.yml +0 -0
  87. data/spec/{resources/yml → fixtures}/hotspots/reek.yml +0 -0
  88. data/spec/{resources/yml → fixtures}/hotspots/roodi.yml +0 -0
  89. data/spec/{resources/yml → fixtures}/hotspots/saikuro.yml +0 -0
  90. data/spec/{resources/yml → fixtures}/hotspots/several_metrics.yml +0 -0
  91. data/spec/{resources/yml → fixtures}/hotspots/stats.yml +0 -0
  92. data/spec/{resources/yml → fixtures}/hotspots/three_metrics_on_same_file.yml +0 -0
  93. data/spec/{resources → fixtures}/line_numbers/foo.rb +0 -0
  94. data/spec/{resources → fixtures}/line_numbers/module.rb +0 -0
  95. data/spec/{resources → fixtures}/line_numbers/module_surrounds_class.rb +0 -0
  96. data/spec/{resources → fixtures}/line_numbers/two_classes.rb +0 -0
  97. data/spec/{resources/yml → fixtures}/metric_missing.yml +0 -0
  98. data/spec/{resources → fixtures}/saikuro/app/controllers/sessions_controller.rb_cyclo.html +0 -0
  99. data/spec/{resources → fixtures}/saikuro/app/controllers/users_controller.rb_cyclo.html +0 -0
  100. data/spec/{resources → fixtures}/saikuro/index_cyclo.html +0 -0
  101. data/spec/{resources → fixtures}/saikuro_sfiles/thing.rb_cyclo.html +0 -0
  102. data/spec/metric_fu/configuration_spec.rb +1 -1
  103. data/spec/metric_fu/data_structures/line_numbers_spec.rb +13 -11
  104. data/spec/metric_fu/formatter/html_spec.rb +2 -2
  105. data/spec/metric_fu/gem_version_spec.rb +14 -0
  106. data/spec/metric_fu/loader_spec.rb +12 -0
  107. data/spec/metric_fu/metrics/base_template_spec.rb +9 -7
  108. data/spec/metric_fu/metrics/cane/cane_spec.rb +7 -7
  109. data/spec/metric_fu/metrics/churn/churn_spec.rb +1 -1
  110. data/spec/metric_fu/metrics/flay/flay_grapher_spec.rb +2 -2
  111. data/spec/metric_fu/metrics/flay/flay_spec.rb +2 -2
  112. data/spec/metric_fu/metrics/flog/flog_grapher_spec.rb +3 -3
  113. data/spec/metric_fu/metrics/generator_spec.rb +1 -35
  114. data/spec/metric_fu/metrics/graph_spec.rb +7 -24
  115. data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +2 -2
  116. data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +2 -2
  117. data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +5 -5
  118. data/spec/metric_fu/metrics/hotspots/hotspots_spec.rb +2 -3
  119. data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_grapher_spec.rb +2 -2
  120. data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_spec.rb +1 -1
  121. data/spec/metric_fu/metrics/rcov/rcov_grapher_spec.rb +2 -2
  122. data/spec/metric_fu/metrics/rcov/rcov_spec.rb +1 -4
  123. data/spec/metric_fu/metrics/reek/reek_grapher_spec.rb +2 -2
  124. data/spec/metric_fu/metrics/reek/reek_spec.rb +1 -1
  125. data/spec/metric_fu/metrics/roodi/roodi_grapher_spec.rb +2 -2
  126. data/spec/metric_fu/metrics/roodi/roodi_spec.rb +3 -3
  127. data/spec/metric_fu/metrics/saikuro/saikuro_spec.rb +14 -10
  128. data/spec/metric_fu/metrics/stats/stats_grapher_spec.rb +2 -2
  129. data/spec/metric_fu/reporting/graphs/{engines/bluff_spec.rb → grapher_spec.rb} +8 -2
  130. data/spec/{run_spec.rb → metric_fu/run_spec.rb} +8 -13
  131. data/spec/spec_helper.rb +30 -5
  132. data/spec/support/deferred_garbaged_collection.rb +34 -0
  133. data/spec/support/helper_methods.rb +1 -15
  134. data/spec/support/suite.rb +4 -24
  135. data/spec/support/test_fixtures.rb +39 -0
  136. data/spec/support/timeout.rb +7 -0
  137. metadata +129 -104
  138. metadata.gz.sig +1 -0
  139. data/lib/metric_fu/metrics/cane/cane_bluff_grapher.rb +0 -16
  140. data/lib/metric_fu/metrics/cane/cane_gchart_grapher.rb +0 -25
  141. data/lib/metric_fu/metrics/flay/flay_bluff_grapher.rb +0 -16
  142. data/lib/metric_fu/metrics/flay/flay_gchart_grapher.rb +0 -20
  143. data/lib/metric_fu/metrics/flog/flog_bluff_grapher.rb +0 -17
  144. data/lib/metric_fu/metrics/flog/flog_gchart_grapher.rb +0 -28
  145. data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices_bluff_grapher.rb +0 -16
  146. data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices_gchart_grapher.rb +0 -27
  147. data/lib/metric_fu/metrics/rcov/rcov_bluff_grapher.rb +0 -16
  148. data/lib/metric_fu/metrics/rcov/rcov_gchart_grapher.rb +0 -22
  149. data/lib/metric_fu/metrics/reek/reek_bluff_grapher.rb +0 -16
  150. data/lib/metric_fu/metrics/reek/reek_gchart_grapher.rb +0 -30
  151. data/lib/metric_fu/metrics/roodi/roodi_bluff_grapher.rb +0 -16
  152. data/lib/metric_fu/metrics/roodi/roodi_gchart_grapher.rb +0 -20
  153. data/lib/metric_fu/metrics/stats/stats_bluff_grapher.rb +0 -17
  154. data/lib/metric_fu/metrics/stats/stats_gchart_grapher.rb +0 -27
  155. data/lib/metric_fu/reporting/graphs/engines/bluff.rb +0 -33
  156. data/lib/metric_fu/reporting/graphs/engines/gchart.rb +0 -72
  157. data/lib/metric_fu/reporting/graphs/engines/init.rb +0 -19
  158. data/lib/metric_fu_requires.rb +0 -63
  159. data/spec/metric_fu/reporting/graphs/engines/gchart_spec.rb +0 -161
@@ -0,0 +1 @@
1
+ �Vm2G��������@�����p�d��g�\��{��c�������ˤY8ܨI>�ӵ��4'Ξ��jL>���U���`��Y��!a�l:� �k4���u���� ;����E�������i�p�.<[T��X`�n}�H-��w\��XMƗ�"7���/7m]t�q\D����mj?����j��|m?O0v�1�ʀ� 0H��p�-`�8�:^��p�/� dY�tUG٢X�Mn5}T� R��2n�IO\���Dd-�7
@@ -1,16 +0,0 @@
1
- MetricFu.metrics_require { 'cane/cane_grapher' }
2
- module MetricFu
3
- class CaneBluffGrapher < CaneGrapher
4
- def title
5
- 'Cane: code quality threshold violations'
6
- end
7
- def data
8
- [
9
- ['cane', @cane_violations.join(',')]
10
- ]
11
- end
12
- def output_filename
13
- 'cane.js'
14
- end
15
- end
16
- end
@@ -1,25 +0,0 @@
1
- MetricFu.metrics_require { 'cane/cane_grapher' }
2
- module MetricFu
3
- class CaneGchartGrapher < CaneGrapher
4
- def title
5
- 'Cane: code quality threshold violations'
6
- end
7
- def legend
8
- ['violations']
9
- end
10
- def data
11
- @cane_violations
12
- end
13
- def output_filename
14
- 'cane.png'
15
- end
16
- def gchart_line_options
17
- super.merge({
18
- :legend => legend,
19
- })
20
- end
21
- def y_axis_scale_argument
22
- @cane_violations
23
- end
24
- end
25
- end
@@ -1,16 +0,0 @@
1
- MetricFu.metrics_require { 'flay/flay_grapher' }
2
- module MetricFu
3
- class FlayBluffGrapher < FlayGrapher
4
- def title
5
- 'Flay: duplication'
6
- end
7
- def data
8
- [
9
- ['flay', @flay_score.join(',')]
10
- ]
11
- end
12
- def output_filename
13
- 'flay.js'
14
- end
15
- end
16
- end
@@ -1,20 +0,0 @@
1
- MetricFu.metrics_require { 'flay/flay_grapher' }
2
- module MetricFu
3
- class FlayGchartGrapher < FlayGrapher
4
- def title
5
- "Flay: duplication"
6
- end
7
- def data
8
- @flay_score
9
- end
10
- def output_filename
11
- 'flay.png'
12
- end
13
- def gchart_line_options
14
- super
15
- end
16
- def y_axis_scale_argument
17
- @flay_score
18
- end
19
- end
20
- end
@@ -1,17 +0,0 @@
1
- MetricFu.metrics_require { 'flog/flog_grapher' }
2
- module MetricFu
3
- class FlogBluffGrapher < FlogGrapher
4
- def title
5
- 'Flog: code complexity'
6
- end
7
- def data
8
- [
9
- ['average', @flog_average.join(',')],
10
- ['top 5% average', @top_five_percent_average.join(',')]
11
- ]
12
- end
13
- def output_filename
14
- 'flog.js'
15
- end
16
- end
17
- end
@@ -1,28 +0,0 @@
1
- MetricFu.metrics_require { 'flog/flog_grapher' }
2
- module MetricFu
3
- class FlogGchartGrapher < FlogGrapher
4
- def title
5
- "Flog: code complexity"
6
- end
7
- def legend
8
- ['average', 'top 5% average']
9
- end
10
- def data
11
- [@flog_average, @top_five_percent_average]
12
- end
13
- def output_filename
14
- 'flog.png'
15
- end
16
- def gchart_line_options
17
- super.merge({
18
- :bar_colors => COLORS[0..1],
19
- :legend => legend,
20
- :custom => 'chdlp=t',
21
- :stacked => false,
22
- })
23
- end
24
- def y_axis_scale_argument
25
- @top_five_percent_average + @flog_average
26
- end
27
- end
28
- end
@@ -1,16 +0,0 @@
1
- MetricFu.metrics_require { 'rails_best_practices/rails_best_practices_grapher' }
2
- module MetricFu
3
- class RailsBestPracticesBluffGrapher < RailsBestPracticesGrapher
4
- def title
5
- 'Rails Best Practices: design problems'
6
- end
7
- def data
8
- [
9
- ['rails_best_practices', @rails_best_practices_count.join(',')]
10
- ]
11
- end
12
- def output_filename
13
- 'rails_best_practices.js'
14
- end
15
- end
16
- end
@@ -1,27 +0,0 @@
1
- MetricFu.metrics_require { 'rails_best_practices/rails_best_practices_grapher' }
2
- module MetricFu
3
- class RailsBestPracticesGchartGrapher < RailsBestPracticesGrapher
4
- def title
5
- "Rails Best Practices: design problems"
6
- end
7
- def legend
8
- ['Problems']
9
- end
10
- def data
11
- self.rails_best_practices_count
12
- end
13
- def output_filename
14
- 'rails_best_practices.png'
15
- end
16
- def gchart_line_options
17
- super.merge({
18
- :bar_colors => COLORS[0..1],
19
- :legend => legend,
20
- :custom => 'chdlp=t',
21
- })
22
- end
23
- def y_axis_scale_argument
24
- @rails_best_practices_count
25
- end
26
- end
27
- end
@@ -1,16 +0,0 @@
1
- MetricFu.metrics_require { 'rcov/rcov_grapher' }
2
- module MetricFu
3
- class RcovBluffGrapher < RcovGrapher
4
- def title
5
- 'Rcov: code coverage'
6
- end
7
- def data
8
- [
9
- ['rcov', @rcov_percent.join(',')]
10
- ]
11
- end
12
- def output_filename
13
- 'rcov.js'
14
- end
15
- end
16
- end
@@ -1,22 +0,0 @@
1
- MetricFu.metrics_require { 'rcov/rcov_grapher' }
2
- module MetricFu
3
- class RcovGchartGrapher < RcovGrapher
4
- def title
5
- "Rcov: code coverage"
6
- end
7
- def data
8
- self.rcov_percent
9
- end
10
- def output_filename
11
- 'rcov.png'
12
- end
13
- # overrides method
14
- def y_axis_scale_options
15
- {
16
- :max_value => 101,
17
- :axis_with_labels => 'x,y',
18
- :axis_labels => [self.labels.values, [0,20,40,60,80,100]],
19
- }
20
- end
21
- end
22
- end
@@ -1,16 +0,0 @@
1
- MetricFu.metrics_require { 'reek/reek_grapher' }
2
- module MetricFu
3
- class ReekBluffGrapher < ReekGrapher
4
- def title
5
- 'Reek: code smells'
6
- end
7
- def data
8
- @reek_count.map do |name, count|
9
- [name, count.join(',')]
10
- end
11
- end
12
- def output_filename
13
- 'reek.js'
14
- end
15
- end
16
- end
@@ -1,30 +0,0 @@
1
- MetricFu.metrics_require { 'reek/reek_grapher' }
2
- module MetricFu
3
- class ReekGchartGrapher < ReekGrapher
4
- def title
5
- "Reek: code smells"
6
- end
7
- def legend
8
- @legend ||= @reek_count.keys.sort
9
- end
10
- def data
11
- values = []
12
- legend.collect {|k| values << @reek_count[k]}
13
- values
14
- end
15
- def output_filename
16
- 'reek.png'
17
- end
18
- def gchart_line_options
19
- super.merge({
20
- :bar_colors => COLORS,
21
- :stacked => false,
22
- :legend => legend,
23
- :custom => 'chdlp=t',
24
- })
25
- end
26
- def y_axis_scale_argument
27
- @reek_count.values.flatten.uniq
28
- end
29
- end
30
- end
@@ -1,16 +0,0 @@
1
- MetricFu.metrics_require { 'roodi/roodi_grapher' }
2
- module MetricFu
3
- class RoodiBluffGrapher < RoodiGrapher
4
- def title
5
- 'Roodi: design problems'
6
- end
7
- def data
8
- [
9
- ['roodi', @roodi_count.join(',')]
10
- ]
11
- end
12
- def output_filename
13
- 'roodi.js'
14
- end
15
- end
16
- end
@@ -1,20 +0,0 @@
1
- MetricFu.metrics_require { 'roodi/roodi_grapher' }
2
- module MetricFu
3
- class RoodiGchartGrapher < RoodiGrapher
4
- def title
5
- "Roodi: potential design problems"
6
- end
7
- def data
8
- @roodi_count
9
- end
10
- def output_filename
11
- 'roodi.png'
12
- end
13
- def gchart_line_options
14
- super
15
- end
16
- def y_axis_scale_argument
17
- @roodi_count
18
- end
19
- end
20
- end
@@ -1,17 +0,0 @@
1
- MetricFu.metrics_require { 'stats/stats_grapher' }
2
- module MetricFu
3
- class StatsBluffGrapher < StatsGrapher
4
- def title
5
- 'Stats: LOC & LOT'
6
- end
7
- def data
8
- [
9
- ['LOC', @loc_counts.join(',')],
10
- ['LOT', @lot_counts.join(',')],
11
- ]
12
- end
13
- def output_filename
14
- 'stats.js'
15
- end
16
- end
17
- end
@@ -1,27 +0,0 @@
1
- MetricFu.metrics_require { 'stats/stats_grapher' }
2
- module MetricFu
3
- class StatsGchartGrapher < StatsGrapher
4
- def title
5
- "Stats: LOC & LOT"
6
- end
7
- def data
8
- [@loc_counts, @lot_counts]
9
- end
10
- def output_filename
11
- 'stats.png'
12
- end
13
- def legend
14
- ['Lines of code', 'Lines of test']
15
- end
16
- def gchart_line_options
17
- super.merge({
18
- :bar_colors => COLORS[0..1],
19
- :legend => legend,
20
- :custom => 'chdlp=t',
21
- })
22
- end
23
- def y_axis_scale_argument
24
- @loc_counts + @lot_counts
25
- end
26
- end
27
- end
@@ -1,33 +0,0 @@
1
- module MetricFu
2
- class Grapher
3
- BLUFF_GRAPH_SIZE = "1000x600"
4
- BLUFF_DEFAULT_OPTIONS = <<-EOS
5
- var g = new Bluff.Line('graph', "#{BLUFF_GRAPH_SIZE}");
6
- g.theme_37signals();
7
- g.tooltips = true;
8
- g.title_font_size = "24px"
9
- g.legend_font_size = "12px"
10
- g.marker_font_size = "10px"
11
- EOS
12
- def graph!
13
- title = send(:title)
14
- data = send(:data)
15
- labels = MultiJson.dump(@labels)
16
- output_filename = send(:output_filename)
17
- content = <<-EOS
18
- #{BLUFF_DEFAULT_OPTIONS}
19
- g.title = '#{title}';
20
- #{build_data(data)}
21
- g.labels = #{labels};
22
- g.draw();
23
- EOS
24
- File.open(File.join(self.output_directory, output_filename), 'w') {|f| f << content }
25
- end
26
- private
27
- def build_data(data)
28
- Array(data).map do |label, datum|
29
- "g.data('#{label}', [#{datum}]);"
30
- end.join("\n")
31
- end
32
- end
33
- end
@@ -1,72 +0,0 @@
1
- module MetricFu
2
- module GchartGrapher
3
- COLORS = %w{009999 FF7400 A60000 008500 E6399B 344AD7 00B860 D5CCB9}
4
- GCHART_GRAPH_SIZE = "945x317" # maximum permitted image size is 300000 pixels
5
- NUMBER_OF_TICKS = 6
6
-
7
- # @see gchart_line_options
8
- def graph!
9
- options = gchart_line_options.reject{|_,v|v.nil?}
10
- Gchart.line(options)
11
- end
12
- # @note Some values are initialized as nil to maintain consistent
13
- # key ordering for the tests. Any keys with nil values are removed
14
- # before graphing
15
- def gchart_line_options
16
- {
17
- :size => GCHART_GRAPH_SIZE,
18
- :title => URI.encode(title),
19
- :data => data,
20
- :stacked => nil,
21
- :bar_colors => nil,
22
- :legend => nil,
23
- :custom => nil,
24
- :max_value => nil,
25
- :axis_with_labels => nil,
26
- :axis_labels => nil,
27
- :format => 'file',
28
- :filename => File.join(self.output_directory, output_filename),
29
- }.merge(y_axis_scale_options)
30
- end
31
- def y_axis_scale_options
32
- determine_y_axis_scale(y_axis_scale_argument)
33
- {
34
- :max_value => @max_value,
35
- :axis_with_labels => 'x,y',
36
- :axis_labels => [@labels.values, @yaxis],
37
- }
38
- end
39
- def determine_y_axis_scale(values)
40
- values = Array(values)
41
- values.collect! {|val| val || 0.0 }
42
- if values.empty?
43
- @max_value = 10
44
- @yaxis = [0, 2, 4, 6, 8, 10]
45
- else
46
- @max_value = values.max + Integer(0.1 * values.max)
47
- portion_size = (@max_value / (NUMBER_OF_TICKS - 1).to_f).ceil
48
- @yaxis = []
49
- NUMBER_OF_TICKS.times {|n| @yaxis << Integer(portion_size * n) }
50
- @max_value = @yaxis.last
51
- end
52
- end
53
- def y_axis_scale_argument
54
- raise "#{__LINE__} in #{__FILE__} from #{caller.join('\n')}"
55
- end
56
- end
57
-
58
- class Grapher
59
-
60
- def self.require_graphing_gem
61
- if MetricFu.configuration.graph_engine == :gchart
62
- require 'gchart'
63
- include MetricFu::GchartGrapher
64
- end
65
- rescue LoadError
66
- mf_log "#"*99 + "\n" +
67
- "If you want to use google charts for graphing, you'll need to install the googlecharts rubygem." +
68
- "\n" + "#"*99
69
- end
70
- end
71
-
72
- end