cobench 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 625fd5b08eece40f4c28722c9258b730336e360cd6d3c51e67a8a6cc969072cd
4
- data.tar.gz: 5e5e65c72b3568c12edf3cbca87c20526e40704388d31dec0221a5b0fe526a4a
3
+ metadata.gz: 106c637350232c212145a1a648680688634f9b44f488fbe660f2003666faba23
4
+ data.tar.gz: eaff88cb6edbc88d3d5616df41d1344c38380b38aca26b642987420f73805a93
5
5
  SHA512:
6
- metadata.gz: c3a6ffbbe1ba49ece0b153abe1c98e5885295a32aa834c5ba0972ec15e01a3c3dc61d2032f9e3f281614b25567e3f0003357f6fec17728a9e45651739238ce05
7
- data.tar.gz: bf16dac666f420e6b576fa0a086d2c1dfd84d8193acec2e863c8ed1be140f722db8ac3d186fa8448a7ae9015a2be9b588a56fc1e933c045b034b4eeab4d492a4
6
+ metadata.gz: 73f87f462a82919c5d435237276952a5b94be9397a053b68c17ad636e50e0b5c71dbe54b6d3118a19600e6eaf9bbd5d113e350ebf5c1330e635f5b38fd49e3b3
7
+ data.tar.gz: fd592b9422b5f48802723027eabcc93ba5a7a23d9f2eedf17d0cd184acf014a7668c1464e3821750a650da4771c81b9b936cdaf02a2fa9c3e43b7ab0ccc988dd
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,15 @@ SOFTWARE.
76
76
  </a>
77
77
  <xsl:text> on </xsl:text>
78
78
  <xsl:value-of select="cobench/@time"/>
79
- <xsl:text>.</xsl:text>
79
+ <xsl:text>. </xsl:text>
80
+ <xsl:text>"Pulls" is the total number of pull requests created by the user and merged. </xsl:text>
81
+ <xsl:text>"Issues" is the total number of issues submitted by the user. </xsl:text>
82
+ <xsl:text>"Commits" is the total number of commits authored by the user. </xsl:text>
83
+ <xsl:text>"Score" is an arithmetic summary of all other numbers with multipliers: </xsl:text>
84
+ <xsl:text>one Pull costs 100 points, </xsl:text>
85
+ <xsl:text>one Issue 50 points, </xsl:text>
86
+ <xsl:text>one Commit 5 points, </xsl:text>
87
+ <xsl:text>one HoC 1 point.</xsl:text>
80
88
  </p>
81
89
  <p>
82
90
  <xsl:text>The numbers you see reflect the activity of the last </xsl:text>
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,20 +92,25 @@ 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: 'Test1', total: Random.new.rand(100), href: 'https://github.com/' },
107
- { title: 'Test2', total: Random.new.rand(100), href: 'https://github.com/' }
112
+ { title: 'Issues', total: Random.new.rand(100), href: 'https://github.com/' },
113
+ { title: 'Pulls', total: Random.new.rand(100), href: 'https://github.com/' }
108
114
  ]
109
115
  else
110
116
  measures = m.take(loog)
@@ -116,6 +122,22 @@ begin
116
122
  end
117
123
  end
118
124
  end
125
+ data.each do |u, ms|
126
+ score = ms.map do |t, h|
127
+ h[:total] * if t == 'HoC'
128
+ 1
129
+ elsif t == 'Pulls'
130
+ 100
131
+ elsif t == 'Issues'
132
+ 50
133
+ elsif t == 'Commits'
134
+ 5
135
+ else
136
+ raise "Unknown title '#{t}'"
137
+ end
138
+ end.inject(0, :+)
139
+ data[u]['Score'] = { total: score, href: '' }
140
+ end
119
141
  builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
120
142
  xml.cobench(time: Time.now, days: opts[:days]) do
121
143
  xml.titles do
@@ -0,0 +1,54 @@
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
+ total = json.items.count do |c|
41
+ sha = c.sha
42
+ repo = c.repository.full_name
43
+ next unless Cobench::Match.new(@opts, loog).matches?(repo)
44
+ loog.debug("Including #{sha} in #{repo}")
45
+ end
46
+ [
47
+ {
48
+ title: 'Commits',
49
+ total: total,
50
+ href: Iri.new('https://github.com/search').add(q: q)
51
+ }
52
+ ]
53
+ end
54
+ 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 = "#{@user} in:comments type:issue author:#{@user} created:>#{from}"
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 = "#{@user} in:comments type:pr author:#{@user} is:merged closed:>#{from}"
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
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2022 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Cobench
26
- VERSION = '0.0.10'.freeze
26
+ VERSION = '0.0.11'.freeze
27
27
  end
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.10
4
+ version: 0.0.11
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-14 00:00:00.000000000 Z
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