hub_link 0.18.0 → 0.19.0

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
- SHA1:
3
- metadata.gz: 7393845f06b0f5351385509b348edf549bc06c8e
4
- data.tar.gz: ed93dc3da202c40c1b682fb39b4a4c73e7b197f8
2
+ SHA256:
3
+ metadata.gz: bb5467d077c3a02f7bb755a034997a7df4ead75eedabbad773b5d48725d57446
4
+ data.tar.gz: 1204105a373f2af9a76f37c9beecc0ef9dc30f377b6344d4b831c187fa1eaaec
5
5
  SHA512:
6
- metadata.gz: 26a4378f6e71fed9919d5303df7d32c296ab54bbb849f5e1bd0ee5b87168cc249cf8bfc3e807d97f854a8af9c26b5a5ef7aad3d7e6fcb1001f332b60945468db
7
- data.tar.gz: 26a50ddbdc5a340b5df5e6271d2dd28fbc982d8813950a35fa9d2deb534c93c7eed6e95b6365d964c8eb9c1314e81303ff9f763bf670fafe8846e77e00a3a811
6
+ metadata.gz: fa20791e755f899fdb81f8a9166328779ae2223219de2cdbf1008887d7647494f080e5d9a72e8652762cd1e460ba203f49f07605ff93dde29093b3074a1044d4
7
+ data.tar.gz: 5f42d81a7bc074eb3cccb0970623da01855d2d86624bc193d6039b54198df16ed5342579870c9354efe9d1c70c5107a916be0e8f2c0a07ab74c94e17dedaeb28
data/README.md CHANGED
@@ -17,7 +17,6 @@ Then you can do:
17
17
  stream = HubLink::Stream.new("balvig/hub_link", since: 3.months.ago)
18
18
 
19
19
  stream.in_batches do |batch|
20
- batch.review_requests # => [{ digest: "a45bfa...", reviewer: "balvig", ... }]
21
20
  batch.reviews # => [{ id: 54, reviewer: "balvig", approval: true, ... }]
22
21
  batch.prs # => [{ id: 34, merge_time: 6400, ... }]
23
22
  end
data/hub_link.gemspec CHANGED
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency "faraday_middleware"
24
24
  spec.add_dependency "octokit"
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.12"
27
- spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "bundler", "~> 2.0"
27
+ spec.add_development_dependency "rake", ">= 12.3.3"
28
28
  spec.add_development_dependency "minitest", "~> 5.0"
29
29
  spec.add_development_dependency "pry"
30
30
  end
@@ -0,0 +1,59 @@
1
+ module HubLink
2
+ module Api
3
+ class Issue < SimpleDelegator
4
+ require "hub_link/slicer"
5
+ require "hub_link/api/pull_request"
6
+
7
+ EXPORT_COLUMNS = %i(
8
+ id
9
+ title
10
+ number
11
+ created_at
12
+ updated_at
13
+ closed_at
14
+ submitter
15
+ labels
16
+ repo
17
+ html_url
18
+ state
19
+ )
20
+
21
+ def self.list(repo:, page:, **options)
22
+ Octokit.list_issues(repo, options.merge(page: page, sort: "updated", direction: "asc", state: "all")).map do |item|
23
+ item.repo = repo
24
+ new_from_api(item)
25
+ end
26
+ end
27
+
28
+ def self.new_from_api(item)
29
+ if item.respond_to?(:pull_request)
30
+ PullRequest.new(item)
31
+ else
32
+ Issue.new(item)
33
+ end
34
+ end
35
+
36
+ def pull_request?
37
+ false
38
+ end
39
+
40
+ def submitter
41
+ user.login
42
+ end
43
+
44
+ def labels
45
+ super.map(&:name).join(", ")
46
+ end
47
+
48
+ def to_h
49
+ Slicer.new(self, columns: export_columns).to_h
50
+ end
51
+
52
+ private
53
+
54
+ def export_columns
55
+ EXPORT_COLUMNS
56
+ end
57
+ end
58
+ end
59
+ end
@@ -1,52 +1,24 @@
1
- require "hub_link/api/review"
2
- require "hub_link/api/review_request"
3
- require "hub_link/slicer"
4
-
5
1
  module HubLink
6
2
  module Api
7
- class PullRequest < SimpleDelegator
8
- EXPORT_COLUMNS = %i(
9
- id
10
- title
11
- number
12
- created_at
13
- updated_at
14
- closed_at
3
+ class PullRequest < Issue
4
+ require "hub_link/api/review"
5
+
6
+ ADDITIONAL_EXPORT_COLUMNS = %i(
15
7
  merged_at
16
8
  body_size
17
9
  additions
18
10
  comments_count
19
11
  review_comments_count
20
- submitter
21
- labels
22
- repo
23
- html_url
24
- state
25
12
  )
26
13
 
27
- def self.list(repo:, page:, **options)
28
- Octokit.list_issues(repo, options.merge(page: page, sort: "updated", direction: "asc", state: "all")).map do |item|
29
- item.repo = repo
30
- new(item)
31
- end
32
- end
33
-
34
14
  def pull_request?
35
- respond_to?(:pull_request)
36
- end
37
-
38
- def submitter
39
- user.login
15
+ true
40
16
  end
41
17
 
42
18
  def reviews
43
19
  @_reviews ||= fetch_reviews
44
20
  end
45
21
 
46
- def review_requests
47
- @_review_requests ||= fetch_review_requests
48
- end
49
-
50
22
  def additions
51
23
  extended_data.additions
52
24
  end
@@ -67,26 +39,10 @@ module HubLink
67
39
  extended_data.review_comments
68
40
  end
69
41
 
70
- def labels
71
- super.map(&:name).join(", ")
72
- end
73
-
74
- def to_h
75
- Slicer.new(self, columns: EXPORT_COLUMNS).to_h
76
- end
77
-
78
42
  private
79
43
 
80
- def merged?
81
- merged_at.present?
82
- end
83
-
84
- def fetch_review_requests
85
- requests = Octokit.pull_request_review_requests(repo, number)
86
-
87
- requests.users.compact.map do |reviewer|
88
- ReviewRequest.new(created_at: created_at, reviewer: reviewer.login, requester: submitter, pull_request_id: id)
89
- end
44
+ def export_columns
45
+ super + ADDITIONAL_EXPORT_COLUMNS
90
46
  end
91
47
 
92
48
  def fetch_reviews
@@ -99,14 +55,6 @@ module HubLink
99
55
  end
100
56
  end
101
57
 
102
- def first_approval
103
- reviews.find(&:approval?)
104
- end
105
-
106
- def first_review
107
- reviews.find(&:submitted?)
108
- end
109
-
110
58
  def extended_data
111
59
  @_extended_data ||= Octokit.get(pull_request.url)
112
60
  end
@@ -1,4 +1,4 @@
1
- require "hub_link/api/pull_request"
1
+ require "hub_link/api/issue"
2
2
 
3
3
  module HubLink
4
4
  class Batch
@@ -28,16 +28,16 @@ module HubLink
28
28
  end
29
29
  end
30
30
 
31
- def review_requests
32
- log "Fetching review requests" do
33
- pull_request_results.flat_map(&:review_requests).map(&:to_h)
31
+ def issues
32
+ log "Fetching issues" do
33
+ (results - pull_request_results).map(&:to_h)
34
34
  end
35
35
  end
36
36
 
37
37
  private
38
38
 
39
39
  def pull_request_results
40
- results.find_all(&:pull_request?)
40
+ @_pull_request_results ||= results.find_all(&:pull_request?)
41
41
  end
42
42
 
43
43
  def results
@@ -45,8 +45,8 @@ module HubLink
45
45
  end
46
46
 
47
47
  def fetch_results
48
- log "*Getting issues* #{formatted_options}" do
49
- Api::PullRequest.list(options)
48
+ log "*Querying issues* #{formatted_options}" do
49
+ Api::Issue.list(**options)
50
50
  end
51
51
  end
52
52
 
@@ -1,3 +1,3 @@
1
1
  module HubLink
2
- VERSION = "0.18.0"
2
+ VERSION = "0.19.0"
3
3
  end
data/lib/hub_link.rb CHANGED
@@ -12,7 +12,9 @@ module HubLink
12
12
  class << self
13
13
  attr_accessor :config
14
14
 
15
- delegate :logger, to: :config
15
+ def logger
16
+ config.logger
17
+ end
16
18
  end
17
19
 
18
20
  self.config = Configuration.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hub_link
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Balvig
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-10 00:00:00.000000000 Z
11
+ date: 2023-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.12'
75
+ version: '2.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.12'
82
+ version: '2.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '10.0'
89
+ version: 12.3.3
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '10.0'
96
+ version: 12.3.3
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: minitest
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- description:
125
+ description:
126
126
  email:
127
127
  - jens@balvig.com
128
128
  executables: []
@@ -140,11 +140,10 @@ files:
140
140
  - bin/setup
141
141
  - hub_link.gemspec
142
142
  - lib/hub_link.rb
143
+ - lib/hub_link/api/issue.rb
143
144
  - lib/hub_link/api/logging.rb
144
145
  - lib/hub_link/api/pull_request.rb
145
146
  - lib/hub_link/api/review.rb
146
- - lib/hub_link/api/review_request.rb
147
- - lib/hub_link/api_logging.rb
148
147
  - lib/hub_link/batch.rb
149
148
  - lib/hub_link/configuration.rb
150
149
  - lib/hub_link/importer.rb
@@ -158,7 +157,7 @@ homepage: https://github.com/balvig/hub_link
158
157
  licenses:
159
158
  - MIT
160
159
  metadata: {}
161
- post_install_message:
160
+ post_install_message:
162
161
  rdoc_options: []
163
162
  require_paths:
164
163
  - lib
@@ -173,9 +172,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
172
  - !ruby/object:Gem::Version
174
173
  version: '0'
175
174
  requirements: []
176
- rubyforge_project:
177
- rubygems_version: 2.6.14.3
178
- signing_key:
175
+ rubygems_version: 3.2.3
176
+ signing_key:
179
177
  specification_version: 4
180
178
  summary: Fetch raw data from GitHub for metrics
181
179
  test_files: []
@@ -1,31 +0,0 @@
1
- module HubLink
2
- module Api
3
- class ReviewRequest
4
- require "digest/sha1"
5
-
6
- attr_reader :reviewer, :requester, :created_at, :pull_request_id
7
-
8
- def initialize(reviewer:, requester:, created_at:, pull_request_id:)
9
- @reviewer = reviewer
10
- @requester = requester
11
- @created_at = created_at
12
- @pull_request_id = pull_request_id
13
- end
14
-
15
- # API doesn't return IDs for review requests https://developer.github.com/v3/pulls/review_requests/#list-review-requests
16
- def digest
17
- Digest::SHA1.hexdigest(digest_components.join)
18
- end
19
-
20
- def to_h
21
- Slicer.new(self, columns: %i(digest reviewer requester created_at pull_request_id)).to_h
22
- end
23
-
24
- private
25
-
26
- def digest_components
27
- [pull_request_id, reviewer]
28
- end
29
- end
30
- end
31
- end
@@ -1,15 +0,0 @@
1
- module HubLink
2
- class ApiLogging < Faraday::Response::Middleware
3
- def call(env)
4
- message = "#{env[:method].upcase} #{env[:url]}".sub("https://api.github.com/repos", "")
5
- logger.info(UPDATE) { message }
6
- super
7
- end
8
-
9
- private
10
-
11
- def logger
12
- HubLink.logger
13
- end
14
- end
15
- end