tdx 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/bin/tdx +1 -1
- data/lib/tdx/base.rb +54 -18
- data/lib/tdx/exec.rb +1 -1
- data/lib/tdx/version.rb +1 -1
- data/test/test__helper.rb +2 -0
- data/test/test_tdx.rb +8 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2766078e04e0d81fd9017e362c86f3a8a9f5fef6
|
4
|
+
data.tar.gz: 0752b9c0baa666bfaad9dda3023695196ee11886
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82426a60cdfaed678185ad17f07e5e5fc76fc8c5d0cfeab1127dd8e30758aec78acabb76a5afa75889fe1dee032008fe571d4981d42446d2fb8349bd1b55ad07
|
7
|
+
data.tar.gz: e5c1f836bbb0153debf140fee05ff6929eb6728c0b23e14dbc9391a8482f940ef467764413e432dc23ff6b4d0be164a5acf45079e6acca0d488dcec9acca7fd6
|
data/.rubocop.yml
CHANGED
data/bin/tdx
CHANGED
@@ -34,7 +34,7 @@ opts = Slop.parse(args, strict: true, help: true) do |o|
|
|
34
34
|
o.bool '-v', '--version', 'Show current version'
|
35
35
|
o.array(
|
36
36
|
'--tests',
|
37
|
-
'Comma-separated list of
|
37
|
+
'Comma-separated list of glob masks with test-related files',
|
38
38
|
delimiter: ','
|
39
39
|
)
|
40
40
|
o.string '--login', 'GitHub login'
|
data/lib/tdx/base.rb
CHANGED
@@ -41,22 +41,52 @@ module TDX
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def svg
|
44
|
-
dat = Tempfile.new('tdx')
|
45
44
|
version = Exec.new('git --version').stdout.split(/ /)[2]
|
46
45
|
raise "git version #{version} is too old, upgrade it to 2.0+" unless
|
47
46
|
Gem::Version.new(version) >= Gem::Version.new('2.0')
|
48
47
|
path = checkout
|
49
|
-
|
50
48
|
commits = Exec.new('git log "--pretty=format:%H %cI" --reverse', path)
|
51
49
|
.stdout.split(/\n/).map { |c| c.split(' ') }
|
52
50
|
issues = issues(commits)
|
53
51
|
puts "Date\t\t\tTest\tHoC\tFiles\tLoC\tIssues\tSHA"
|
54
|
-
commits.
|
52
|
+
metrics = commits.map do |sha, date|
|
55
53
|
Exec.new("git checkout --quiet #{sha}", path).stdout
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
{
|
55
|
+
date: date,
|
56
|
+
pure: pure(path),
|
57
|
+
hoc: hoc(path),
|
58
|
+
files: files(path),
|
59
|
+
loc: loc(path),
|
60
|
+
issues: issues[sha],
|
61
|
+
sha: sha
|
62
|
+
}
|
63
|
+
end
|
64
|
+
metrics.each do |m|
|
65
|
+
puts "#{m[:date][0, 16]}\t#{m[:pure]}\t#{m[:hoc]}\t#{m[:files]}\t\
|
66
|
+
#{m[:loc]}\t#{m[:issues]}\t#{m[:sha][0, 7]}"
|
67
|
+
end
|
68
|
+
max = { pure: 0, hoc: 0, files: 0, loc: 0, issues: 0 }
|
69
|
+
max = metrics.inject(max) do |m, t|
|
70
|
+
{
|
71
|
+
pure: [m[:pure], t[:pure], 1].max,
|
72
|
+
hoc: [m[:hoc], t[:hoc], 1].max,
|
73
|
+
files: [m[:files], t[:files], 1].max,
|
74
|
+
loc: [m[:loc], t[:loc], 1].max,
|
75
|
+
issues: [m[:issues], t[:issues], 1].max
|
76
|
+
}
|
77
|
+
end
|
78
|
+
dat = Tempfile.new('tdx')
|
79
|
+
metrics.each do |m|
|
80
|
+
dat << [
|
81
|
+
m[:date],
|
82
|
+
100.0 * m[:pure] / max[:pure],
|
83
|
+
100.0 * (m[:pure] - m[:hoc]) / (max[:pure] - max[:hoc]),
|
84
|
+
100.0 * m[:hoc] / max[:hoc],
|
85
|
+
100.0 * m[:files] / max[:files],
|
86
|
+
100.0 * m[:loc] / max[:loc],
|
87
|
+
100.0 * m[:issues] / max[:issues],
|
88
|
+
m[:sha]
|
89
|
+
].join(' ') + "\n"
|
60
90
|
end
|
61
91
|
dat.close
|
62
92
|
svg = Tempfile.new('tdx')
|
@@ -66,19 +96,17 @@ module TDX
|
|
66
96
|
'set termoption font "monospace,10"',
|
67
97
|
'set xdata time',
|
68
98
|
'set timefmt "%Y-%m"',
|
69
|
-
'set ytics format "%.0f%%" textcolor rgb "
|
99
|
+
'set ytics format "%.0f%%" textcolor rgb "black"',
|
70
100
|
'set grid linecolor rgb "gray"',
|
71
101
|
'set xtics format "%b/%y" font "monospace,8" textcolor rgb "black"',
|
72
102
|
'set autoscale',
|
73
103
|
'set style fill solid',
|
74
104
|
'set boxwidth 0.75 relative',
|
75
105
|
[
|
76
|
-
"plot \"#{dat.path}\" using 1:
|
106
|
+
"plot \"#{dat.path}\" using 1:3 with lines",
|
77
107
|
'title "Test HoC" linecolor rgb "#81b341"',
|
78
|
-
', "" using 1:
|
79
|
-
', "" using 1:
|
80
|
-
', "" using 1:5 with boxes title "LoC" linecolor rgb "cyan"',
|
81
|
-
', "" using 1:6 with boxes title "Issues" linecolor rgb "orange"'
|
108
|
+
', "" using 1:4 with lines title "HoC" linecolor rgb "red"',
|
109
|
+
', "" using 1:7 with lines title "Issues" linecolor rgb "orange"'
|
82
110
|
].join(' ')
|
83
111
|
]
|
84
112
|
Exec.new("gnuplot -e '#{gpi.join('; ')}'").stdout
|
@@ -107,15 +135,23 @@ module TDX
|
|
107
135
|
|
108
136
|
def loc(path)
|
109
137
|
Nokogiri::XML.parse(Exec.new('cloc . --xml --quiet', path).stdout)
|
110
|
-
.xpath('/results/languages/total/@code')
|
138
|
+
.xpath('/results/languages/total/@code')[0].to_s.to_i
|
111
139
|
end
|
112
140
|
|
113
|
-
def
|
114
|
-
|
141
|
+
def pure(path)
|
142
|
+
exclude = if @opts[:tests]
|
143
|
+
@opts[:tests].map { |e| "--exclude=#{e}" }
|
144
|
+
else
|
145
|
+
[]
|
146
|
+
end
|
147
|
+
Exec.new(
|
148
|
+
'hoc ' + exclude.join(' '),
|
149
|
+
path
|
150
|
+
).stdout.strip.to_i
|
115
151
|
end
|
116
152
|
|
117
|
-
def
|
118
|
-
Exec.new('hoc', path).stdout.strip
|
153
|
+
def hoc(path)
|
154
|
+
Exec.new('hoc', path).stdout.strip.to_i
|
119
155
|
end
|
120
156
|
|
121
157
|
def issues(commits)
|
data/lib/tdx/exec.rb
CHANGED
data/lib/tdx/version.rb
CHANGED
data/test/test__helper.rb
CHANGED
data/test/test_tdx.rb
CHANGED
@@ -33,11 +33,6 @@ class TestPDD < Minitest::Test
|
|
33
33
|
def test_git_repo
|
34
34
|
skip if Gem.win_platform?
|
35
35
|
Dir.mktmpdir 'test' do |dir|
|
36
|
-
opts = opts(
|
37
|
-
[
|
38
|
-
'--tests', 'tests'
|
39
|
-
]
|
40
|
-
)
|
41
36
|
raise unless system("
|
42
37
|
set -e
|
43
38
|
cd '#{dir}'
|
@@ -52,17 +47,20 @@ class TestPDD < Minitest::Test
|
|
52
47
|
")
|
53
48
|
assert(
|
54
49
|
TDX::Base.new(
|
55
|
-
"file:///#{File.join(dir, 'repo')}",
|
50
|
+
"file:///#{File.join(dir, 'repo')}",
|
51
|
+
opts(['--tests', 'tests/**/*'])
|
56
52
|
).svg.include?('<path ')
|
57
53
|
)
|
58
54
|
end
|
59
55
|
end
|
60
56
|
|
61
57
|
def test_real_github_repo
|
62
|
-
|
58
|
+
File.write(
|
59
|
+
'/tmp/a.svg',
|
63
60
|
TDX::Base.new(
|
64
|
-
'https://github.com/yegor256/
|
65
|
-
|
61
|
+
'https://github.com/yegor256/jare.git',
|
62
|
+
opts(['--tests', 'src/test/**/*'])
|
63
|
+
).svg
|
66
64
|
)
|
67
65
|
end
|
68
66
|
|
@@ -70,7 +68,7 @@ class TestPDD < Minitest::Test
|
|
70
68
|
|
71
69
|
def opts(args)
|
72
70
|
Slop.parse args do |o|
|
73
|
-
o.
|
71
|
+
o.array '-t', '--tests', argument: :required
|
74
72
|
end
|
75
73
|
end
|
76
74
|
end
|