cobench 0.0.11 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/index.xsl +24 -7
- data/bin/cobench +13 -8
- data/lib/cobench/mask.rb +2 -2
- data/lib/cobench/metrics/commits.rb +10 -0
- data/lib/cobench/version.rb +1 -1
- data/test/test_mask.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a36f769e2bd7c22261752671935908e1e9776228406eab462a80e14ec47f5888
|
4
|
+
data.tar.gz: 528467b0d08b48aa958d2bc5eb5d075322f55af081834982a2fc06c02e5c0919
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce12d12d53b6cda30c247125455e7b5b7f9cd256a05df04a99e9871606e6a862436ac802057848068c5d9cd88165baa326d79ebbaee8b1455c124f96e2cbe6fd
|
7
|
+
data.tar.gz: '059a36cb0f76dbfa525a87ac56b38cd1816eedeabeb89389cdd5048ba2ac1d35488655b0adfc7dd01bc4b86abfa78ab55fea4b54a7794db8150b4804eb5fc868'
|
data/assets/index.xsl
CHANGED
@@ -77,9 +77,26 @@ SOFTWARE.
|
|
77
77
|
<xsl:text> on </xsl:text>
|
78
78
|
<xsl:value-of select="cobench/@time"/>
|
79
79
|
<xsl:text>. </xsl:text>
|
80
|
-
<xsl:text>"
|
81
|
-
<
|
82
|
-
|
80
|
+
<xsl:text>"Commits" is the total number of </xsl:text>
|
81
|
+
<a href="https://github.com/git-guides/git-commit">
|
82
|
+
<xsl:text>Git commits</xsl:text>
|
83
|
+
</a>
|
84
|
+
<xsl:text> authored by the user. </xsl:text>
|
85
|
+
<xsl:text>"HoC" is the total number of user's hits of code. </xsl:text>
|
86
|
+
<a href="https://www.yegor256.com/2014/11/14/hits-of-code.html">
|
87
|
+
<xsl:text>hits of code</xsl:text>
|
88
|
+
</a>
|
89
|
+
<xsl:text>. </xsl:text>
|
90
|
+
<xsl:text>"Issues" is the total number of issues. </xsl:text>
|
91
|
+
<a href="https://docs.github.com/en/issues">
|
92
|
+
<xsl:text>issues</xsl:text>
|
93
|
+
</a>
|
94
|
+
<xsl:text>. </xsl:text>
|
95
|
+
<xsl:text>"Pulls" is the total number of </xsl:text>
|
96
|
+
<a href="https://docs.github.com/en/pull-requests">
|
97
|
+
<xsl:text>pull requests</xsl:text>
|
98
|
+
</a>
|
99
|
+
<xsl:text> created by the user and merged. </xsl:text>
|
83
100
|
<xsl:text>"Score" is an arithmetic summary of all other numbers with multipliers: </xsl:text>
|
84
101
|
<xsl:text>one Pull costs 100 points, </xsl:text>
|
85
102
|
<xsl:text>one Issue 50 points, </xsl:text>
|
@@ -134,13 +151,13 @@ SOFTWARE.
|
|
134
151
|
<xsl:template match="m">
|
135
152
|
<td class="num">
|
136
153
|
<xsl:choose>
|
137
|
-
<xsl:when test="@href">
|
154
|
+
<xsl:when test="@href = ''">
|
155
|
+
<xsl:value-of select="."/>
|
156
|
+
</xsl:when>
|
157
|
+
<xsl:otherwise>
|
138
158
|
<a href="{@href}">
|
139
159
|
<xsl:value-of select="."/>
|
140
160
|
</a>
|
141
|
-
</xsl:when>
|
142
|
-
<xsl:otherwise>
|
143
|
-
<xsl:value-of select="."/>
|
144
161
|
</xsl:otherwise>
|
145
162
|
</xsl:choose>
|
146
163
|
</td>
|
data/bin/cobench
CHANGED
@@ -56,7 +56,7 @@ opts = Slop.parse(args, strict: true, help: true) do |o|
|
|
56
56
|
o.array '--exclude', 'Mask of GitHub repo to exclude'
|
57
57
|
end
|
58
58
|
|
59
|
-
if opts.help?
|
59
|
+
if opts.help? || opts[:coder].empty?
|
60
60
|
puts opts
|
61
61
|
exit
|
62
62
|
end
|
@@ -95,30 +95,35 @@ begin
|
|
95
95
|
loog.info("Reading GitHub data for the last #{opts[:days]} days")
|
96
96
|
titles = {}
|
97
97
|
opts[:coder].each do |u|
|
98
|
-
|
99
|
-
|
98
|
+
user = u.downcase
|
99
|
+
loog.info("Scanning #{user}...")
|
100
|
+
data[user] = {}
|
100
101
|
Dir[File.join(__dir__, '../lib/cobench/metrics/*.rb')].each do |f|
|
101
102
|
name = File::basename(f).split('.')[0]
|
102
103
|
if !opts[:metrics].empty? && !opts[:metrics].include?(name)
|
103
|
-
loog.info("Ignoring #{
|
104
|
+
loog.info("Ignoring #{user}/#{name} due to --metrics")
|
104
105
|
next
|
105
106
|
end
|
106
107
|
type = "Cobench::#{name.capitalize}"
|
107
|
-
loog.info("Reading #{
|
108
|
+
loog.info("Reading #{user}/#{name}...")
|
108
109
|
require_relative f
|
109
110
|
m = type.split('::').reduce(Module, :const_get).new(api, u, opts)
|
110
111
|
if opts.dry?
|
111
112
|
measures = [
|
112
113
|
{ title: 'Issues', total: Random.new.rand(100), href: 'https://github.com/' },
|
113
|
-
{ title: 'Pulls', total: Random.new.rand(100), href: '
|
114
|
+
{ title: 'Pulls', total: Random.new.rand(100), href: '' },
|
115
|
+
{ title: 'HoC', total: Random.new.rand(100), href: '' },
|
116
|
+
{ title: 'HoC', total: Random.new.rand(100), href: '' }
|
114
117
|
]
|
115
118
|
else
|
116
119
|
measures = m.take(loog)
|
117
120
|
end
|
118
121
|
measures.each do |d|
|
119
|
-
|
122
|
+
before = 0
|
123
|
+
before += data[u][d[:title]][:total] if data[u][d[:title]] != nil
|
124
|
+
data[u][d[:title]] = { total: d[:total] + before, href: d[:href] }
|
120
125
|
titles[d[:title]] = d[:title]
|
121
|
-
loog.info("The value of #{
|
126
|
+
loog.info("The value of #{user}/#{d[:title]} is #{d[:total]}")
|
122
127
|
end
|
123
128
|
end
|
124
129
|
end
|
data/lib/cobench/mask.rb
CHANGED
@@ -24,11 +24,11 @@
|
|
24
24
|
# License:: MIT
|
25
25
|
class Cobench::Mask
|
26
26
|
def initialize(txt)
|
27
|
-
@org, @repo = txt.split('/')
|
27
|
+
@org, @repo = txt.downcase.split('/')
|
28
28
|
end
|
29
29
|
|
30
30
|
def matches?(repo)
|
31
|
-
org, repo = repo.split('/')
|
31
|
+
org, repo = repo.downcase.split('/')
|
32
32
|
return false if ['', nil].include?(org)
|
33
33
|
return false if ['', nil].include?(repo)
|
34
34
|
return false if org != @org && @org != '*'
|
@@ -37,17 +37,27 @@ class Cobench::Commits
|
|
37
37
|
q = "author:#{@user} author-date:>#{from}"
|
38
38
|
json = @api.search_commits(q)
|
39
39
|
loog.debug("Found #{json.total_count} commits")
|
40
|
+
hoc = 0
|
40
41
|
total = json.items.count do |c|
|
41
42
|
sha = c.sha
|
42
43
|
repo = c.repository.full_name
|
43
44
|
next unless Cobench::Match.new(@opts, loog).matches?(repo)
|
44
45
|
loog.debug("Including #{sha} in #{repo}")
|
46
|
+
json = @api.commit(repo, sha)
|
47
|
+
hocs = json.stats.total
|
48
|
+
loog.debug("Found #{hocs} HoC in #{sha}")
|
49
|
+
hoc += hocs
|
45
50
|
end
|
46
51
|
[
|
47
52
|
{
|
48
53
|
title: 'Commits',
|
49
54
|
total: total,
|
50
55
|
href: Iri.new('https://github.com/search').add(q: q)
|
56
|
+
},
|
57
|
+
{
|
58
|
+
title: 'HoC',
|
59
|
+
total: hoc,
|
60
|
+
href: ''
|
51
61
|
}
|
52
62
|
]
|
53
63
|
end
|
data/lib/cobench/version.rb
CHANGED
data/test/test_mask.rb
CHANGED
@@ -28,8 +28,8 @@ require_relative '../lib/cobench/mask'
|
|
28
28
|
class TestMask < Minitest::Test
|
29
29
|
def test_positive
|
30
30
|
assert Cobench::Mask.new('*/*').matches?('foo/bar')
|
31
|
-
assert Cobench::Mask.new('test/*').matches?('
|
32
|
-
assert Cobench::Mask.new('test/hello').matches?('test/
|
31
|
+
assert Cobench::Mask.new('test/*').matches?('Test/one')
|
32
|
+
assert Cobench::Mask.new('test/hello').matches?('test/Hello')
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_negative
|