cobench 0.0.42 → 0.0.43
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 +4 -4
- data/assets/index.xsl +1 -0
- data/bin/cobench +2 -1
- data/lib/cobench/metrics/pulls.rb +8 -2
- data/lib/cobench/version.rb +1 -1
- data/test/metrics/test_pulls.rb +41 -0
- 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: cabe10e0f4143687f43ae2f9114906197d14b2cf47f29111bdc1d974e1615dc9
         | 
| 4 | 
            +
              data.tar.gz: 2d7c43fb9702ee84a2844995724f05193cf816414cc027cbeb761f2b34f84443
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 7f5f3e6eda6a79e35aca42a7fd4439bd98cdac809b867931c25c8d79ce8968286ed9fdb00d2bad764d01aa419a0eb5c4ca3aeb1e66c99b69f256546cf98bc584
         | 
| 7 | 
            +
              data.tar.gz: 4075b13331760eff6b869bddcc4e095294d99aa930ad322147588a0c049bc08603197ae5d325589a2c3706f0eb7e1451574efc1f190b99ea5c7c21ce596f6682
         | 
    
        data/assets/index.xsl
    CHANGED
    
    | @@ -145,6 +145,7 @@ SOFTWARE. | |
| 145 145 | 
             
                            <xsl:text>issues</xsl:text>
         | 
| 146 146 | 
             
                          </a>
         | 
| 147 147 | 
             
                          <xsl:text>. </xsl:text>
         | 
| 148 | 
            +
                          <xsl:text>"LcP" is an average lifecycle of a pull request in hours. </xsl:text>
         | 
| 148 149 | 
             
                          <xsl:text>"Msgs" is the total number of messages posted in pull requests where the user was a reviewer. </xsl:text>
         | 
| 149 150 | 
             
                          <xsl:text>"Pulls" is the total number of </xsl:text>
         | 
| 150 151 | 
             
                          <a href="https://docs.github.com/en/pull-requests">
         | 
    
        data/bin/cobench
    CHANGED
    
    
| @@ -19,6 +19,7 @@ | |
| 19 19 | 
             
            # SOFTWARE.
         | 
| 20 20 |  | 
| 21 21 | 
             
            require 'iri'
         | 
| 22 | 
            +
            require 'time'
         | 
| 22 23 | 
             
            require_relative '../match'
         | 
| 23 24 |  | 
| 24 25 | 
             
            # Pulls in GitHub API.
         | 
| @@ -39,12 +40,14 @@ class Cobench::Pulls | |
| 39 40 | 
             
                loog.debug("Found #{json.total_count} pull requests")
         | 
| 40 41 | 
             
                hoc = 0
         | 
| 41 42 | 
             
                orgs = []
         | 
| 43 | 
            +
                lcps = []
         | 
| 42 44 | 
             
                total = json.items.count do |p|
         | 
| 43 45 | 
             
                  pr = p.pull_request.url.split('/')[-1]
         | 
| 44 46 | 
             
                  repo = p.repository_url.split('/')[-2..-1].join('/')
         | 
| 45 47 | 
             
                  next unless Cobench::Match.new(@opts, loog).matches?(repo)
         | 
| 46 48 | 
             
                  orgs << p.repository_url.split('/')[-2]
         | 
| 47 49 | 
             
                  pr_json = @api.pull_request(repo, pr)
         | 
| 50 | 
            +
                  lcps << (pr_json[:merged_at] - pr_json[:created_at])
         | 
| 48 51 | 
             
                  hocs = pr_json.additions + pr_json.deletions
         | 
| 49 52 | 
             
                  hoc += hocs
         | 
| 50 53 | 
             
                  loog.debug("Including #{repo}##{pr} with #{hocs}")
         | 
| @@ -60,10 +63,13 @@ class Cobench::Pulls | |
| 60 63 | 
             
                    total: total,
         | 
| 61 64 | 
             
                    href: Iri.new('https://github.com/search').add(q: q)
         | 
| 62 65 | 
             
                  },
         | 
| 66 | 
            +
                  {
         | 
| 67 | 
            +
                    title: 'LcP',
         | 
| 68 | 
            +
                    total: lcps.size.zero? ? 0 : ((lcps.inject(&:+) / lcps.size) / (60 * 60)).to_i
         | 
| 69 | 
            +
                  },
         | 
| 63 70 | 
             
                  {
         | 
| 64 71 | 
             
                    title: 'HoC',
         | 
| 65 | 
            -
                    total: hoc | 
| 66 | 
            -
                    href: ''
         | 
| 72 | 
            +
                    total: hoc
         | 
| 67 73 | 
             
                  }
         | 
| 68 74 | 
             
                ]
         | 
| 69 75 | 
             
              end
         | 
    
        data/lib/cobench/version.rb
    CHANGED
    
    
| @@ -0,0 +1,41 @@ | |
| 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 'minitest/autorun'
         | 
| 22 | 
            +
            require 'octokit'
         | 
| 23 | 
            +
            require 'loog'
         | 
| 24 | 
            +
            require_relative '../../lib/cobench/metrics/pulls'
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            # Test for Pulls.
         | 
| 27 | 
            +
            # Author:: Yegor Bugayenko (yegor256@gmail.com)
         | 
| 28 | 
            +
            # Copyright:: Copyright (c) 2022 Yegor Bugayenko
         | 
| 29 | 
            +
            # License:: MIT
         | 
| 30 | 
            +
            class TestPulls < Minitest::Test
         | 
| 31 | 
            +
              def test_real
         | 
| 32 | 
            +
                api = Octokit::Client.new
         | 
| 33 | 
            +
                m = Cobench::Pulls.new(api, 'yegor256', { days: 5 })
         | 
| 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
         | 
    
        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.43
         | 
| 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-09- | 
| 11 | 
            +
            date: 2022-09-30 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: backtrace
         | 
| @@ -273,6 +273,7 @@ files: | |
| 273 273 | 
             
            - lib/cobench/version.rb
         | 
| 274 274 | 
             
            - logo.svg
         | 
| 275 275 | 
             
            - renovate.json
         | 
| 276 | 
            +
            - test/metrics/test_pulls.rb
         | 
| 276 277 | 
             
            - test/metrics/test_reviews.rb
         | 
| 277 278 | 
             
            - test/test__helper.rb
         | 
| 278 279 | 
             
            - test/test_mask.rb
         |