cobench 0.0.10 → 0.0.13
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 +31 -6
- data/bin/cobench +29 -3
- data/lib/cobench/metrics/commits.rb +64 -0
- data/lib/cobench/metrics/issues.rb +1 -1
- data/lib/cobench/metrics/pulls.rb +1 -1
- data/lib/cobench/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b298ef3dbb65893787af11d1b4cf86e9b02169dc2c83a3e34d902c2c26a2d43
|
4
|
+
data.tar.gz: b13f5d42eb289a3e6a5fdd9bdb8a5c31a2357ec1c8a3f35cc35b3c5ec1b6c9e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83080a2db71ccd8d2e93a00bcbb0bd33a1aa3ddd3ae4a31accdc442403f65b22db215b6e2887dae69c43f0a3655293c7d398f8d5be2819e272995162884923bc
|
7
|
+
data.tar.gz: 86b2a9d10ac6e59b41b43ba16c1e55aa0cec3b83729556f53a7530b847a6c2b5738bc8b142ebca0583ac231dc3750156c870776dfad93f2201c1467ab85c67eb
|
data/assets/index.xsl
CHANGED
@@ -48,7 +48,7 @@ SOFTWARE.
|
|
48
48
|
.num { text-align: right; }
|
49
49
|
.left { border-bottom: 0; }
|
50
50
|
header { text-align: center; }
|
51
|
-
footer { text-align: center; font-size: 0.8em; }
|
51
|
+
footer { text-align: center; font-size: 0.8em; line-height: 1.2em; color: gray; }
|
52
52
|
article { width: 60em; border: 0; }
|
53
53
|
.sorter { cursor: pointer; }
|
54
54
|
</style>
|
@@ -76,7 +76,32 @@ SOFTWARE.
|
|
76
76
|
</a>
|
77
77
|
<xsl:text> on </xsl:text>
|
78
78
|
<xsl:value-of select="cobench/@time"/>
|
79
|
-
<xsl:text
|
79
|
+
<xsl:text>. </xsl:text>
|
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>
|
100
|
+
<xsl:text>"Score" is an arithmetic summary of all other numbers with multipliers: </xsl:text>
|
101
|
+
<xsl:text>one Pull costs 100 points, </xsl:text>
|
102
|
+
<xsl:text>one Issue 50 points, </xsl:text>
|
103
|
+
<xsl:text>one Commit 5 points, </xsl:text>
|
104
|
+
<xsl:text>one HoC 1 point.</xsl:text>
|
80
105
|
</p>
|
81
106
|
<p>
|
82
107
|
<xsl:text>The numbers you see reflect the activity of the last </xsl:text>
|
@@ -126,13 +151,13 @@ SOFTWARE.
|
|
126
151
|
<xsl:template match="m">
|
127
152
|
<td class="num">
|
128
153
|
<xsl:choose>
|
129
|
-
<xsl:when test="@href">
|
154
|
+
<xsl:when test="@href = ''">
|
155
|
+
<xsl:value-of select="."/>
|
156
|
+
</xsl:when>
|
157
|
+
<xsl:otherwise>
|
130
158
|
<a href="{@href}">
|
131
159
|
<xsl:value-of select="."/>
|
132
160
|
</a>
|
133
|
-
</xsl:when>
|
134
|
-
<xsl:otherwise>
|
135
|
-
<xsl:value-of select="."/>
|
136
161
|
</xsl:otherwise>
|
137
162
|
</xsl:choose>
|
138
163
|
</td>
|
data/bin/cobench
CHANGED
@@ -51,6 +51,7 @@ opts = Slop.parse(args, strict: true, help: true) do |o|
|
|
51
51
|
o.string '--to', 'Directory where to save all files to', default: './cobench'
|
52
52
|
o.string '--token', 'GitHub authentication token'
|
53
53
|
o.array '--coder', 'GitHub nickname of a coder to track'
|
54
|
+
o.array '--metrics', 'Names of metrics to use (all by default)'
|
54
55
|
o.array '--include', 'Mask of GitHub repo to include, e.g. yegor256/*'
|
55
56
|
o.array '--exclude', 'Mask of GitHub repo to exclude'
|
56
57
|
end
|
@@ -91,31 +92,56 @@ begin
|
|
91
92
|
end
|
92
93
|
api.auto_paginate = true
|
93
94
|
api = Obk.new(api, pause: 2000)
|
95
|
+
loog.info("Reading GitHub data for the last #{opts[:days]} days")
|
94
96
|
titles = {}
|
95
97
|
opts[:coder].each do |u|
|
96
98
|
loog.info("Scanning #{u}...")
|
97
99
|
data[u] = {}
|
98
100
|
Dir[File.join(__dir__, '../lib/cobench/metrics/*.rb')].each do |f|
|
99
101
|
name = File::basename(f).split('.')[0]
|
102
|
+
if !opts[:metrics].empty? && !opts[:metrics].include?(name)
|
103
|
+
loog.info("Ignoring #{u}/#{name} due to --metrics")
|
104
|
+
next
|
105
|
+
end
|
100
106
|
type = "Cobench::#{name.capitalize}"
|
101
107
|
loog.info("Reading #{u}/#{name}...")
|
102
108
|
require_relative f
|
103
109
|
m = type.split('::').reduce(Module, :const_get).new(api, u, opts)
|
104
110
|
if opts.dry?
|
105
111
|
measures = [
|
106
|
-
{ title: '
|
107
|
-
{ title: '
|
112
|
+
{ title: 'Issues', total: Random.new.rand(100), href: 'https://github.com/' },
|
113
|
+
{ title: 'Pulls', total: Random.new.rand(100), href: '' },
|
114
|
+
{ title: 'HoC', total: Random.new.rand(100), href: '' },
|
115
|
+
{ title: 'HoC', total: Random.new.rand(100), href: '' }
|
108
116
|
]
|
109
117
|
else
|
110
118
|
measures = m.take(loog)
|
111
119
|
end
|
112
120
|
measures.each do |d|
|
113
|
-
|
121
|
+
before = 0
|
122
|
+
before += data[u][d[:title]][:total] if data[u][d[:title]] != nil
|
123
|
+
data[u][d[:title]] = { total: d[:total] + before, href: d[:href] }
|
114
124
|
titles[d[:title]] = d[:title]
|
115
125
|
loog.info("The value of #{u}/#{d[:title]} is #{d[:total]}")
|
116
126
|
end
|
117
127
|
end
|
118
128
|
end
|
129
|
+
data.each do |u, ms|
|
130
|
+
score = ms.map do |t, h|
|
131
|
+
h[:total] * if t == 'HoC'
|
132
|
+
1
|
133
|
+
elsif t == 'Pulls'
|
134
|
+
100
|
135
|
+
elsif t == 'Issues'
|
136
|
+
50
|
137
|
+
elsif t == 'Commits'
|
138
|
+
5
|
139
|
+
else
|
140
|
+
raise "Unknown title '#{t}'"
|
141
|
+
end
|
142
|
+
end.inject(0, :+)
|
143
|
+
data[u]['Score'] = { total: score, href: '' }
|
144
|
+
end
|
119
145
|
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
120
146
|
xml.cobench(time: Time.now, days: opts[:days]) do
|
121
147
|
xml.titles do
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Copyright (c) 2022 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
require 'iri'
|
22
|
+
require_relative '../match'
|
23
|
+
|
24
|
+
# Commits in GitHub API.
|
25
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
26
|
+
# Copyright:: Copyright (c) 2022 Yegor Bugayenko
|
27
|
+
# License:: MIT
|
28
|
+
class Cobench::Commits
|
29
|
+
def initialize(api, user, opts)
|
30
|
+
@api = api
|
31
|
+
@user = user
|
32
|
+
@opts = opts
|
33
|
+
end
|
34
|
+
|
35
|
+
def take(loog)
|
36
|
+
from = (Time.now - (60 * 60 * 24 * @opts[:days])).strftime('%Y-%m-%d')
|
37
|
+
q = "author:#{@user} author-date:>#{from}"
|
38
|
+
json = @api.search_commits(q)
|
39
|
+
loog.debug("Found #{json.total_count} commits")
|
40
|
+
hoc = 0
|
41
|
+
total = json.items.count do |c|
|
42
|
+
sha = c.sha
|
43
|
+
repo = c.repository.full_name
|
44
|
+
next unless Cobench::Match.new(@opts, loog).matches?(repo)
|
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
|
50
|
+
end
|
51
|
+
[
|
52
|
+
{
|
53
|
+
title: 'Commits',
|
54
|
+
total: total,
|
55
|
+
href: Iri.new('https://github.com/search').add(q: q)
|
56
|
+
},
|
57
|
+
{
|
58
|
+
title: 'HoC',
|
59
|
+
total: hoc,
|
60
|
+
href: ''
|
61
|
+
}
|
62
|
+
]
|
63
|
+
end
|
64
|
+
end
|
@@ -34,7 +34,7 @@ class Cobench::Issues
|
|
34
34
|
|
35
35
|
def take(loog)
|
36
36
|
from = (Time.now - (60 * 60 * 24 * @opts[:days])).strftime('%Y-%m-%d')
|
37
|
-
q = "
|
37
|
+
q = "in:comments type:issue author:#{@user} created:>#{from}"
|
38
38
|
json = @api.search_issues(q)
|
39
39
|
loog.debug("Found #{json.total_count} issues")
|
40
40
|
total = json.items.count do |p|
|
@@ -34,7 +34,7 @@ class Cobench::Pulls
|
|
34
34
|
|
35
35
|
def take(loog)
|
36
36
|
from = (Time.now - (60 * 60 * 24 * @opts[:days])).strftime('%Y-%m-%d')
|
37
|
-
q = "
|
37
|
+
q = "in:comments type:pr author:#{@user} is:merged closed:>#{from}"
|
38
38
|
json = @api.search_issues(q)
|
39
39
|
loog.debug("Found #{json.total_count} pull requests")
|
40
40
|
hoc = 0
|
data/lib/cobench/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cobench
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|
@@ -252,6 +252,7 @@ files:
|
|
252
252
|
- features/support/env.rb
|
253
253
|
- lib/cobench/mask.rb
|
254
254
|
- lib/cobench/match.rb
|
255
|
+
- lib/cobench/metrics/commits.rb
|
255
256
|
- lib/cobench/metrics/issues.rb
|
256
257
|
- lib/cobench/metrics/pulls.rb
|
257
258
|
- lib/cobench/version.rb
|