metric_fu 2.1.4.pre5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.metrics CHANGED
@@ -1,8 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # For testing that this file gets loaded
4
- puts "Metrics config loaded"
4
+ mf_debug "Metrics config loaded"
5
5
  # example configuration
6
6
  # MetricFu::Configuration.run do |config|
7
+ # coverage_file = File.expand_path("coverage/rcov/rcov.txt", Dir.pwd)
8
+ # config.add_metric(:rcov)
9
+ # config.add_graph(:rcov)
10
+ # config.configure_metric(:rcov, {:external => coverage_file})
11
+ # end
12
+ # or
13
+ # MetricFu::Configuration.run do |config|
7
14
  # config.metrics -= [ :rcov ]
8
15
  # end
16
+ # you may enable running rcov manually with
17
+ # MetricFu.run_rcov
data/Gemfile CHANGED
@@ -5,5 +5,10 @@ group :development, :test do
5
5
  gem "rspec", '>2'
6
6
  gem "test-construct", ">= 1.2.0"
7
7
  gem "googlecharts"
8
+ if ENV['COVERAGE']
9
+ gem 'simplecov'
10
+ # https://github.com/kina/simplecov-rcov-text
11
+ gem 'simplecov-rcov-text'
12
+ end
8
13
  end
9
14
  gemspec
data/README.md CHANGED
@@ -19,17 +19,53 @@ See `metric_fu --help` for more options
19
19
  It is currently testing on MRI 1.8.7, 1.9.2, and 1.9.3
20
20
 
21
21
  * The `japgolly-Saikuro` fork and `metric_fu-roodi` fork are a part of an attempt to get metric_fu working in a modern Ruby environment, specifically compatibility with Ruby 1.9 and Bundler.
22
- * rcov may fail in ruby 1.9
23
22
  * rails_best_practices is disabled in ruby 1.8
23
+ * metric_fu no longer runs rcov itself. You may still use rcov metrics as documented below
24
24
 
25
25
  ## Documentation
26
26
 
27
- TBD
28
-
29
27
  ### Configuration
30
28
 
31
29
  see the .metrics file
32
30
 
31
+ ### Using Coverage Metrics
32
+
33
+ in your .metrics file add the below to run pre-generated metrics
34
+
35
+ MetricFu::Configuration.run do |config|
36
+ coverage_file = File.expand_path("coverage/rcov/rcov.txt", Dir.pwd)
37
+ config.add_metric(:rcov)
38
+ config.add_graph(:rcov)
39
+ config.configure_metric(:rcov, {:external => coverage_file})
40
+ end
41
+
42
+ if you want metric_fu to actually run rcov itself (1.8 only), just add
43
+
44
+ MetricFu.run_rcov
45
+
46
+ #### Rcov metrics with Ruby 1.8
47
+
48
+ To generate the same metrics metric_fu has been generating run from the root of your project before running metric_fu
49
+
50
+ RAILS_ENV=test rcov $(ruby -e "puts Dir['{spec,test}/**/*_{spec,test}.rb'].join(' ')") --sort coverage --no-html --text-coverage --no-color --profile --exclude-only '.*' --include-file "\Aapp,\Alib" -Ispec >> coverage/rcov/rcov.txt
51
+
52
+ #### Simplecov metrics with Ruby 1.9
53
+
54
+ Add to your Gemfile or otherwise install
55
+
56
+ gem 'simplecov'
57
+ # https://github.com/kina/simplecov-rcov-text
58
+ gem 'simplecov-rcov-text'
59
+
60
+ Modify your spec_helper as per the SimpleCov docs and run your tests before running metric_fu
61
+
62
+ #in your spec_helper
63
+ require 'simplecov'
64
+ require 'simplecov-rcov-text'
65
+ SimpleCov.formatter = SimpleCov::Formatter::RcovTextFormatter
66
+ SimpleCov.start
67
+ # SimpleCov.start 'rails'
68
+
33
69
  ### Historical
34
70
 
35
71
  There is some useful-but-out-of-date documentation about configuring metric_fu at http://metric-fu.rubyforge.org/ and a change log in the the HISTORY file.
data/lib/metric_fu.rb CHANGED
@@ -42,11 +42,26 @@ module MetricFu
42
42
  end
43
43
  def self.configure
44
44
  MetricFu.lib_require { 'configuration' }
45
- Dir.glob(File.join(MetricFu.metrics_dir, '**/init.rb')).each do |file|
45
+ init_files = Dir.glob(File.join(MetricFu.metrics_dir, '**/init.rb')).reject do |file|
46
+ if file =~ /rcov/
47
+ MetricFu.configuration.mf_debug("rcov is not available. See README")
48
+ true
49
+ else
50
+ false
51
+ end
52
+ end
53
+ init_files.each do |file|
46
54
  load file
47
55
  end
48
56
  MetricFu.configuration
49
57
  end
58
+ def self.run_rcov
59
+ load File.join(MetricFu.metrics_dir, 'rcov/init.rb')
60
+ end
61
+ def self.skip_rcov
62
+ MetricFu.metrics -= [:rcov]
63
+ MetricFu.graphs -= [:rcov]
64
+ end
50
65
  class << self
51
66
  %w(scratch output _data).each do |dir|
52
67
  define_method("#{dir.gsub(/[^A-Za-z0-9]/,'')}_dir") do
@@ -4,9 +4,11 @@ require 'metric_fu/cli/parser'
4
4
  module MetricFu
5
5
  module Cli
6
6
  class Helper
7
+ def initialize
8
+ @metric_fu = MetricFu::Run.new
9
+ end
7
10
  def run(options={})
8
- @metric_fu = MetricFu::Run.new(options)
9
- @metric_fu.run
11
+ @metric_fu.run(options)
10
12
  complete
11
13
  end
12
14
  def version
@@ -23,7 +23,7 @@ Dir.glob(File.join(MetricFu.errors_dir, '**/*.rb')).each do |file|
23
23
  require file
24
24
  end
25
25
  Dir.glob(File.join(MetricFu.metrics_dir, '**/*.rb')).each do |file|
26
- require file
26
+ require(file) unless file =~ /init.rb/
27
27
  end
28
28
  Dir.glob(File.join(MetricFu.reporting_dir, '**/*.rb')).each do |file|
29
29
  require file
data/lib/metric_fu/run.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  MetricFu.configure
2
2
  module MetricFu
3
3
  class Run
4
- def initialize(options={})
4
+ def initialize
5
5
  STDOUT.sync = true
6
6
  load_user_configuration
7
- disable_metrics(options)
8
7
  end
9
- def run
8
+ def run(options={})
9
+ disable_metrics(options)
10
10
  run_reports
11
11
  save_reports
12
12
  save_graphs
@@ -1,3 +1,3 @@
1
1
  module MetricFu
2
- VERSION = "2.1.4.pre5"
2
+ VERSION = "3.0.0"
3
3
  end
data/metric_fu.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.summary = "A fistful of code metrics, with awesome templates and graphs"
11
11
  s.email = "github@benjaminfleischer.com"
12
12
  s.homepage = "http://github.com/metricfu/metric_fu"
13
- s.description = "Code metrics from Flog, Flay, RCov, Saikuro, Churn, Reek, Roodi, Rails' stats task and Rails Best Practices"
13
+ s.description = "Code metrics from Flog, Flay, Saikuro, Churn, Reek, Roodi, Rails' stats task and Rails Best Practices, and optionally RCov"
14
14
  s.authors = ["Jake Scruggs", "Sean Soper", "Andre Arko", "Petrik de Heus", "Grant McInnes", "Nick Quaranto", "Édouard Brière", "Carl Youngblood", "Richard Huang", "Dan Mayer", "Benjamin Fleischer"]
15
15
  s.rubyforge_project = 'metric_fu'
16
16
  s.required_ruby_version = ">= 1.8.7"
@@ -23,10 +23,6 @@ Gem::Specification.new do |s|
23
23
 
24
24
  {
25
25
  "rails_best_practices" => ["= #{MetricFu::MetricVersion.rails_best_practices}"],
26
- "rcov" => ["#{MetricFu::MetricVersion.rcov}"],
27
- # still using rcov in ruby 1.9 till some errors are fleshed out
28
- # "simplecov" => [">= 0.5.4"],
29
- # "simplecov-rcov" => [">= 0.2.3"],
30
26
  "japgolly-Saikuro" => ["#{MetricFu::MetricVersion.saikuro}"],
31
27
  "metric_fu-roodi" => [">= #{MetricFu::MetricVersion.roodi}"],
32
28
  "flay" => ["= #{MetricFu::MetricVersion.flay}"],
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'metric_fu/cli/helper'
3
+ MetricFu.run_rcov
3
4
 
4
5
  describe MetricFu::Cli::Helper do
5
6
 
@@ -7,6 +7,7 @@ describe MetricFu::Configuration do
7
7
  @config = MetricFu.configuration
8
8
  @config.reset
9
9
  MetricFu.configure
10
+ MetricFu.run_rcov
10
11
  @config.stub :create_directories # no need to create directories for the tests
11
12
  @config
12
13
  end
@@ -284,8 +284,6 @@ __
284
284
  :add_coverage_percentage: 1.3
285
285
  :read: 1.3
286
286
  :[]: 2.70000000000001
287
- :average_score: 27.8909176873585
288
- :total_score: 195.23642381151
289
287
  - :highest_score: 60.0573892206447
290
288
  :path: lib/base/metric_analyzer.rb
291
289
  :methods:
@@ -307,6 +305,8 @@ __
307
305
  :==: 3.1
308
306
  :to_s: 1.3
309
307
  :[]: 5.40000000000001
308
+ :average_score: 27.8909176873585
309
+ :total_score: 195.23642381151
310
310
  __
311
311
  end
312
312
 
@@ -3,7 +3,8 @@ require "spec_helper"
3
3
  describe MetricFu::Rcov do
4
4
 
5
5
  before :each do
6
- MetricFu::Configuration.run {}
6
+ MetricFu.configure
7
+ MetricFu.run_rcov
7
8
  File.stub!(:directory?).and_return(true)
8
9
  @rcov = MetricFu::Rcov.new('base_dir')
9
10
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,10 @@
1
+ if ENV['COVERAGE']
2
+ require 'simplecov'
3
+ require 'simplecov-rcov-text'
4
+ SimpleCov.formatter = SimpleCov::Formatter::RcovTextFormatter
5
+ SimpleCov.start
6
+ end
7
+
1
8
  require 'rspec/autorun'
2
9
  require 'date'
3
10
  require 'construct'
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metric_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4.pre5
5
- prerelease: 6
4
+ version: 3.0.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jake Scruggs
@@ -19,7 +19,7 @@ authors:
19
19
  autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
- date: 2013-02-04 00:00:00.000000000 Z
22
+ date: 2013-02-07 00:00:00.000000000 Z
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: rails_best_practices
@@ -37,22 +37,6 @@ dependencies:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
39
  version: 1.13.2
40
- - !ruby/object:Gem::Dependency
41
- name: rcov
42
- requirement: !ruby/object:Gem::Requirement
43
- none: false
44
- requirements:
45
- - - ~>
46
- - !ruby/object:Gem::Version
47
- version: '0.8'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
53
- - - ~>
54
- - !ruby/object:Gem::Version
55
- version: '0.8'
56
40
  - !ruby/object:Gem::Dependency
57
41
  name: japgolly-Saikuro
58
42
  requirement: !ruby/object:Gem::Requirement
@@ -315,8 +299,8 @@ dependencies:
315
299
  - - ! '>='
316
300
  - !ruby/object:Gem::Version
317
301
  version: '0'
318
- description: Code metrics from Flog, Flay, RCov, Saikuro, Churn, Reek, Roodi, Rails'
319
- stats task and Rails Best Practices
302
+ description: Code metrics from Flog, Flay, Saikuro, Churn, Reek, Roodi, Rails' stats
303
+ task and Rails Best Practices, and optionally RCov
320
304
  email: github@benjaminfleischer.com
321
305
  executables:
322
306
  - metric_fu