metric_fu-metrical 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/metric_fu-metrical +1 -1
- data/bin/metrical +4 -0
- data/lib/metrical.rb +2 -73
- data/lib/metrical/version.rb +1 -1
- data/metrical.gemspec +13 -14
- metadata +33 -109
- data/.gitignore +0 -6
- data/.metrics +0 -4
- data/.rspec +0 -3
- data/.travis.yml +0 -7
- data/Gemfile +0 -4
- data/README.md +0 -121
- data/Rakefile +0 -8
- data/lib/metrical/options.rb +0 -61
- data/spec/options_spec.rb +0 -181
- data/spec/running_spec.rb +0 -46
- data/spec/spec_helper.rb +0 -34
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 964f9a4af46238aaf4e5f0815221060e021f8ddd
|
4
|
+
data.tar.gz: 5b185dc63fd31c838107948f79eb22bc6bc377e1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f403d028e02659c010c02e055a2c6909af8d009cb48ebc733a425b1e6b46a703bb7a2f9a65dfeafea6018de69ced9bf2be99e30667cabb02079ea933b6566a7
|
7
|
+
data.tar.gz: 122db2e33f739b7b32a308dadc6b9df6678c70b90f5400eefaf73720239a568e6b7a52467669955dcabfdad05660384b042e339a52644adf88379d32eb59102a
|
data/bin/metric_fu-metrical
CHANGED
data/bin/metrical
ADDED
data/lib/metrical.rb
CHANGED
@@ -1,78 +1,7 @@
|
|
1
1
|
require "metrical/version"
|
2
|
-
require "metrical/options"
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
require 'json'
|
6
|
-
require 'metric_fu'
|
7
|
-
|
8
|
-
# Required for RCOV
|
9
|
-
require 'active_support'
|
10
|
-
require 'active_support/core_ext'
|
11
2
|
|
12
3
|
module Metrical
|
13
|
-
|
14
|
-
|
15
|
-
def run(argv)
|
16
|
-
options = Options.parse(argv)
|
17
|
-
load_defaults
|
18
|
-
set_new_rcov_defaults
|
19
|
-
load_user_configuration
|
20
|
-
disable_metrics(options)
|
21
|
-
run_metric_fu
|
22
|
-
open_in_browser if options[:open]
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def disable_metrics(options)
|
28
|
-
options[:metrics].each do |metric, chosen|
|
29
|
-
unless chosen
|
30
|
-
MetricFu.configuration.metrics -= [ metric ]
|
31
|
-
MetricFu.configuration.graphs -= [ metric ]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def load_defaults
|
37
|
-
MetricFu::Configuration.run {}
|
38
|
-
end
|
39
|
-
|
40
|
-
def set_new_rcov_defaults
|
41
|
-
test_files = Dir['{spec,test}/**/*_{spec,test}.rb']
|
42
|
-
MetricFu::Configuration.run do |config|
|
43
|
-
config.rcov[:test_files] = test_files
|
44
|
-
config.rcov[:rcov_opts] = [
|
45
|
-
"--sort coverage",
|
46
|
-
"--no-html",
|
47
|
-
"--text-coverage",
|
48
|
-
"--no-color",
|
49
|
-
"--profile",
|
50
|
-
"--exclude-only '.*'",
|
51
|
-
'--include-file "\Aapp,\Alib"'
|
52
|
-
]
|
53
|
-
config.rcov[:rcov_opts] << "-Ispec" if File.exist?("spec")
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def load_user_configuration
|
58
|
-
file = File.join(Dir.pwd, '.metrics')
|
59
|
-
load file if File.exist?(file)
|
4
|
+
def self.message
|
5
|
+
"Please install metric_fu. It runs from the command-line now. And gem metrical metric_fu-metrical. Thanks :)"
|
60
6
|
end
|
61
|
-
|
62
|
-
def run_metric_fu
|
63
|
-
MetricFu.metrics.each {|metric| MetricFu.report.add(metric) }
|
64
|
-
MetricFu.report.save_output(MetricFu.report.to_yaml, MetricFu.base_directory, "report.yml")
|
65
|
-
MetricFu.report.save_output(MetricFu.report.to_yaml, MetricFu.data_directory, "#{Time.now.strftime("%Y%m%d")}.yml")
|
66
|
-
MetricFu.report.save_templatized_report
|
67
|
-
|
68
|
-
MetricFu.graphs.each {|graph| MetricFu.graph.add(graph, MetricFu.graph_engine) }
|
69
|
-
MetricFu.graph.generate
|
70
|
-
end
|
71
|
-
|
72
|
-
def open_in_browser
|
73
|
-
if MetricFu.report.open_in_browser?
|
74
|
-
MetricFu.report.show_in_browser(MetricFu.output_directory)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
7
|
end
|
data/lib/metrical/version.rb
CHANGED
data/metrical.gemspec
CHANGED
@@ -1,24 +1,23 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "metrical"
|
3
4
|
require "metrical/version"
|
4
5
|
|
5
6
|
Gem::Specification.new do |s|
|
6
|
-
s.name
|
7
|
-
s.
|
8
|
-
s.
|
9
|
-
s.
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
7
|
+
s.name = "metric_fu-metrical"
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.version = Metrical::VERSION
|
10
|
+
s.authors = ["iain"]
|
11
|
+
s.email = ["iain@iain.nl"]
|
12
|
+
s.homepage = "https://github.com/metricfu/metrical"
|
13
|
+
s.summary = %q{Run metric_fu without making it a project dependency}
|
14
|
+
s.description = %q{MetricFu no longer need metrical. It runs on the commandline all by itself}
|
15
|
+
s.post_install_message = Metrical.message
|
13
16
|
|
14
|
-
s.rubyforge_project
|
17
|
+
s.rubyforge_project = "metrical"
|
15
18
|
|
16
|
-
s.files =
|
17
|
-
s.
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.files = %w(metrical.gemspec lib/metrical.rb lib/metrical/version.rb bin/metrical bin/metric_fu-metrical)
|
20
|
+
s.executables = %w(metrical metric_fu-metrical)
|
19
21
|
s.require_paths = ["lib"]
|
20
22
|
|
21
|
-
s.add_runtime_dependency "metric_fu", "> 2.1.3.6"
|
22
|
-
s.add_runtime_dependency "rcov", "~> 0.9"
|
23
|
-
s.add_development_dependency "rspec", "~> 2.8"
|
24
23
|
end
|
metadata
CHANGED
@@ -1,128 +1,52 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: metric_fu-metrical
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 1
|
10
|
-
version: 0.1.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- iain
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
name: metric_fu
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ">"
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 103
|
29
|
-
segments:
|
30
|
-
- 2
|
31
|
-
- 1
|
32
|
-
- 3
|
33
|
-
- 6
|
34
|
-
version: 2.1.3.6
|
35
|
-
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rcov
|
39
|
-
prerelease: false
|
40
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 25
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
- 9
|
49
|
-
version: "0.9"
|
50
|
-
type: :runtime
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: rspec
|
54
|
-
prerelease: false
|
55
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
|
-
requirements:
|
58
|
-
- - ~>
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
hash: 19
|
61
|
-
segments:
|
62
|
-
- 2
|
63
|
-
- 8
|
64
|
-
version: "2.8"
|
65
|
-
type: :development
|
66
|
-
version_requirements: *id003
|
67
|
-
description: MetricFu is awesome! The only problem is that it's kinda obtrusive. Metrical provides a executable so you can run metric fu on any project without making changes to the project.
|
68
|
-
email:
|
11
|
+
date: 2013-09-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: MetricFu no longer need metrical. It runs on the commandline all by itself
|
14
|
+
email:
|
69
15
|
- iain@iain.nl
|
70
|
-
executables:
|
16
|
+
executables:
|
17
|
+
- metrical
|
71
18
|
- metric_fu-metrical
|
72
19
|
extensions: []
|
73
|
-
|
74
20
|
extra_rdoc_files: []
|
75
|
-
|
76
|
-
|
77
|
-
- .gitignore
|
78
|
-
- .metrics
|
79
|
-
- .rspec
|
80
|
-
- .travis.yml
|
81
|
-
- Gemfile
|
82
|
-
- README.md
|
83
|
-
- Rakefile
|
84
|
-
- bin/metric_fu-metrical
|
21
|
+
files:
|
22
|
+
- metrical.gemspec
|
85
23
|
- lib/metrical.rb
|
86
|
-
- lib/metrical/options.rb
|
87
24
|
- lib/metrical/version.rb
|
88
|
-
- metrical
|
89
|
-
-
|
90
|
-
|
91
|
-
- spec/spec_helper.rb
|
92
|
-
homepage: https://github.com/iain/metrical
|
25
|
+
- bin/metrical
|
26
|
+
- bin/metric_fu-metrical
|
27
|
+
homepage: https://github.com/metricfu/metrical
|
93
28
|
licenses: []
|
94
|
-
|
95
|
-
post_install_message:
|
29
|
+
metadata: {}
|
30
|
+
post_install_message: Please install metric_fu. It runs from the command-line now. And
|
31
|
+
gem metrical metric_fu-metrical. Thanks :)
|
96
32
|
rdoc_options: []
|
97
|
-
|
98
|
-
require_paths:
|
33
|
+
require_paths:
|
99
34
|
- lib
|
100
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
none: false
|
111
|
-
requirements:
|
112
|
-
- - ">="
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
hash: 3
|
115
|
-
segments:
|
116
|
-
- 0
|
117
|
-
version: "0"
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
118
45
|
requirements: []
|
119
|
-
|
120
46
|
rubyforge_project: metrical
|
121
|
-
rubygems_version:
|
47
|
+
rubygems_version: 2.0.3
|
122
48
|
signing_key:
|
123
|
-
specification_version:
|
49
|
+
specification_version: 4
|
124
50
|
summary: Run metric_fu without making it a project dependency
|
125
|
-
test_files:
|
126
|
-
|
127
|
-
- spec/running_spec.rb
|
128
|
-
- spec/spec_helper.rb
|
51
|
+
test_files: []
|
52
|
+
has_rdoc:
|
data/.gitignore
DELETED
data/.metrics
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/README.md
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
## Warning: This gem is not being maintained anymore!
|
2
|
-
|
3
|
-
I work exclusively with Ruby 1.9, and most tools included don't (fully) support it.
|
4
|
-
If you want to take over the project, fork the project, and open an issue stating your intentions.
|
5
|
-
|
6
|
-
---
|
7
|
-
|
8
|
-
# Metrical
|
9
|
-
|
10
|
-
[![Build Status](https://secure.travis-ci.org/iain/metrical.png)](http://travis-ci.org/iain/metrical)
|
11
|
-
|
12
|
-
MetricFu is awesome! Metrical strives to make it a little bit easier to get working.
|
13
|
-
|
14
|
-
## Features
|
15
|
-
|
16
|
-
### Cleverer defaults
|
17
|
-
|
18
|
-
Normally, RCov would work on a black-listing basis. This means that your coverage reports would
|
19
|
-
occasionally be flooded with code outside your project. No longer, because the default is now to
|
20
|
-
exclude everything and only include your `lib` and `app` directories. It also fixes some issues with
|
21
|
-
loading RSpec.
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
You're advised to install it with Bundler, because of dependency issues. Add this to your `Gemfile`:
|
26
|
-
|
27
|
-
gem 'metrical', :require => false
|
28
|
-
|
29
|
-
Then run:
|
30
|
-
|
31
|
-
bundle install
|
32
|
-
|
33
|
-
And run it:
|
34
|
-
|
35
|
-
bundle exec metrical
|
36
|
-
|
37
|
-
## Configuration
|
38
|
-
|
39
|
-
You can configure MetricFu in a `.metrics` file in the root of your project.
|
40
|
-
|
41
|
-
MetricFu::Configuration.run do |config|
|
42
|
-
config.metrics -= [ :rcov ]
|
43
|
-
end
|
44
|
-
|
45
|
-
For more information on configuring your metrics, please visit the
|
46
|
-
[MetricFu homepage](http://metric-fu.rubyforge.org/).
|
47
|
-
|
48
|
-
You can also turn off metrics when running, for instance:
|
49
|
-
|
50
|
-
bundle exec metrical --no-rcov
|
51
|
-
|
52
|
-
The metrics you can turn on and off depend on the type of project you are in.
|
53
|
-
For instance, Rails projects also have `rails_best_practices` and `stats` as
|
54
|
-
options.
|
55
|
-
|
56
|
-
Also, Metrical tries to be smart about your Ruby version. Some metrics are not
|
57
|
-
available on Ruby 1.9 and are disabled automatically.
|
58
|
-
|
59
|
-
To see which metrics are available, run:
|
60
|
-
|
61
|
-
bundle exec metrical --help
|
62
|
-
|
63
|
-
And that's all there is too it. If you have any suggestions, ideas or bug fixes,
|
64
|
-
please drop me a line, or make a github issue.
|
65
|
-
|
66
|
-
## Known issues
|
67
|
-
|
68
|
-
### General lack of support of Ruby 1.9
|
69
|
-
|
70
|
-
Most tools don't handle Ruby 1.9 new syntax properly. It doesn't look like this is going to change any time soon.
|
71
|
-
|
72
|
-
### RCov and Ruby 1.9
|
73
|
-
|
74
|
-
RCov doesn't work at all with Ruby 1.9. You should use something like
|
75
|
-
[SimpleCov](https://github.com/colszowka/simplecov). Unfortunately, it hasn't been included into
|
76
|
-
MetricFu yet. Until then, Metrical automatically disables RCov under Ruby 1.9.
|
77
|
-
|
78
|
-
### New syntax in Ruby 1.9
|
79
|
-
|
80
|
-
Most metrics can't cope with the new syntax in Ruby 1.9. There is nothing I can do about that, or
|
81
|
-
the creator of these metrics, because the root lie in the code parser they use. Either don't use the
|
82
|
-
new syntax or exclude these metrics in your `.metrics` file.
|
83
|
-
|
84
|
-
### Roodi vs. Psych
|
85
|
-
|
86
|
-
If you're running Ruby 1.9 with Psych as your default YAML parser (possible in 1.9.2, and the
|
87
|
-
default in 1.9.3), you might get an error message. [Read this issue](https://github.com/iain/metrical/issues/15).
|
88
|
-
|
89
|
-
### Gem dependency issues
|
90
|
-
|
91
|
-
Metrical depends on a lot of other gems. This means that sometimes, when a new version of a gem is released,
|
92
|
-
Rubygems will load the wrong version of the gem, that might be incompatible.
|
93
|
-
|
94
|
-
If you get a message like `can't activate X, already activated Y`, or something similar, use Bundler.
|
95
|
-
|
96
|
-
|
97
|
-
## Development
|
98
|
-
|
99
|
-
Install dependencies:
|
100
|
-
|
101
|
-
gem install bundler && bundle install
|
102
|
-
|
103
|
-
Run the specs:
|
104
|
-
|
105
|
-
rspec
|
106
|
-
|
107
|
-
|
108
|
-
## Changelog
|
109
|
-
|
110
|
-
Version 0.1.0:
|
111
|
-
|
112
|
-
* Finally added tests and added metrical to Travis
|
113
|
-
* Add option `--no-open` to stop it from opening in the browser
|
114
|
-
* Automatically turn off RCov in Ruby 1.9.x
|
115
|
-
* Depend on RCov 0.9, so installation will work under Ruby 1.9
|
116
|
-
* Remove other dependencies, it looks like MetricFu has that covered now.
|
117
|
-
* Automatically turn off Saikuro on Ruby 1.9.x
|
118
|
-
* Add switches for every metric (run `metrical --help` to see them all)
|
119
|
-
|
120
|
-
---
|
121
|
-
Copyright 2010-2011, [Iain Hecker](http://iain.nl) - Released under the MIT License.
|
data/Rakefile
DELETED
data/lib/metrical/options.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
|
3
|
-
module Metrical
|
4
|
-
module Options
|
5
|
-
|
6
|
-
def self.defaults
|
7
|
-
|
8
|
-
defaults = {
|
9
|
-
:open => true,
|
10
|
-
:metrics => Hash.new(true)
|
11
|
-
}
|
12
|
-
defaults[:metrics][:saikuro] = version(ruby) < version("1.9")
|
13
|
-
defaults[:metrics][:rcov] = version(ruby) < version("1.9")
|
14
|
-
defaults
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.version(version)
|
18
|
-
Gem::Version.new(version)
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.ruby
|
22
|
-
RUBY_VERSION.dup
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.metrics
|
26
|
-
MetricFu.configuration.metrics.sort_by(&:to_s)
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.parse(argv)
|
30
|
-
options = defaults.dup
|
31
|
-
|
32
|
-
opts = OptionParser.new do |opts|
|
33
|
-
|
34
|
-
opts.version = Metrical::VERSION
|
35
|
-
|
36
|
-
metrics.each do |metric|
|
37
|
-
|
38
|
-
opts.on "--[no-]#{metric}", "Enables or disables #{metric.to_s.titleize} (default: #{options[:metrics][metric]})" do |option|
|
39
|
-
options[:metrics][metric] = option
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
opts.on "--[no-]open", "Open report in browser" do |open|
|
45
|
-
options[:open] = open
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
begin
|
51
|
-
opts.parse!(argv)
|
52
|
-
rescue OptionParser::InvalidOption => error
|
53
|
-
puts error.message
|
54
|
-
puts opts
|
55
|
-
exit 1
|
56
|
-
end
|
57
|
-
options
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
data/spec/options_spec.rb
DELETED
@@ -1,181 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Metrical::Options do
|
4
|
-
|
5
|
-
describe ".defaults" do
|
6
|
-
|
7
|
-
let(:defaults) { Metrical::Options.defaults }
|
8
|
-
|
9
|
-
context "on every Ruby version" do
|
10
|
-
|
11
|
-
it "opens the report in a browser" do
|
12
|
-
defaults[:open].should be_true
|
13
|
-
end
|
14
|
-
|
15
|
-
it "enables Flog" do
|
16
|
-
defaults[:metrics][:flog].should be_true
|
17
|
-
end
|
18
|
-
|
19
|
-
it "enables Flay" do
|
20
|
-
defaults[:metrics][:flay].should be_true
|
21
|
-
end
|
22
|
-
|
23
|
-
it "enables Reek" do
|
24
|
-
defaults[:metrics][:reek].should be_true
|
25
|
-
end
|
26
|
-
|
27
|
-
it "enables Hotspots" do
|
28
|
-
defaults[:metrics][:hotspots].should be_true
|
29
|
-
end
|
30
|
-
|
31
|
-
it "enables Rails Best Practices" do
|
32
|
-
defaults[:metrics][:rails_best_practices].should be_true
|
33
|
-
end
|
34
|
-
|
35
|
-
it "enables Churn" do
|
36
|
-
defaults[:metrics][:churn].should be_true
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
context "on Ruby 1.8.6" do
|
42
|
-
|
43
|
-
before { subject.stub(:ruby).and_return("1.8.6") }
|
44
|
-
|
45
|
-
it "enables Saikuro" do
|
46
|
-
defaults[:metrics][:saikuro].should be_true
|
47
|
-
end
|
48
|
-
|
49
|
-
it "enables RCov" do
|
50
|
-
defaults[:metrics][:rcov].should be_true
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
context "on Ruby 1.8.7" do
|
56
|
-
|
57
|
-
before { subject.stub(:ruby).and_return("1.8.7") }
|
58
|
-
|
59
|
-
it "enables Saikuro" do
|
60
|
-
defaults[:metrics][:saikuro].should be_true
|
61
|
-
end
|
62
|
-
|
63
|
-
it "enables RCov" do
|
64
|
-
defaults[:metrics][:rcov].should be_true
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
context "on Ruby 1.9.2" do
|
70
|
-
|
71
|
-
before { subject.stub(:ruby).and_return("1.9.2") }
|
72
|
-
|
73
|
-
it "enables Saikuro" do
|
74
|
-
defaults[:metrics][:saikuro].should be_false
|
75
|
-
end
|
76
|
-
|
77
|
-
it "disables RCov" do
|
78
|
-
defaults[:metrics][:rcov].should be_false
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
context "on Ruby 1.9.3" do
|
84
|
-
|
85
|
-
before { subject.stub(:ruby).and_return("1.9.3") }
|
86
|
-
|
87
|
-
it "disables Saikuro" do
|
88
|
-
defaults[:metrics][:saikuro].should be_false
|
89
|
-
end
|
90
|
-
|
91
|
-
it "disables RCov" do
|
92
|
-
defaults[:metrics][:rcov].should be_false
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
98
|
-
|
99
|
-
describe ".parse" do
|
100
|
-
|
101
|
-
it "turns open in browser off" do
|
102
|
-
subject.parse(["--no-open"])[:open].should be_false
|
103
|
-
end
|
104
|
-
|
105
|
-
it "turns open in browser on" do
|
106
|
-
subject.parse(["--open"])[:open].should be_true
|
107
|
-
end
|
108
|
-
|
109
|
-
# MetricFu doesn't include Saikuro on 1.9.2 (it is broken on 1.9 anyway)
|
110
|
-
# https://github.com/jscruggs/metric_fu/blob/master/lib/base/configuration.rb#L12
|
111
|
-
unless RUBY_VERSION == "1.9.2"
|
112
|
-
|
113
|
-
it "turns saikuro off" do
|
114
|
-
subject.parse(["--no-saikuro"])[:metrics][:saikuro].should be_false
|
115
|
-
end
|
116
|
-
|
117
|
-
it "turns saikuro on" do
|
118
|
-
subject.parse(["--saikuro"])[:metrics][:saikuro].should be_true
|
119
|
-
end
|
120
|
-
|
121
|
-
end
|
122
|
-
|
123
|
-
it "turns churn off" do
|
124
|
-
subject.parse(["--no-churn"])[:metrics][:churn].should be_false
|
125
|
-
end
|
126
|
-
|
127
|
-
it "turns churn on" do
|
128
|
-
subject.parse(["--churn"])[:metrics][:churn].should be_true
|
129
|
-
end
|
130
|
-
|
131
|
-
it "turns flay off" do
|
132
|
-
subject.parse(["--no-flay"])[:metrics][:flay].should be_false
|
133
|
-
end
|
134
|
-
|
135
|
-
it "turns flay on" do
|
136
|
-
subject.parse(["--flay"])[:metrics][:flay].should be_true
|
137
|
-
end
|
138
|
-
|
139
|
-
it "turns flog off" do
|
140
|
-
subject.parse(["--no-flog"])[:metrics][:flog].should be_false
|
141
|
-
end
|
142
|
-
|
143
|
-
it "turns flog on" do
|
144
|
-
subject.parse(["--flog"])[:metrics][:flog].should be_true
|
145
|
-
end
|
146
|
-
|
147
|
-
it "turns hotspots off" do
|
148
|
-
subject.parse(["--no-hotspots"])[:metrics][:hotspots].should be_false
|
149
|
-
end
|
150
|
-
|
151
|
-
it "turns hotspots on" do
|
152
|
-
subject.parse(["--hotspots"])[:metrics][:hotspots].should be_true
|
153
|
-
end
|
154
|
-
|
155
|
-
it "turns rcov off" do
|
156
|
-
subject.parse(["--no-rcov"])[:metrics][:rcov].should be_false
|
157
|
-
end
|
158
|
-
|
159
|
-
it "turns rcov on" do
|
160
|
-
subject.parse(["--rcov"])[:metrics][:rcov].should be_true
|
161
|
-
end
|
162
|
-
|
163
|
-
it "turns reek off" do
|
164
|
-
subject.parse(["--no-reek"])[:metrics][:reek].should be_false
|
165
|
-
end
|
166
|
-
|
167
|
-
it "turns reek on" do
|
168
|
-
subject.parse(["--reek"])[:metrics][:reek].should be_true
|
169
|
-
end
|
170
|
-
|
171
|
-
it "turns roodi off" do
|
172
|
-
subject.parse(["--no-roodi"])[:metrics][:roodi].should be_false
|
173
|
-
end
|
174
|
-
|
175
|
-
it "turns roodi on" do
|
176
|
-
subject.parse(["--roodi"])[:metrics][:roodi].should be_true
|
177
|
-
end
|
178
|
-
|
179
|
-
end
|
180
|
-
|
181
|
-
end
|
data/spec/running_spec.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Metrical, "running" do
|
4
|
-
|
5
|
-
before do
|
6
|
-
FileUtils.rm_rf("tmp/metric_fu")
|
7
|
-
end
|
8
|
-
|
9
|
-
it "has a clean start" do
|
10
|
-
File.should_not exist("tmp/metric_fu")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "loads the .metrics file" do
|
14
|
-
out = metrical
|
15
|
-
out.should include "Metrics config loaded"
|
16
|
-
end
|
17
|
-
|
18
|
-
it "creates a report yaml file" do
|
19
|
-
expect { metrical }.to create_file("tmp/metric_fu/report.yml")
|
20
|
-
end
|
21
|
-
|
22
|
-
it "creates a report html file" do
|
23
|
-
expect { metrical }.to create_file("tmp/metric_fu/output/index.html")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "displays help" do
|
27
|
-
out = metrical("bundle exec metrical --help")
|
28
|
-
out.should include "Usage: metrical [options]"
|
29
|
-
end
|
30
|
-
|
31
|
-
it "displays version" do
|
32
|
-
out = metrical("bundle exec metrical --version")
|
33
|
-
out.should == "metrical #{Metrical::VERSION}"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "errors on unknown flags" do
|
37
|
-
expect { metrical "--asdasdasda" }.to raise_error
|
38
|
-
end
|
39
|
-
|
40
|
-
def metrical(command = "--no-open")
|
41
|
-
results = `metrical #{command} 2>&1`
|
42
|
-
$?.to_i.should eq(0), "The command 'metrical #{command}' failed!\n\n#{results}"
|
43
|
-
results.strip
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
require 'metrical'
|
3
|
-
require 'rspec'
|
4
|
-
|
5
|
-
RSpec::Matchers.define :create_file do |expected|
|
6
|
-
|
7
|
-
match do |block|
|
8
|
-
@before = File.exist?(expected)
|
9
|
-
block.call
|
10
|
-
@after = File.exist?(expected)
|
11
|
-
!@before && @after
|
12
|
-
end
|
13
|
-
|
14
|
-
failure_message_for_should do |block|
|
15
|
-
existed_before_message expected do
|
16
|
-
"The file #{expected.inspect} was not created"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
failure_message_for_should_not do |block|
|
21
|
-
existed_before_message expected do
|
22
|
-
"The file #{expected.inspect} was created"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def existed_before_message(expected)
|
27
|
-
if @before
|
28
|
-
"The file #{expected.inspect} existed before, so this test doesn't work"
|
29
|
-
else
|
30
|
-
yield
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|