fief 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3543ddd3cd50e0eaee854ded81482f5055a33b802cab4e27698cfc93b7e9d7a4
4
- data.tar.gz: 20b02a86929d62c77e177c3b1d7f495adc07a1d3463d80bf4361c0f379a64638
3
+ metadata.gz: ba06e870d6a95356820b15bd3f692a4662057e7a466cf7a877065228bd74e536
4
+ data.tar.gz: 1deec8fafbe79d23d4d2f7a580daec7089b056ad3c03a2d29c36150251721496
5
5
  SHA512:
6
- metadata.gz: d770b689daff2ed3ef9efa70789cdf2503a2f0c8b0ed82620782ce05b6e270676dd47b8f7a551ad5378a500e33ca385754e40a64ef096261727b58ee792c2650
7
- data.tar.gz: f2a36f91fa8c01df22501c51ee2b49dffa88450da44f998c23965a5589b65852dc914f1c8a6e4d2dfdcc4ecc051999e82732bd3848bd342ba77af2910d0e8b01
6
+ metadata.gz: 0b80671ae6d23c725dcaf3f94920682a45b2ec0d304736e6266d888fd976ceab3eb810c06d48dd828fe4d0d1c8c24c45943a33b17668e3baf790a9a39d149076
7
+ data.tar.gz: 24d27ab6bb0cf97bf7b4ef9176381918f295641448f31dbaca719ddb3cb45eed6ab5dd977b100572a77734e8612a2c5ce4038d1feb7dd5388b7e6967174cb686
@@ -21,12 +21,13 @@ jobs:
21
21
  - run: |
22
22
  bin/fief --verbose --token ${{ secrets.TOKEN }} --to gh-pages \
23
23
  --include jcabi/* \
24
+ --exclude jcabi/.github \
24
25
  --include yegor256/cactoos \
25
26
  --include yegor256/takes \
26
27
  --include yegor256/xembly
27
28
  - run: mkdir -p gh-pages/$(date +'%Y/%m/%d')
28
29
  - run: cp gh-pages/index.xml gh-pages/$(date +'%Y/%m/%d')/index.xml
29
- - uses: JamesIves/github-pages-deploy-action@4.1.4
30
+ - uses: JamesIves/github-pages-deploy-action@v4.4.2
30
31
  with:
31
32
  branch: gh-pages
32
33
  folder: gh-pages
@@ -11,8 +11,8 @@ jobs:
11
11
  test:
12
12
  strategy:
13
13
  matrix:
14
- os: [ubuntu-20.04, macos-12]
15
- ruby: ['2.7', '3.0']
14
+ os: [ubuntu-20.04]
15
+ ruby: ['3.0']
16
16
  runs-on: ${{ matrix.os }}
17
17
  steps:
18
18
  - uses: actions/checkout@v3
data/Gemfile CHANGED
@@ -24,8 +24,8 @@ gemspec
24
24
  gem 'cucumber', '8.0.0', require: false
25
25
  gem 'minitest', '5.15.0', require: false
26
26
  gem 'rake', '13.0.6', require: false
27
- gem 'rdoc', '6.4.0', require: false
28
- gem 'rubocop', '1.32.0', require: false
29
- gem 'rubocop-rspec', '2.11.1', require: false
27
+ gem 'rdoc', '6.5.0', require: false
28
+ gem 'rubocop', '1.52.0', require: false
29
+ gem 'rubocop-rspec', '2.22.0', require: false
30
30
  gem 'simplecov', '0.22.0', require: false
31
31
  gem 'xcop', '0.7.1', require: false
data/README.md CHANGED
@@ -9,7 +9,6 @@
9
9
  [![Gem Version](https://badge.fury.io/rb/fief.svg)](http://badge.fury.io/rb/fief)
10
10
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/fief/blob/master/LICENSE.txt)
11
11
  [![Maintainability](https://api.codeclimate.com/v1/badges/396ec0584e0a84adc723/maintainability)](https://codeclimate.com/github/yegor256/fief/maintainability)
12
- [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/fief.svg)](https://codecov.io/github/yegor256/fief?branch=master)
13
12
  ![Lines of code](https://img.shields.io/tokei/lines/github/yegor256/fief)
14
13
  [![Hits-of-Code](https://hitsofcode.com/github/yegor256/fief)](https://hitsofcode.com/view/github/yegor256/fief)
15
14
 
@@ -26,6 +25,8 @@ Then, run it locally and read its output:
26
25
  $ fief --repo yegor256/fief --verbose
27
26
  ```
28
27
 
28
+ For example, [here is mine](https://yegor256.github.io/fief/).
29
+
29
30
  ## How to contribute
30
31
 
31
32
  Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
data/assets/index.xsl CHANGED
@@ -98,7 +98,7 @@ SOFTWARE.
98
98
  <xsl:text>,1]]</xsl:text>
99
99
  </xsl:attribute>
100
100
  <colgroup>
101
- <col style="width: 2.5em;"/>
101
+ <col/>
102
102
  <xsl:for-each select="fief/titles/title">
103
103
  <xsl:sort select="."/>
104
104
  <col/>
@@ -189,6 +189,11 @@ SOFTWARE.
189
189
  <xsl:attribute name="data-sort-value">
190
190
  <xsl:copy-of select="."/>
191
191
  </xsl:attribute>
192
+ <xsl:if test="@alert">
193
+ <xsl:attribute name="class">
194
+ <xsl:text>firebrick</xsl:text>
195
+ </xsl:attribute>
196
+ </xsl:if>
192
197
  <xsl:copy-of select="."/>
193
198
  </td>
194
199
  </xsl:template>
data/bin/fief CHANGED
@@ -104,7 +104,10 @@ def build_xml(opts, loog)
104
104
  else
105
105
  measures = m.take(loog)
106
106
  end
107
- data << {name: repo, metrics: measures}
107
+ if data.find { |d| d[:name] == repo }.nil?
108
+ data << {name: repo, metrics: []}
109
+ end
110
+ data.find { |d| d[:name] == repo }[:metrics] += measures
108
111
  end
109
112
  end
110
113
  builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
@@ -122,6 +125,7 @@ def build_xml(opts, loog)
122
125
  xml.metrics do
123
126
  r[:metrics].each do |ms|
124
127
  xml.m(id: ms[:title]) do
128
+ xml.parent.set_attribute('alert', 'yes') if ms[:alert]
125
129
  xml.text ms[:value]
126
130
  end
127
131
  end
@@ -31,11 +31,37 @@ class Fief::Issues
31
31
 
32
32
  def take(loog)
33
33
  json = @api.list_issues(@repo, state: 'open')
34
- loog.debug("Found #{json.count} open issues in #{@repo}")
34
+ total = json.count
35
+ loog.debug("Found #{total} open issues in #{@repo}")
36
+ old = 0
37
+ older = 0
38
+ json.each do |issue|
39
+ num = issue[:number]
40
+ data = @api.issue(@repo, num)
41
+ if data[:created_at] < Time.now - (60 * 60 * 24 * 14)
42
+ loog.debug("Issue #{@repo}/##{num} is old")
43
+ old += 1
44
+ end
45
+ if data[:created_at] < Time.now - (60 * 60 * 24 * 56)
46
+ loog.debug("Issue #{@repo}/##{num} is very old")
47
+ older += 1
48
+ end
49
+ end
35
50
  [
36
51
  {
37
52
  title: 'Open Issues',
38
- value: json.count
53
+ value: total,
54
+ alert: false
55
+ },
56
+ {
57
+ title: 'Old Issues',
58
+ value: old,
59
+ alert: older > total * 0.4
60
+ },
61
+ {
62
+ title: 'Older Issues',
63
+ value: older,
64
+ alert: older > total * 0.4
39
65
  }
40
66
  ]
41
67
  end
@@ -31,11 +31,37 @@ class Fief::Pulls
31
31
 
32
32
  def take(loog)
33
33
  json = @api.pull_requests(@repo, state: 'open')
34
- loog.debug("Found #{json.count} open pull requests in #{@repo}")
34
+ total = json.count
35
+ loog.debug("Found #{total} open pull requests in #{@repo}")
36
+ old = 0
37
+ older = 0
38
+ json.each do |pr|
39
+ num = pr[:number]
40
+ data = @api.pull_request(@repo, num)
41
+ if data[:created_at] < Time.now - (60 * 60 * 24 * 14)
42
+ loog.debug("PR #{@repo}/##{num} is old")
43
+ old += 1
44
+ end
45
+ if data[:created_at] < Time.now - (60 * 60 * 24 * 56)
46
+ loog.debug("PR #{@repo}/##{num} is very old")
47
+ older += 1
48
+ end
49
+ end
35
50
  [
36
51
  {
37
- title: 'Open Pull Requests',
38
- value: json.count
52
+ title: 'Open PRs',
53
+ value: total,
54
+ alert: false
55
+ },
56
+ {
57
+ title: 'Old PRs',
58
+ value: old,
59
+ alert: older > total * 0.4
60
+ },
61
+ {
62
+ title: 'Older PRs',
63
+ value: older,
64
+ alert: older > total * 0.2
39
65
  }
40
66
  ]
41
67
  end
data/lib/fief/version.rb CHANGED
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2023 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Fief
26
- VERSION = '0.0.1'.freeze
26
+ VERSION = '0.0.2'.freeze
27
27
  end
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2023 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 'minitest/autorun'
22
+ require 'octokit'
23
+ require 'loog'
24
+ require_relative '../../lib/fief/metrics/issues'
25
+
26
+ # Test for Issues.
27
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
+ # Copyright:: Copyright (c) 2023 Yegor Bugayenko
29
+ # License:: MIT
30
+ class TestIssues < Minitest::Test
31
+ def test_real
32
+ api = Octokit::Client.new
33
+ m = Fief::Issues.new(api, 'yegor256/fief', {})
34
+ ms = m.take(Loog::VERBOSE)
35
+ assert !ms.empty?
36
+ p ms
37
+ rescue Octokit::TooManyRequests => e
38
+ puts e.message
39
+ skip
40
+ end
41
+ end
@@ -31,7 +31,7 @@ class TestPulls < Minitest::Test
31
31
  def test_real
32
32
  api = Octokit::Client.new
33
33
  m = Fief::Pulls.new(api, 'yegor256/fief', {})
34
- ms = m.take(Loog::NULL)
34
+ ms = m.take(Loog::VERBOSE)
35
35
  assert !ms.empty?
36
36
  p ms
37
37
  rescue Octokit::TooManyRequests => e
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fief
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -162,6 +162,7 @@ files:
162
162
  - logo.png
163
163
  - logo.svg
164
164
  - renovate.json
165
+ - test/metrics/test_issues.rb
165
166
  - test/metrics/test_pulls.rb
166
167
  - test/test__helper.rb
167
168
  - test/test_mask.rb