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
@@ -1,12 +1,8 @@
1
1
  <h3>Lines of Code/Tests Metric Results</h3>
2
2
 
3
3
  <% graph_name = 'stats' %>
4
- <% if MetricFu.configuration.graph_engine == :gchart %>
5
- <img src="<%= graph_name %>.png?<%= Time.now.to_i %>" />
6
- <% else %>
7
4
  <canvas id="graph"></canvas>
8
5
  <script language="javascript" src="<%= graph_name %>.js?<%= Time.now.to_i %>" type="text/javascript"></script>
9
- <% end %>
10
6
 
11
7
 
12
8
  <p>Lines of Code/Tests Metrics Results</p>
@@ -1,9 +1,35 @@
1
+ # Class opened and modified by requiring a graph engine
2
+ require 'multi_json'
1
3
  module MetricFu
2
4
  class Grapher
5
+
6
+ @graphers = []
7
+ # @return all subclassed graphers [Array<MetricFu::Grapher>]
8
+ def self.graphers
9
+ @graphers
10
+ end
11
+
12
+ def self.inherited(subclass)
13
+ @graphers << subclass
14
+ end
15
+
16
+ def self.get_grapher(metric)
17
+ graphers.find{|grapher|grapher.metric.to_s == metric.to_s}
18
+ end
19
+
20
+ BLUFF_GRAPH_SIZE = "1000x600"
21
+ BLUFF_DEFAULT_OPTIONS = <<-EOS
22
+ var g = new Bluff.Line('graph', "#{BLUFF_GRAPH_SIZE}");
23
+ g.theme_37signals();
24
+ g.tooltips = true;
25
+ g.title_font_size = "24px"
26
+ g.legend_font_size = "12px"
27
+ g.marker_font_size = "10px"
28
+ EOS
29
+
3
30
  attr_accessor :output_directory
4
31
 
5
32
  def initialize(opts = {})
6
- self.class.require_graphing_gem
7
33
  self.output_directory = opts[:output_directory]
8
34
  end
9
35
 
@@ -11,8 +37,48 @@ module MetricFu
11
37
  @output_directory || MetricFu::Io::FileSystem.directory('output_directory')
12
38
  end
13
39
 
14
- def self.require_graphing_gem
15
- # to be overridden by charting engines
40
+ def get_metrics(metrics, sortable_prefix)
41
+ not_implemented
42
+ end
43
+
44
+ def graph!
45
+ title = send(:title)
46
+ data = send(:data)
47
+ labels = MultiJson.dump(@labels)
48
+ output_filename = send(:output_filename)
49
+ content = <<-EOS
50
+ #{BLUFF_DEFAULT_OPTIONS}
51
+ g.title = '#{title}';
52
+ #{build_data(data)}
53
+ g.labels = #{labels};
54
+ g.draw();
55
+ EOS
56
+ File.open(File.join(self.output_directory, output_filename), 'w') {|f| f << content }
57
+ end
58
+
59
+ def title
60
+ not_implemented
61
+ end
62
+
63
+ def date
64
+ not_implemented
16
65
  end
66
+
67
+ def output_filename
68
+ not_implemented
69
+ end
70
+
71
+ private
72
+
73
+ def build_data(data)
74
+ Array(data).map do |label, datum|
75
+ "g.data('#{label}', [#{datum}]);"
76
+ end.join("\n")
77
+ end
78
+
79
+ def not_implemented
80
+ raise "#{__LINE__} in #{__FILE__} from #{caller[0]}"
81
+ end
82
+
17
83
  end
18
84
  end
@@ -24,7 +24,11 @@ module MetricFu
24
24
  end
25
25
 
26
26
  def per_file_data
27
- @per_file_data ||= {}
27
+ @per_file_data ||= Hash.new do |hash, filename|
28
+ hash[filename] = Hash.new do |h, line|
29
+ h[line] = Array.new
30
+ end
31
+ end
28
32
  end
29
33
 
30
34
  def result_hash #:nodoc:
@@ -1,3 +1,4 @@
1
+ require 'fileutils'
1
2
  require 'coderay'
2
3
  MetricFu.metrics_require { 'base_template' }
3
4
  MetricFu.lib_require { 'utility' }
@@ -6,8 +7,8 @@ class AwesomeTemplate < MetricFu::Template
6
7
 
7
8
  def write
8
9
  # Getting rid of the crap before and after the project name from integrity
9
- # @name = File.basename(Dir.pwd).gsub(/^\w+-|-\w+$/, "")
10
- @name = Pathname.new(Dir.pwd).basename
10
+ # @name = File.basename(MetricFu.run_dir).gsub(/^\w+-|-\w+$/, "")
11
+ @name = Pathname.new(MetricFu.run_dir).basename
11
12
 
12
13
  # Copy Bluff javascripts to output directory
13
14
  Dir[File.join(template_directory, '..', 'javascripts', '*')].each do |f|
@@ -66,7 +67,10 @@ class AwesomeTemplate < MetricFu::Template
66
67
  def write_file_data
67
68
 
68
69
  per_file_data.each_pair do |file, lines|
69
- data = File.open(file, 'r').readlines
70
+ next if file.to_s.empty?
71
+ next unless File.file?(file)
72
+
73
+ data = File.readlines(file)
70
74
  fn = "#{file.gsub(%r{/}, '_')}.html"
71
75
 
72
76
  out = <<-HTML
@@ -3,7 +3,6 @@ module MetricFu
3
3
  class Run
4
4
  def initialize
5
5
  STDOUT.sync = true
6
- load_user_configuration
7
6
  end
8
7
  def run(options={})
9
8
  configure_run(options)
@@ -27,11 +26,6 @@ module MetricFu
27
26
  reporter.display_results
28
27
  end
29
28
  private
30
- def load_user_configuration
31
- file = File.join(Dir.pwd, '.metrics')
32
- load file if File.exist?(file)
33
- end
34
- # Updates configuration based on runtime options.
35
29
  def configure_run(options)
36
30
  disable_metrics(options)
37
31
  configure_formatters(options)
@@ -39,8 +33,10 @@ module MetricFu
39
33
  def disable_metrics(options)
40
34
  return if options.size == 0
41
35
  report_metrics.each do |metric|
42
- if options[metric.to_sym]
36
+ metric = metric.to_sym
37
+ if (metric_options = options[metric] )
43
38
  mf_debug "using metric #{metric}"
39
+ configure_metric(metric, metric_options) if metric_options.is_a?(Hash)
44
40
  else
45
41
  mf_debug "disabling metric #{metric}"
46
42
  MetricFu::Metric.get_metric(metric).enabled = false
@@ -48,6 +44,16 @@ module MetricFu
48
44
  end
49
45
  end
50
46
  end
47
+ def configure_metric(metric, metric_options)
48
+ MetricFu::Configuration.run do |config|
49
+ config.configure_metric(metric) do |metric|
50
+ metric_options.each do |option, value|
51
+ mf_log "Setting #{metric} option #{option} to #{value}"
52
+ metric.public_send("#{option}=", value)
53
+ end
54
+ end
55
+ end
56
+ end
51
57
  def configure_formatters(options)
52
58
  # Configure from command line if any.
53
59
  if options[:format]
@@ -1,7 +1,54 @@
1
1
  require 'rake'
2
+ require 'metric_fu/run'
2
3
  namespace :metrics do
3
- desc "Generate all metrics reports"
4
- task :all do
5
- MetricFu::Run.new.run
4
+ def options_tip(task_name)
5
+ "with options, for example: rake metrics:#{task_name}['cane: {abc_max: 81}']"
6
+ end
7
+ desc "Generate all metrics reports, or #{options_tip('all')}"
8
+ task :all, [:options] do |t,args|
9
+ MetricFu.run(process_options(args.options))
10
+ end
11
+
12
+ desc "Run only specified ;-separated metrics, for example, metrics:only[cane;flog] or #{options_tip('only')}"
13
+ task :only, [:metrics, :options] do |t,args|
14
+ requested_metrics = args.metrics.to_s.split(';').map(&:strip)
15
+ enabled_metrics = MetricFu::Metric.enabled_metrics.map(&:name)
16
+ metrics_to_run = enabled_metrics.select{|metric| requested_metrics.include?(metric.to_s) }
17
+ MetricFu.run_only(metrics_to_run, process_options(args.options))
18
+ end
19
+
20
+ MetricFu::Metric.enabled_metrics.each do |metric|
21
+ name = metric.name
22
+ desc "Generate report for #{name}, or #{options_tip('cane')}"
23
+ task name, [:options] do |t,args|
24
+ MetricFu.run_only(name, process_options(args.options))
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ # from https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/keys.rb
31
+ class Hash
32
+ # Destructively, recursively convert all keys to symbols, as long as they respond
33
+ # to +to_sym+.
34
+ def recursively_symbolize_keys!
35
+ keys.each do |key|
36
+ value = delete(key)
37
+ new_key = key.intern #rescue
38
+ self[new_key] = (value.is_a?(Hash) ? value.dup.recursively_symbolize_keys! : value)
39
+ end
40
+ self
41
+ end
42
+ end
43
+
44
+ def process_options(options)
45
+ return {} if options.nil? or options.empty?
46
+ options = YAML.load(options)
47
+ if options.is_a?(Hash)
48
+ p "Got options #{options.recursively_symbolize_keys!.inspect}"
49
+ options
50
+ else
51
+ raise "Invalid options #{options.inspect}, is a #{options.class}, should be a Hash"
52
+ end
6
53
  end
7
54
  end
@@ -1,3 +1,5 @@
1
+ require 'yaml'
2
+ require 'fileutils'
1
3
  module MetricFu
2
4
  module Utility
3
5
  module_function
@@ -23,5 +25,13 @@ module MetricFu
23
25
  FileUtils.mkdir_p(*args)
24
26
  end
25
27
 
28
+ def glob(*args)
29
+ Dir.glob(*args)
30
+ end
31
+
32
+ def load_yaml(file)
33
+ YAML.load_file(file)
34
+ end
35
+
26
36
  end
27
37
  end
@@ -1,3 +1,3 @@
1
1
  module MetricFu
2
- VERSION = "4.4.4"
2
+ VERSION = '4.5.1'
3
3
  end
@@ -8,7 +8,12 @@ Gem::Specification.new do |s|
8
8
  s.summary = "A fistful of code metrics, with awesome templates and graphs"
9
9
  s.description = "Code metrics from Flog, Flay, Saikuro, Churn, Reek, Roodi, Code Statistics, and Rails Best Practices. (and optionally RCov)"
10
10
  s.email = "github@benjaminfleischer.com"
11
- s.authors = File.readlines('AUTHORS').map(&:strip)
11
+ author_file = File.expand_path('AUTHORS', File.dirname(__FILE__))
12
+ s.authors = File.readlines(author_file).map(&:strip)
13
+
14
+ # used with gem i metric_fu -P HighSecurity
15
+ s.cert_chain = ['certs/bf4.pem']
16
+ s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
12
17
 
13
18
  s.rubyforge_project = 'metric_fu'
14
19
  s.license = 'MIT'
@@ -31,7 +36,7 @@ Gem::Specification.new do |s|
31
36
  s.add_runtime_dependency 'flay', ['>= 2.0.1', '~> 2.1']
32
37
  s.add_runtime_dependency 'churn', ['~> 0.0.28']
33
38
  s.add_runtime_dependency 'flog', ['>= 4.1.1', '~> 4.1']
34
- s.add_runtime_dependency 'reek', ['>= 1.3.3', '~> 1.3']
39
+ s.add_runtime_dependency 'reek', ['>= 1.3.4', '~> 1.3']
35
40
  s.add_runtime_dependency 'cane', ['>= 2.5.2', '~> 2.5']
36
41
  s.add_runtime_dependency 'rails_best_practices', ['>= 1.14.3', '~> 1.14']
37
42
  s.add_runtime_dependency 'metric_fu-Saikuro', ['>= 1.1.1.0']
@@ -43,8 +48,6 @@ Gem::Specification.new do |s|
43
48
  s.add_runtime_dependency 'redcard'
44
49
  # syntax highlighting
45
50
  s.add_runtime_dependency 'coderay'
46
- # default graphing libraries
47
- s.add_runtime_dependency 'bluff'
48
51
  # to_json support
49
52
  s.add_runtime_dependency 'multi_json'
50
53
 
@@ -0,0 +1 @@
1
+ tmp
File without changes
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # For testing that this file gets loaded
4
+ $metric_file_loaded = true
File without changes
File without changes
@@ -2957,7 +2957,7 @@
2957
2957
  - :was_run: false
2958
2958
  :content: " # Getting rid of the crap before and after the project name from integrity"
2959
2959
  - :was_run: false
2960
- :content: " @name = File.basename(Dir.pwd).gsub(/^\\w+-|-\\w+$/, \"\")"
2960
+ :content: " @name = File.basename(MetricFu.run_dir).gsub(/^\\w+-|-\\w+$/, \"\")"
2961
2961
  - :was_run: false
2962
2962
  :content: " "
2963
2963
  - :was_run: false
@@ -146,7 +146,7 @@ describe MetricFu::Configuration do
146
146
  it 'should set @reek to {:dirs_to_reek => @code_dirs}' do
147
147
  load_metric 'reek'
148
148
  expect(MetricFu::Metric.get_metric(:reek).run_options).to eq(
149
- {:config_file_pattern=>nil, :dirs_to_reek => ['lib']}
149
+ {:config_file_pattern=>'config/*.reek', :dirs_to_reek => ['lib']}
150
150
  )
151
151
  end
152
152
 
@@ -1,58 +1,60 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe MetricFu::LineNumbers do
4
-
4
+ FIXTURE_DATA = ->(paths) {
5
+ FIXTURE.load_file( ['line_numbers'].concat(Array(paths)) )
6
+ }
5
7
  describe "in_method?" do
6
8
  it "should know if a line is NOT in a method" do
7
- ln = MetricFu::LineNumbers.new(File.read("#{resources_path}/line_numbers/foo.rb"))
9
+ ln = MetricFu::LineNumbers.new(FIXTURE_DATA["foo.rb"])
8
10
  ln.in_method?(2).should == false
9
11
  end
10
12
 
11
13
  it "should know if a line is in an instance method" do
12
- ln = MetricFu::LineNumbers.new(File.read("#{resources_path}/line_numbers/foo.rb"))
14
+ ln = MetricFu::LineNumbers.new(FIXTURE_DATA["foo.rb"])
13
15
  ln.in_method?(8).should == true
14
16
  end
15
17
 
16
18
  it "should know if a line is in an class method" do
17
- ln = MetricFu::LineNumbers.new(File.read("#{resources_path}/line_numbers/foo.rb"))
19
+ ln = MetricFu::LineNumbers.new(FIXTURE_DATA["foo.rb"])
18
20
  ln.in_method?(3).should == true
19
21
  end
20
22
  end
21
23
 
22
24
  describe "method_at_line" do
23
25
  it "should know the name of an instance method at a particular line" do
24
- ln = MetricFu::LineNumbers.new(File.read("#{resources_path}/line_numbers/foo.rb"))
26
+ ln = MetricFu::LineNumbers.new(FIXTURE_DATA["foo.rb"])
25
27
  ln.method_at_line(8).should == "Foo#what"
26
28
  end
27
29
 
28
30
  it "should know the name of a class method at a particular line" do
29
- ln = MetricFu::LineNumbers.new(File.read("#{resources_path}/line_numbers/foo.rb"))
31
+ ln = MetricFu::LineNumbers.new(FIXTURE_DATA["foo.rb"])
30
32
  ln.method_at_line(3).should == "Foo::awesome"
31
33
  end
32
34
 
33
35
  it "should know the name of a private method at a particular line" do
34
- ln = MetricFu::LineNumbers.new(File.read("#{resources_path}/line_numbers/foo.rb"))
36
+ ln = MetricFu::LineNumbers.new(FIXTURE_DATA["foo.rb"])
35
37
  ln.method_at_line(28).should == "Foo#whoop"
36
38
  end
37
39
 
38
40
  it "should know the name of a class method defined in a 'class << self block at a particular line" do
39
- ln = MetricFu::LineNumbers.new(File.read("#{resources_path}/line_numbers/foo.rb"))
41
+ ln = MetricFu::LineNumbers.new(FIXTURE_DATA["foo.rb"])
40
42
  ln.method_at_line(22).should == "Foo::neat"
41
43
  end
42
44
 
43
45
  it "should know the name of an instance method at a particular line in a file with two classes" do
44
- ln = MetricFu::LineNumbers.new(File.read("#{resources_path}/line_numbers/two_classes.rb"))
46
+ ln = MetricFu::LineNumbers.new(FIXTURE_DATA["two_classes.rb"])
45
47
  ln.method_at_line(3).should == "Foo#stuff"
46
48
  ln.method_at_line(9).should == "Bar#stuff"
47
49
  end
48
50
 
49
51
  it "should work with modules" do
50
- ln = MetricFu::LineNumbers.new(File.read("#{resources_path}/line_numbers/module.rb"))
52
+ ln = MetricFu::LineNumbers.new(FIXTURE_DATA["module.rb"])
51
53
  ln.method_at_line(4).should == 'KickAss#get_beat_up?'
52
54
  end
53
55
 
54
56
  it "should work with module surrounding class" do
55
- ln = MetricFu::LineNumbers.new(File.read("#{resources_path}/line_numbers/module_surrounds_class.rb"))
57
+ ln = MetricFu::LineNumbers.new(FIXTURE_DATA["module_surrounds_class.rb"])
56
58
  ln.method_at_line(5).should == "StuffModule::ThingClass#do_it"
57
59
  # ln.method_at_line(12).should == "StuffModule#blah" #why no work?
58
60
  end