turbulence 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/lib/turbulence.rb +39 -20
- data/lib/turbulence/calculators/churn.rb +44 -34
- data/lib/turbulence/calculators/complexity.rb +17 -13
- data/lib/turbulence/checks_environment.rb +2 -1
- data/lib/turbulence/cli_parser.rb +46 -0
- data/lib/turbulence/command_line_interface.rb +23 -47
- data/lib/turbulence/configuration.rb +28 -0
- data/lib/turbulence/version.rb +1 -1
- data/spec/turbulence/calculators/churn_spec.rb +3 -1
- data/spec/turbulence/calculators/complexity_spec.rb +3 -1
- data/spec/turbulence/cli_parser_spec.rb +40 -0
- data/spec/turbulence/command_line_interface_spec.rb +2 -19
- data/spec/turbulence/configuration_spec.rb +13 -0
- data/spec/turbulence/turbulence_spec.rb +11 -3
- metadata +8 -5
- data/spec/turbulence/checks_environoment_spec.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1491a1041aa988c3e1b1ba0a9c285b85f61dd2fe
|
4
|
+
data.tar.gz: 52fc99ed010da6d2b62aaf794cb8ccfe42bf9079
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da0688c4eac40019c589daa4df804aa29f71906b7706b92cf1b0237930ebb5324c547fd631a93cc28918c323a20ca5f8feae055bd4b6a5c552cce6f7088610fb
|
7
|
+
data.tar.gz: df3db44e2fad25424ee559ff82648a41f625bfdb90acbad83835af9f9d814d76757457183f199f014b248957c050bda4318104fb4c252b2b622b5a66856b6830
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
turbulence (1.2.
|
4
|
+
turbulence (1.2.4)
|
5
5
|
flog (~> 4.1)
|
6
6
|
json (>= 1.4.6)
|
7
7
|
launchy (>= 2.0.0)
|
@@ -9,11 +9,11 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
|
-
addressable (2.3.
|
12
|
+
addressable (2.3.6)
|
13
13
|
diff-lcs (1.2.5)
|
14
|
-
flog (4.1
|
14
|
+
flog (4.2.1)
|
15
15
|
ruby_parser (~> 3.1, > 3.1.0)
|
16
|
-
sexp_processor (~> 4.
|
16
|
+
sexp_processor (~> 4.4)
|
17
17
|
json (1.8.1)
|
18
18
|
launchy (2.4.2)
|
19
19
|
addressable (~> 2.3)
|
@@ -26,9 +26,9 @@ GEM
|
|
26
26
|
rspec-expectations (2.14.4)
|
27
27
|
diff-lcs (>= 1.1.3, < 2.0)
|
28
28
|
rspec-mocks (2.14.4)
|
29
|
-
ruby_parser (3.
|
29
|
+
ruby_parser (3.6.1)
|
30
30
|
sexp_processor (~> 4.1)
|
31
|
-
sexp_processor (4.4.
|
31
|
+
sexp_processor (4.4.3)
|
32
32
|
|
33
33
|
PLATFORMS
|
34
34
|
ruby
|
data/lib/turbulence.rb
CHANGED
@@ -1,32 +1,47 @@
|
|
1
|
+
require 'turbulence/configuration'
|
1
2
|
require 'turbulence/file_name_mangler'
|
2
3
|
require 'turbulence/command_line_interface'
|
3
|
-
require 'turbulence/checks_environment'
|
4
4
|
require 'turbulence/calculators/churn'
|
5
5
|
require 'turbulence/calculators/complexity'
|
6
6
|
require 'turbulence/generators/treemap'
|
7
7
|
require 'turbulence/generators/scatterplot'
|
8
8
|
|
9
9
|
class Turbulence
|
10
|
-
CODE_DIRECTORIES = [
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
CODE_DIRECTORIES = [
|
11
|
+
"app/models",
|
12
|
+
"app/controllers",
|
13
|
+
"app/helpers",
|
14
|
+
"app/jobs",
|
15
|
+
"app/mailers",
|
16
|
+
"app/validators",
|
17
|
+
"lib",
|
18
|
+
]
|
19
|
+
CALCULATORS = [
|
20
|
+
Turbulence::Calculators::Complexity,
|
21
|
+
Turbulence::Calculators::Churn,
|
22
|
+
]
|
19
23
|
|
20
|
-
|
24
|
+
# Make a config instance available to anyone who wants one
|
25
|
+
def self.config
|
26
|
+
@config ||= Configuration.new
|
27
|
+
end
|
28
|
+
|
29
|
+
attr_reader :config
|
21
30
|
attr_reader :metrics
|
22
31
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
32
|
+
extend Forwardable
|
33
|
+
def_delegators :config, *[
|
34
|
+
:directory,
|
35
|
+
:exclusion_pattern,
|
36
|
+
:output,
|
37
|
+
]
|
38
|
+
|
39
|
+
def initialize(config = nil)
|
40
|
+
@config = config || Turbulence.config
|
41
|
+
@metrics = {}
|
27
42
|
|
28
43
|
Dir.chdir(directory) do
|
29
|
-
|
44
|
+
calculators.each(&method(:calculate_metrics_with))
|
30
45
|
end
|
31
46
|
end
|
32
47
|
|
@@ -40,14 +55,14 @@ class Turbulence
|
|
40
55
|
|
41
56
|
calculator.for_these_files(files_of_interest) do |filename, score|
|
42
57
|
report "."
|
43
|
-
set_file_metric(filename, calculator, score)
|
58
|
+
set_file_metric(filename, calculator.class, score)
|
44
59
|
end
|
45
60
|
|
46
61
|
report "\n"
|
47
62
|
end
|
48
63
|
|
49
64
|
def report(this)
|
50
|
-
|
65
|
+
output.print this unless output.nil?
|
51
66
|
end
|
52
67
|
|
53
68
|
def set_file_metric(filename, metric, value)
|
@@ -60,9 +75,13 @@ class Turbulence
|
|
60
75
|
|
61
76
|
private
|
62
77
|
def exclude_files(files)
|
63
|
-
if not
|
64
|
-
files = files.reject { |f| f =~ Regexp.new(
|
78
|
+
if not exclusion_pattern.nil?
|
79
|
+
files = files.reject { |f| f =~ Regexp.new(exclusion_pattern) }
|
65
80
|
end
|
66
81
|
files
|
67
82
|
end
|
83
|
+
|
84
|
+
def calculators
|
85
|
+
CALCULATORS.map { |calc_class| calc_class.new(config) }
|
86
|
+
end
|
68
87
|
end
|
@@ -1,54 +1,64 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
1
3
|
class Turbulence
|
2
4
|
module Calculators
|
3
5
|
class Churn
|
4
6
|
RUBY_FILE_EXTENSION = ".rb"
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
+
attr_reader :config
|
9
|
+
def initialize(config = nil)
|
10
|
+
@config = config || Turbulence.config
|
11
|
+
end
|
8
12
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
extend Forwardable
|
14
|
+
def_delegators :config, *[
|
15
|
+
:scm, :scm=,
|
16
|
+
:commit_range, :commit_range=,
|
17
|
+
:compute_mean, :compute_mean=,
|
18
|
+
]
|
14
19
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
20
|
+
def for_these_files(files)
|
21
|
+
changes_by_ruby_file.each do |filename, count|
|
22
|
+
yield filename, count if files.include?(filename)
|
19
23
|
end
|
24
|
+
end
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
[filename, churn]
|
26
|
+
def changes_by_ruby_file
|
27
|
+
ruby_files_changed_in_scm.group_by(&:first).map do |filename, stats|
|
28
|
+
churn_for_file(filename,stats)
|
25
29
|
end
|
30
|
+
end
|
26
31
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
def churn_for_file(filename,stats)
|
33
|
+
churn = stats[0..-2].map(&:last).inject(0){|running_total, changes| running_total + changes}
|
34
|
+
churn = calculate_mean_of_churn(churn, stats.size - 1) if compute_mean
|
35
|
+
[filename, churn]
|
36
|
+
end
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
38
|
+
def calculate_mean_of_churn(churn, sample_size)
|
39
|
+
return churn if sample_size < 1
|
40
|
+
churn /= sample_size
|
41
|
+
end
|
37
42
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
[filename, adds.to_i + deletes.to_i]
|
42
|
-
end
|
43
|
+
def ruby_files_changed_in_scm
|
44
|
+
counted_line_changes_by_file_by_commit.select do |filename, _|
|
45
|
+
filename.end_with?(RUBY_FILE_EXTENSION) && File.exist?(filename)
|
43
46
|
end
|
47
|
+
end
|
44
48
|
|
45
|
-
|
46
|
-
|
49
|
+
def counted_line_changes_by_file_by_commit
|
50
|
+
scm_log_file_lines.map do |line|
|
51
|
+
adds, deletes, filename = line.split(/\t/)
|
52
|
+
[filename, adds.to_i + deletes.to_i]
|
47
53
|
end
|
54
|
+
end
|
48
55
|
|
49
|
-
|
50
|
-
|
51
|
-
|
56
|
+
def scm_log_file_lines
|
57
|
+
scm_log_command.each_line.reject{|line| line == "\n"}.map(&:chomp)
|
58
|
+
end
|
59
|
+
|
60
|
+
def scm_log_command
|
61
|
+
scm.log_command(commit_range)
|
52
62
|
end
|
53
63
|
end
|
54
64
|
end
|
@@ -18,22 +18,26 @@ end
|
|
18
18
|
class Turbulence
|
19
19
|
module Calculators
|
20
20
|
class Complexity
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def for_these_files(files)
|
26
|
-
files.each do |filename|
|
27
|
-
yield filename, score_for_file(filename)
|
28
|
-
end
|
29
|
-
end
|
21
|
+
attr_reader :config
|
22
|
+
def initialize(config = nil)
|
23
|
+
@config = config || Turbulence.config
|
24
|
+
end
|
30
25
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
def flogger
|
27
|
+
@flogger ||= Flog19.new(:continue => true)
|
28
|
+
end
|
29
|
+
|
30
|
+
def for_these_files(files)
|
31
|
+
files.each do |filename|
|
32
|
+
yield filename, score_for_file(filename)
|
35
33
|
end
|
36
34
|
end
|
35
|
+
|
36
|
+
def score_for_file(filename)
|
37
|
+
flogger.reset
|
38
|
+
flogger.flog filename
|
39
|
+
flogger.total_score
|
40
|
+
end
|
37
41
|
end
|
38
42
|
end
|
39
43
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class Turbulence
|
2
|
+
class CommandLineInterface
|
3
|
+
# I Update a Turbulence::Configuration instance to match the user's
|
4
|
+
# expectations (as expressed in ARGV)
|
5
|
+
module ConfigParser
|
6
|
+
def self.parse_argv_into_config(argv, config)
|
7
|
+
option_parser = OptionParser.new do |opts|
|
8
|
+
opts.banner = "Usage: bule [options] [dir]"
|
9
|
+
|
10
|
+
opts.on('--scm p4|git', String, 'scm to use (default: git)') do |s|
|
11
|
+
case s
|
12
|
+
when "git", "", nil
|
13
|
+
when "p4"
|
14
|
+
config.scm_name = 'Perforce'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on('--churn-range since..until', String, 'commit range to compute file churn') do |s|
|
19
|
+
config.commit_range = s
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on('--churn-mean', 'calculate mean churn instead of cummulative') do
|
23
|
+
config.compute_mean = true
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on('--exclude pattern', String, 'exclude files matching pattern') do |pattern|
|
27
|
+
config.exclusion_pattern = pattern
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on('--treemap', String, 'output treemap graph instead of scatterplot') do |s|
|
31
|
+
config.graph_type = "treemap"
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
36
|
+
puts opts
|
37
|
+
exit
|
38
|
+
end
|
39
|
+
end
|
40
|
+
option_parser.parse!(argv)
|
41
|
+
|
42
|
+
config.directory = argv.first unless argv.empty?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,62 +1,38 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'launchy'
|
3
3
|
require 'optparse'
|
4
|
+
require 'forwardable'
|
5
|
+
|
6
|
+
require 'turbulence/configuration'
|
7
|
+
require 'turbulence/cli_parser'
|
4
8
|
require 'turbulence/scm/git'
|
5
9
|
require 'turbulence/scm/perforce'
|
6
10
|
|
7
11
|
class Turbulence
|
8
12
|
class CommandLineInterface
|
9
13
|
TURBULENCE_TEMPLATE_PATH = File.join(File.expand_path(File.dirname(__FILE__)), "..", "..", "template")
|
10
|
-
TEMPLATE_FILES = [
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
+
TEMPLATE_FILES = [
|
15
|
+
'turbulence.html',
|
16
|
+
'highcharts.js',
|
17
|
+
'jquery.min.js',
|
18
|
+
'treemap.html',
|
19
|
+
].map do |filename|
|
14
20
|
File.join(TURBULENCE_TEMPLATE_PATH, filename)
|
15
21
|
end
|
16
22
|
|
17
|
-
attr_reader :exclusion_pattern
|
18
|
-
attr_reader :directory
|
19
23
|
def initialize(argv, additional_options = {})
|
20
|
-
|
21
|
-
|
22
|
-
OptionParser.new do |opts|
|
23
|
-
opts.banner = "Usage: bule [options] [dir]"
|
24
|
-
|
25
|
-
opts.on('--scm p4|git', String, 'scm to use (default: git)') do |s|
|
26
|
-
case s
|
27
|
-
when "git", "", nil
|
28
|
-
when "p4"
|
29
|
-
Turbulence::Calculators::Churn.scm = Scm::Perforce
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
opts.on('--churn-range since..until', String, 'commit range to compute file churn') do |s|
|
34
|
-
Turbulence::Calculators::Churn.commit_range = s
|
35
|
-
end
|
36
|
-
|
37
|
-
opts.on('--churn-mean', 'calculate mean churn instead of cummulative') do
|
38
|
-
Turbulence::Calculators::Churn.compute_mean = true
|
39
|
-
end
|
40
|
-
|
41
|
-
opts.on('--exclude pattern', String, 'exclude files matching pattern') do |pattern|
|
42
|
-
@exclusion_pattern = pattern
|
43
|
-
end
|
44
|
-
|
45
|
-
opts.on('--treemap', String, 'output treemap graph instead of scatterplot') do |s|
|
46
|
-
@graph_type = "treemap"
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
51
|
-
puts opts
|
52
|
-
exit
|
53
|
-
end
|
54
|
-
end.parse!(argv)
|
55
|
-
|
56
|
-
@directory = argv.first || Dir.pwd
|
57
|
-
@output = additional_options.fetch(:output, STDOUT)
|
24
|
+
ConfigParser.parse_argv_into_config argv, config
|
25
|
+
config.output = additional_options.fetch(:output, STDOUT)
|
58
26
|
end
|
59
27
|
|
28
|
+
extend Forwardable
|
29
|
+
def_delegators :Turbulence, :config
|
30
|
+
def_delegators :config, *[
|
31
|
+
:directory,
|
32
|
+
:graph_type,
|
33
|
+
:exclusion_pattern,
|
34
|
+
]
|
35
|
+
|
60
36
|
def copy_templates_into(directory)
|
61
37
|
FileUtils.cp TEMPLATE_FILES, directory
|
62
38
|
end
|
@@ -65,9 +41,9 @@ class Turbulence
|
|
65
41
|
FileUtils.mkdir_p("turbulence")
|
66
42
|
|
67
43
|
Dir.chdir("turbulence") do
|
68
|
-
turb = Turbulence.new(
|
44
|
+
turb = Turbulence.new(config)
|
69
45
|
|
70
|
-
generator = case
|
46
|
+
generator = case graph_type
|
71
47
|
when "treemap"
|
72
48
|
Turbulence::Generators::TreeMap.new({})
|
73
49
|
else
|
@@ -79,7 +55,7 @@ class Turbulence
|
|
79
55
|
end
|
80
56
|
|
81
57
|
def open_bundle
|
82
|
-
Launchy.open("file:///#{directory}/turbulence/#{
|
58
|
+
Launchy.open("file:///#{directory}/turbulence/#{graph_type}.html")
|
83
59
|
end
|
84
60
|
end
|
85
61
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
class Turbulence
|
4
|
+
class Configuration
|
5
|
+
attr_accessor *[
|
6
|
+
:directory,
|
7
|
+
:scm,
|
8
|
+
:scm_name,
|
9
|
+
:commit_range,
|
10
|
+
:compute_mean,
|
11
|
+
:exclusion_pattern,
|
12
|
+
:graph_type,
|
13
|
+
:output,
|
14
|
+
]
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@directory = Dir.pwd
|
18
|
+
@graph_type = 'turbulence'
|
19
|
+
@scm_name = 'Git'
|
20
|
+
@output = STDOUT
|
21
|
+
end
|
22
|
+
|
23
|
+
# TODO: drop attr accessor and ivar once it stops getting set via Churn
|
24
|
+
def scm
|
25
|
+
@scm || Turbulence::Scm.const_get(scm_name)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/turbulence/version.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'turbulence/calculators/churn'
|
2
2
|
|
3
3
|
describe Turbulence::Calculators::Churn do
|
4
|
-
let(:calculator) { Turbulence::Calculators::Churn }
|
4
|
+
let(:calculator) { Turbulence::Calculators::Churn.new(config) }
|
5
|
+
let(:config) { Turbulence::Configuration.new }
|
6
|
+
|
5
7
|
before do
|
6
8
|
calculator.stub(:scm_log_command) { "" }
|
7
9
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'turbulence/calculators/complexity'
|
2
2
|
|
3
3
|
describe Turbulence::Calculators::Complexity do
|
4
|
-
let(:calculator) { Turbulence::Calculators::Complexity }
|
4
|
+
let(:calculator) { Turbulence::Calculators::Complexity.new(config) }
|
5
|
+
let(:config) { Turbulence::Configuration.new }
|
6
|
+
|
5
7
|
describe "::for_these_files" do
|
6
8
|
it "yields up the filename and score for each file" do
|
7
9
|
files = ["lib/corey.rb", "lib/chad.rb"]
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'turbulence'
|
3
|
+
|
4
|
+
describe Turbulence::CommandLineInterface::ConfigParser do
|
5
|
+
let(:config) { Turbulence::Configuration.new }
|
6
|
+
|
7
|
+
def parse(argv)
|
8
|
+
described_class.parse_argv_into_config(argv, config)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "sets directory" do
|
12
|
+
parse %w( path/to/compute )
|
13
|
+
config.directory.should == 'path/to/compute'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "sets SCM name to 'Perforce'" do
|
17
|
+
parse %w( --scm p4 )
|
18
|
+
config.scm_name.should == 'Perforce'
|
19
|
+
end
|
20
|
+
|
21
|
+
it "sets commit range" do
|
22
|
+
parse %w( --churn-range f3e1d7a6..830b9d3d9f )
|
23
|
+
config.commit_range.should eq('f3e1d7a6..830b9d3d9f')
|
24
|
+
end
|
25
|
+
|
26
|
+
it "sets compute mean" do
|
27
|
+
parse %w( --churn-mean )
|
28
|
+
config.compute_mean.should be_true
|
29
|
+
end
|
30
|
+
|
31
|
+
it "sets the exclusion pattern" do
|
32
|
+
parse %w( --exclude turbulence )
|
33
|
+
config.exclusion_pattern.should == 'turbulence'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "sets the graph type" do
|
37
|
+
parse %w( --treemap )
|
38
|
+
config.graph_type.should == 'treemap'
|
39
|
+
end
|
40
|
+
end
|
@@ -3,11 +3,13 @@ require 'turbulence'
|
|
3
3
|
|
4
4
|
describe Turbulence::CommandLineInterface do
|
5
5
|
let(:cli) { Turbulence::CommandLineInterface.new(%w(.), :output => nil) }
|
6
|
+
|
6
7
|
describe "::TEMPLATE_FILES" do
|
7
8
|
Turbulence::CommandLineInterface::TEMPLATE_FILES.each do |template_file|
|
8
9
|
File.dirname(template_file).should == Turbulence::CommandLineInterface::TURBULENCE_TEMPLATE_PATH
|
9
10
|
end
|
10
11
|
end
|
12
|
+
|
11
13
|
describe "#generate_bundle" do
|
12
14
|
before do
|
13
15
|
FileUtils.remove_dir("turbulence", true)
|
@@ -28,23 +30,4 @@ describe Turbulence::CommandLineInterface do
|
|
28
30
|
lines.any? { |l| l =~ /turbulence\.rb/ }.should be_false
|
29
31
|
end
|
30
32
|
end
|
31
|
-
describe "command line options" do
|
32
|
-
let(:cli_churn_range) { Turbulence::CommandLineInterface.new(%w(--churn-range f3e1d7a6..830b9d3d9f path/to/compute)) }
|
33
|
-
let(:cli_churn_mean) { Turbulence::CommandLineInterface.new(%w(--churn-mean .)) }
|
34
|
-
let(:cli_exclusion_pattern) { Turbulence::CommandLineInterface.new(%w(--exclude turbulence)) }
|
35
|
-
|
36
|
-
it "sets churn range" do
|
37
|
-
cli_churn_range.directory.should == 'path/to/compute'
|
38
|
-
Turbulence::Calculators::Churn.commit_range.should == 'f3e1d7a6..830b9d3d9f'
|
39
|
-
end
|
40
|
-
|
41
|
-
it "sets churn mean" do
|
42
|
-
cli_churn_mean.directory.should == '.'
|
43
|
-
Turbulence::Calculators::Churn.compute_mean.should be_true
|
44
|
-
end
|
45
|
-
|
46
|
-
it "sets the exclusion pattern" do
|
47
|
-
cli_exclusion_pattern.exclusion_pattern.should == 'turbulence'
|
48
|
-
end
|
49
|
-
end
|
50
33
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'turbulence'
|
3
|
+
|
4
|
+
describe Turbulence::Configuration do
|
5
|
+
describe "defaults" do
|
6
|
+
its(:output) { should eq(STDOUT) }
|
7
|
+
its(:directory) { should eq(Dir.pwd) }
|
8
|
+
its(:graph_type) { should eq('turbulence') }
|
9
|
+
its(:scm_name) { should eq('Git') }
|
10
|
+
its(:scm) { should eq(Turbulence::Scm::Git) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
@@ -2,14 +2,22 @@ require 'rspec'
|
|
2
2
|
require 'turbulence'
|
3
3
|
|
4
4
|
describe Turbulence do
|
5
|
+
subject(:turb) { Turbulence.new(config) }
|
6
|
+
|
7
|
+
let(:config) {
|
8
|
+
Turbulence::Configuration.new.tap do |config|
|
9
|
+
config.directory = '.'
|
10
|
+
config.exclusion_pattern = nil
|
11
|
+
config.output = nil
|
12
|
+
end
|
13
|
+
}
|
14
|
+
|
5
15
|
it "finds files of interest" do
|
6
|
-
turb = Turbulence.new(".")
|
7
|
-
turb.exclusion_pattern.should be_nil
|
8
16
|
turb.files_of_interest.should include "lib/turbulence.rb"
|
9
17
|
end
|
10
18
|
|
11
19
|
it "filters out exluded files" do
|
12
|
-
|
20
|
+
config.exclusion_pattern = 'turbulence'
|
13
21
|
turb.files_of_interest.should_not include "lib/turbulence.rb"
|
14
22
|
end
|
15
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbulence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Fowler
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-07-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: flog
|
@@ -103,7 +103,9 @@ files:
|
|
103
103
|
- lib/turbulence/calculators/churn.rb
|
104
104
|
- lib/turbulence/calculators/complexity.rb
|
105
105
|
- lib/turbulence/checks_environment.rb
|
106
|
+
- lib/turbulence/cli_parser.rb
|
106
107
|
- lib/turbulence/command_line_interface.rb
|
108
|
+
- lib/turbulence/configuration.rb
|
107
109
|
- lib/turbulence/file_name_mangler.rb
|
108
110
|
- lib/turbulence/generators/scatterplot.rb
|
109
111
|
- lib/turbulence/generators/treemap.rb
|
@@ -112,8 +114,9 @@ files:
|
|
112
114
|
- lib/turbulence/version.rb
|
113
115
|
- spec/turbulence/calculators/churn_spec.rb
|
114
116
|
- spec/turbulence/calculators/complexity_spec.rb
|
115
|
-
- spec/turbulence/
|
117
|
+
- spec/turbulence/cli_parser_spec.rb
|
116
118
|
- spec/turbulence/command_line_interface_spec.rb
|
119
|
+
- spec/turbulence/configuration_spec.rb
|
117
120
|
- spec/turbulence/generators/scatter_plot_spec.rb
|
118
121
|
- spec/turbulence/generators/treemap_spec.rb
|
119
122
|
- spec/turbulence/scm/git_spec.rb
|
@@ -152,11 +155,11 @@ summary: Automates churn + flog scoring on a git repo for a Ruby project
|
|
152
155
|
test_files:
|
153
156
|
- spec/turbulence/calculators/churn_spec.rb
|
154
157
|
- spec/turbulence/calculators/complexity_spec.rb
|
155
|
-
- spec/turbulence/
|
158
|
+
- spec/turbulence/cli_parser_spec.rb
|
156
159
|
- spec/turbulence/command_line_interface_spec.rb
|
160
|
+
- spec/turbulence/configuration_spec.rb
|
157
161
|
- spec/turbulence/generators/scatter_plot_spec.rb
|
158
162
|
- spec/turbulence/generators/treemap_spec.rb
|
159
163
|
- spec/turbulence/scm/git_spec.rb
|
160
164
|
- spec/turbulence/scm/perforce_spec.rb
|
161
165
|
- spec/turbulence/turbulence_spec.rb
|
162
|
-
has_rdoc:
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'turbulence/scm/git'
|
3
|
-
require 'turbulence'
|
4
|
-
|
5
|
-
describe Turbulence::ChecksEnvironment do
|
6
|
-
|
7
|
-
it "should determine if the current directory is a git repository" do
|
8
|
-
Turbulence::Calculators::Churn.scm = Turbulence::Scm::Git
|
9
|
-
Turbulence::ChecksEnvironment.scm_repo?(Dir.pwd).should be_true
|
10
|
-
end
|
11
|
-
end
|