nya_pr 0.5.0 → 0.7.0
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/lib/nya_pr/config/builder.rb +19 -56
- data/lib/nya_pr/config/defaults.rb +2 -5
- data/lib/nya_pr/config/global.rb +1 -14
- data/lib/nya_pr/config/schema.rb +52 -0
- data/lib/nya_pr/pull_request/config.rb +4 -2
- data/lib/nya_pr/pull_request/finder.rb +46 -13
- data/lib/nya_pr/repository/collector.rb +1 -1
- data/lib/nya_pr/repository/filter.rb +8 -4
- data/lib/nya_pr/version.rb +1 -1
- data/lib/nya_pr.rb +1 -0
- metadata +193 -145
- data/lib/nya_pr/progress.rb +0 -124
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6db49c61ff9da807f8b397d15bb5dfd9b368af404a9e01120243bd752d4a1062
|
|
4
|
+
data.tar.gz: 3e64e2f852690f03f666884e33a06d6dd99b7848a0c4fe62883d0aa650265348
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d83f3b8996fb8b79f43c9890c3b12e8d9121e2400c7e316d09667817a578b7f6235340919cffa59d4dd3bd206a5060fbe098948df085aac40debbd02b68bded9
|
|
7
|
+
data.tar.gz: 5476ec4da7d3d7bd3f7e475440d6bab66d9349176bd882ddc58465ce972d6f150acec8293d682fb730be994349cffb5bb2ed6e28078780640f5dc7fb7932a010
|
|
@@ -11,14 +11,6 @@ module NyaPr
|
|
|
11
11
|
'fatal' => Logger::FATAL
|
|
12
12
|
}.freeze
|
|
13
13
|
|
|
14
|
-
BOOLEAN_KEYS = %i[
|
|
15
|
-
refresh
|
|
16
|
-
skip_archived
|
|
17
|
-
skip_drafts
|
|
18
|
-
progress
|
|
19
|
-
save_pull_requests
|
|
20
|
-
].freeze
|
|
21
|
-
|
|
22
14
|
def self.build(options, file_options: {})
|
|
23
15
|
new(options, file_options).build
|
|
24
16
|
end
|
|
@@ -29,15 +21,19 @@ module NyaPr
|
|
|
29
21
|
end
|
|
30
22
|
|
|
31
23
|
def build
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Global.new(
|
|
35
|
-
**normalize(
|
|
24
|
+
result = Schema.call(
|
|
25
|
+
normalize(
|
|
36
26
|
Defaults::OPTIONS.
|
|
37
27
|
merge(file_options).
|
|
38
28
|
merge(options.compact)
|
|
39
29
|
)
|
|
40
30
|
)
|
|
31
|
+
|
|
32
|
+
raise_config_error!(result) unless result.success?
|
|
33
|
+
|
|
34
|
+
Global.new(
|
|
35
|
+
**result.to_h, log_level: LOG_LEVELS.fetch(result[:log_level])
|
|
36
|
+
)
|
|
41
37
|
end
|
|
42
38
|
|
|
43
39
|
private
|
|
@@ -50,20 +46,12 @@ module NyaPr
|
|
|
50
46
|
owners: normalize_list(attributes[:owners]),
|
|
51
47
|
exclude_repositories: normalize_repositories(
|
|
52
48
|
attributes[:exclude_repositories]
|
|
53
|
-
)
|
|
54
|
-
limit: normalize_positive_integer(attributes[:limit], :limit),
|
|
55
|
-
workers: normalize_positive_integer(attributes[:workers], :workers),
|
|
56
|
-
log_level: normalize_log_level(attributes[:log_level]),
|
|
57
|
-
**normalize_booleans(attributes)
|
|
49
|
+
)
|
|
58
50
|
)
|
|
59
51
|
end
|
|
60
52
|
|
|
61
53
|
def normalize_username(value)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return username unless username.empty?
|
|
65
|
-
|
|
66
|
-
raise NyaPr::Error, 'GitHub username is required'
|
|
54
|
+
value&.to_s&.strip
|
|
67
55
|
end
|
|
68
56
|
|
|
69
57
|
def normalize_list(values)
|
|
@@ -79,41 +67,16 @@ module NyaPr
|
|
|
79
67
|
uniq
|
|
80
68
|
end
|
|
81
69
|
|
|
82
|
-
def
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return number if number.positive?
|
|
92
|
-
|
|
93
|
-
raise NyaPr::Error, "#{name} must be greater than 0"
|
|
94
|
-
rescue ArgumentError, TypeError
|
|
95
|
-
raise NyaPr::Error, "#{name} must be a positive integer"
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def normalize_boolean(value, name)
|
|
99
|
-
return value if [true, false].include?(value)
|
|
100
|
-
|
|
101
|
-
raise NyaPr::Error, "#{name} must be true or false"
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def normalize_log_level(value)
|
|
105
|
-
LOG_LEVELS.fetch(value.to_s) do
|
|
106
|
-
raise NyaPr::Error, "Invalid log level: #{value}"
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def validate_keys!
|
|
111
|
-
unknown = file_options.keys - Global.members
|
|
112
|
-
|
|
113
|
-
return if unknown.empty?
|
|
70
|
+
def raise_config_error!(result)
|
|
71
|
+
message = result.errors.to_h.
|
|
72
|
+
flat_map do |key, messages|
|
|
73
|
+
Array(messages).map do |error|
|
|
74
|
+
"#{key} #{error}"
|
|
75
|
+
end
|
|
76
|
+
end.
|
|
77
|
+
join(', ')
|
|
114
78
|
|
|
115
|
-
raise NyaPr::Error,
|
|
116
|
-
"Unknown config option(s): #{unknown.join(', ')}"
|
|
79
|
+
raise NyaPr::Error, message
|
|
117
80
|
end
|
|
118
81
|
end
|
|
119
82
|
end
|
|
@@ -3,15 +3,12 @@
|
|
|
3
3
|
module NyaPr
|
|
4
4
|
module Config
|
|
5
5
|
module Defaults
|
|
6
|
-
LIMIT = 100
|
|
7
|
-
WORKERS = 10
|
|
8
|
-
|
|
9
6
|
OPTIONS = {
|
|
10
7
|
owners: [],
|
|
11
8
|
token: nil,
|
|
12
9
|
repositories_csv: nil,
|
|
13
10
|
pull_requests_dir: nil,
|
|
14
|
-
limit:
|
|
11
|
+
limit: 100,
|
|
15
12
|
refresh: false,
|
|
16
13
|
skip_archived: false,
|
|
17
14
|
skip_drafts: false,
|
|
@@ -19,7 +16,7 @@ module NyaPr
|
|
|
19
16
|
save_pull_requests: true,
|
|
20
17
|
progress: true,
|
|
21
18
|
log_level: 'info',
|
|
22
|
-
workers:
|
|
19
|
+
workers: 30
|
|
23
20
|
}.freeze
|
|
24
21
|
end
|
|
25
22
|
end
|
data/lib/nya_pr/config/global.rb
CHANGED
|
@@ -3,20 +3,7 @@
|
|
|
3
3
|
module NyaPr
|
|
4
4
|
module Config
|
|
5
5
|
Global = Data.define(
|
|
6
|
-
|
|
7
|
-
:owners,
|
|
8
|
-
:token,
|
|
9
|
-
:repositories_csv,
|
|
10
|
-
:pull_requests_dir,
|
|
11
|
-
:limit,
|
|
12
|
-
:refresh,
|
|
13
|
-
:skip_archived,
|
|
14
|
-
:skip_drafts,
|
|
15
|
-
:exclude_repositories,
|
|
16
|
-
:save_pull_requests,
|
|
17
|
-
:progress,
|
|
18
|
-
:log_level,
|
|
19
|
-
:workers
|
|
6
|
+
*Schema.key_map.dump
|
|
20
7
|
)
|
|
21
8
|
end
|
|
22
9
|
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'dry/schema'
|
|
4
|
+
|
|
5
|
+
module NyaPr
|
|
6
|
+
module Config
|
|
7
|
+
STRICT_BOOL = Dry::Types['strict.bool']
|
|
8
|
+
|
|
9
|
+
private_constant :STRICT_BOOL
|
|
10
|
+
|
|
11
|
+
Schema = Dry::Schema.Params do
|
|
12
|
+
config.validate_keys = true
|
|
13
|
+
|
|
14
|
+
required(:username).filled(:string)
|
|
15
|
+
|
|
16
|
+
required(:owners).array(:string)
|
|
17
|
+
|
|
18
|
+
required(:token).maybe(:string)
|
|
19
|
+
required(:repositories_csv).maybe(:string)
|
|
20
|
+
required(:pull_requests_dir).maybe(:string)
|
|
21
|
+
|
|
22
|
+
required(:limit).filled(
|
|
23
|
+
:integer,
|
|
24
|
+
gt?: 0
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
required(:workers).filled(
|
|
28
|
+
:integer,
|
|
29
|
+
gt?: 0
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
required(:refresh).value(STRICT_BOOL)
|
|
33
|
+
required(:skip_archived).value(STRICT_BOOL)
|
|
34
|
+
required(:skip_drafts).value(STRICT_BOOL)
|
|
35
|
+
required(:save_pull_requests).value(STRICT_BOOL)
|
|
36
|
+
required(:progress).value(STRICT_BOOL)
|
|
37
|
+
|
|
38
|
+
required(:exclude_repositories).array(:string)
|
|
39
|
+
|
|
40
|
+
required(:log_level).filled(
|
|
41
|
+
:string,
|
|
42
|
+
included_in?: %w[
|
|
43
|
+
debug
|
|
44
|
+
info
|
|
45
|
+
warn
|
|
46
|
+
error
|
|
47
|
+
fatal
|
|
48
|
+
]
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -6,14 +6,16 @@ module NyaPr
|
|
|
6
6
|
:limit,
|
|
7
7
|
:skip_drafts,
|
|
8
8
|
:progress_enabled,
|
|
9
|
-
:pull_requests_dir
|
|
9
|
+
:pull_requests_dir,
|
|
10
|
+
:workers
|
|
10
11
|
) do
|
|
11
12
|
def self.from_app(config)
|
|
12
13
|
new(
|
|
13
14
|
limit: config.limit,
|
|
14
15
|
skip_drafts: config.skip_drafts,
|
|
15
16
|
progress_enabled: config.progress,
|
|
16
|
-
pull_requests_dir: config.pull_requests_dir
|
|
17
|
+
pull_requests_dir: config.pull_requests_dir,
|
|
18
|
+
workers: config.workers
|
|
17
19
|
)
|
|
18
20
|
end
|
|
19
21
|
end
|
|
@@ -44,27 +44,56 @@ module NyaPr
|
|
|
44
44
|
def collect_pull_requests(repositories, progress_bar)
|
|
45
45
|
pull_requests = []
|
|
46
46
|
|
|
47
|
-
repositories.
|
|
48
|
-
|
|
47
|
+
repositories.each_slice(config.workers) do |repositories_batch|
|
|
48
|
+
remaining = config.limit - pull_requests.size
|
|
49
|
+
break unless remaining.positive?
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
results = process_batch(
|
|
52
|
+
repositories_batch,
|
|
53
|
+
remaining,
|
|
53
54
|
progress_bar
|
|
54
55
|
)
|
|
56
|
+
|
|
57
|
+
append_results(
|
|
58
|
+
pull_requests,
|
|
59
|
+
results
|
|
60
|
+
)
|
|
55
61
|
end
|
|
56
62
|
|
|
57
63
|
pull_requests
|
|
58
64
|
end
|
|
59
65
|
|
|
60
|
-
def
|
|
61
|
-
|
|
66
|
+
def process_batch(repositories, limit, progress_bar)
|
|
67
|
+
threads = repositories.map do |repository|
|
|
68
|
+
Thread.new do
|
|
69
|
+
Thread.current.report_on_exception = false
|
|
70
|
+
|
|
71
|
+
process_repository(
|
|
72
|
+
repository,
|
|
73
|
+
limit,
|
|
74
|
+
progress_bar
|
|
75
|
+
)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
62
78
|
|
|
63
|
-
|
|
79
|
+
threads.map(&:value)
|
|
80
|
+
end
|
|
64
81
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
82
|
+
def append_results(pull_requests, results)
|
|
83
|
+
results.each do |repository_pull_requests|
|
|
84
|
+
remaining = config.limit - pull_requests.size
|
|
85
|
+
break unless remaining.positive?
|
|
86
|
+
|
|
87
|
+
pull_requests.concat(
|
|
88
|
+
repository_pull_requests.first(remaining)
|
|
89
|
+
)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def process_repository(repository, limit, progress_bar)
|
|
94
|
+
return [] unless pull_requests_enabled?(repository)
|
|
95
|
+
|
|
96
|
+
pull_requests_for(repository, limit)
|
|
68
97
|
ensure
|
|
69
98
|
progress_bar.advance
|
|
70
99
|
end
|
|
@@ -137,10 +166,14 @@ module NyaPr
|
|
|
137
166
|
end
|
|
138
167
|
|
|
139
168
|
def build_progress(total)
|
|
140
|
-
|
|
169
|
+
KawaiiProgress::Bar.new(
|
|
141
170
|
'🐾 Checking pull requests',
|
|
142
171
|
total: total,
|
|
143
|
-
enabled: config.progress_enabled && $stderr.tty
|
|
172
|
+
enabled: config.progress_enabled && $stderr.tty?,
|
|
173
|
+
width: 20,
|
|
174
|
+
filled: '♥',
|
|
175
|
+
empty: '♡',
|
|
176
|
+
format: '%{title} [%{bar}] %{current}/%{total} %{percentage}%% | ETA %{eta}'
|
|
144
177
|
)
|
|
145
178
|
end
|
|
146
179
|
|
|
@@ -40,16 +40,20 @@ module NyaPr
|
|
|
40
40
|
|
|
41
41
|
def log_start(repositories)
|
|
42
42
|
NyaPr.logger.info(
|
|
43
|
-
"Checking contributions in #{repositories.size} repositories " \
|
|
43
|
+
"Checking contributions in #{repositories.size} external repositories " \
|
|
44
44
|
"using #{workers} workers"
|
|
45
45
|
)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def build_progress(repositories)
|
|
49
|
-
|
|
49
|
+
KawaiiProgress::Bar.new(
|
|
50
50
|
'🐈 Checking repositories',
|
|
51
51
|
total: repositories.size,
|
|
52
|
-
enabled: progress_enabled && $stderr.tty
|
|
52
|
+
enabled: progress_enabled && $stderr.tty?,
|
|
53
|
+
width: 20,
|
|
54
|
+
filled: '━',
|
|
55
|
+
empty: '─',
|
|
56
|
+
format: '%{title} [%{bar}] %{current}/%{total} %{percentage}%% | ETA %{eta}'
|
|
53
57
|
)
|
|
54
58
|
end
|
|
55
59
|
|
|
@@ -75,7 +79,7 @@ module NyaPr
|
|
|
75
79
|
|
|
76
80
|
def log_result(result)
|
|
77
81
|
NyaPr.logger.info(
|
|
78
|
-
"Finished contribution check: #{result.size} repositories
|
|
82
|
+
"Finished contribution check: contributions found in #{result.size} repositories"
|
|
79
83
|
)
|
|
80
84
|
end
|
|
81
85
|
|
data/lib/nya_pr/version.rb
CHANGED
data/lib/nya_pr.rb
CHANGED
metadata
CHANGED
|
@@ -1,174 +1,222 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nya_pr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Elijah S. Krukowski
|
|
7
|
+
- Elijah S. Krukowski
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
-
- !ruby/object:Gem::Dependency
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- !ruby/object:Gem::
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
- !ruby/object:Gem::
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: csv
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
-
|
|
17
|
+
- ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: "3.3"
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
-
|
|
25
|
+
- ~>
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: "3.3"
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: dotenv
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
-
|
|
33
|
+
- ~>
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: "3.2"
|
|
36
|
+
type: :runtime
|
|
37
|
+
prerelease: false
|
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
-
|
|
41
|
+
- ~>
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: "3.2"
|
|
44
|
+
- !ruby/object:Gem::Dependency
|
|
45
|
+
name: dry-cli
|
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
-
|
|
49
|
+
- ~>
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: "1.4"
|
|
52
|
+
type: :runtime
|
|
53
|
+
prerelease: false
|
|
54
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
-
|
|
57
|
+
- ~>
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: "1.4"
|
|
60
|
+
- !ruby/object:Gem::Dependency
|
|
61
|
+
name: dry-schema
|
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
-
|
|
65
|
+
- ~>
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: "1.16"
|
|
68
|
+
type: :runtime
|
|
69
|
+
prerelease: false
|
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
-
|
|
73
|
+
- ~>
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: "1.16"
|
|
76
|
+
- !ruby/object:Gem::Dependency
|
|
77
|
+
name: faraday
|
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
-
|
|
81
|
+
- ~>
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: "2.14"
|
|
84
|
+
type: :runtime
|
|
85
|
+
prerelease: false
|
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
-
|
|
89
|
+
- ~>
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: "2.14"
|
|
92
|
+
- !ruby/object:Gem::Dependency
|
|
93
|
+
name: faraday-gzip
|
|
94
|
+
requirement: !ruby/object:Gem::Requirement
|
|
95
|
+
requirements:
|
|
96
|
+
-
|
|
97
|
+
- ~>
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: "3"
|
|
100
|
+
type: :runtime
|
|
101
|
+
prerelease: false
|
|
102
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
103
|
+
requirements:
|
|
104
|
+
-
|
|
105
|
+
- ~>
|
|
106
|
+
- !ruby/object:Gem::Version
|
|
107
|
+
version: "3"
|
|
108
|
+
- !ruby/object:Gem::Dependency
|
|
109
|
+
name: kawaii_progress
|
|
110
|
+
requirement: !ruby/object:Gem::Requirement
|
|
111
|
+
requirements:
|
|
112
|
+
-
|
|
113
|
+
- ~>
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: "0.1"
|
|
116
|
+
type: :runtime
|
|
117
|
+
prerelease: false
|
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
119
|
+
requirements:
|
|
120
|
+
-
|
|
121
|
+
- ~>
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: "0.1"
|
|
124
|
+
- !ruby/object:Gem::Dependency
|
|
125
|
+
name: oj
|
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
-
|
|
129
|
+
- ~>
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: "3.10"
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
-
|
|
137
|
+
- ~>
|
|
138
|
+
- !ruby/object:Gem::Version
|
|
139
|
+
version: "3.10"
|
|
140
|
+
- !ruby/object:Gem::Dependency
|
|
141
|
+
name: zeitwerk
|
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
|
143
|
+
requirements:
|
|
144
|
+
-
|
|
145
|
+
- ~>
|
|
146
|
+
- !ruby/object:Gem::Version
|
|
147
|
+
version: "2.6"
|
|
148
|
+
type: :runtime
|
|
149
|
+
prerelease: false
|
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
151
|
+
requirements:
|
|
152
|
+
-
|
|
153
|
+
- ~>
|
|
154
|
+
- !ruby/object:Gem::Version
|
|
155
|
+
version: "2.6"
|
|
110
156
|
description: |
|
|
111
157
|
NyaPr collects repositories you own or contribute to, finds their open pull
|
|
112
158
|
requests, and puts them together in one place for maximum kawaii.
|
|
113
159
|
email:
|
|
114
|
-
- elskruk@proton.me
|
|
160
|
+
- elskruk@proton.me
|
|
115
161
|
executables:
|
|
116
|
-
- nya-pr
|
|
162
|
+
- nya-pr
|
|
117
163
|
extensions: []
|
|
118
164
|
extra_rdoc_files: []
|
|
119
165
|
files:
|
|
120
|
-
- LICENSE.md
|
|
121
|
-
- README.md
|
|
122
|
-
- exe/nya-pr
|
|
123
|
-
- lib/nya_pr.rb
|
|
124
|
-
- lib/nya_pr/cli/command.rb
|
|
125
|
-
- lib/nya_pr/config/builder.rb
|
|
126
|
-
- lib/nya_pr/config/defaults.rb
|
|
127
|
-
- lib/nya_pr/config/global.rb
|
|
128
|
-
- lib/nya_pr/config/loader.rb
|
|
129
|
-
- lib/nya_pr/
|
|
130
|
-
- lib/nya_pr/
|
|
131
|
-
- lib/nya_pr/github/
|
|
132
|
-
- lib/nya_pr/github/
|
|
133
|
-
- lib/nya_pr/
|
|
134
|
-
- lib/nya_pr/pull_request/config.rb
|
|
135
|
-
- lib/nya_pr/pull_request/csv_store.rb
|
|
136
|
-
- lib/nya_pr/pull_request/filter.rb
|
|
137
|
-
- lib/nya_pr/pull_request/finder.rb
|
|
138
|
-
- lib/nya_pr/pull_request/paths.rb
|
|
139
|
-
- lib/nya_pr/pull_request/printer.rb
|
|
140
|
-
- lib/nya_pr/repository/collector.rb
|
|
141
|
-
- lib/nya_pr/repository/config.rb
|
|
142
|
-
- lib/nya_pr/repository/csv_store.rb
|
|
143
|
-
- lib/nya_pr/repository/filter.rb
|
|
144
|
-
- lib/nya_pr/repository/finder.rb
|
|
145
|
-
- lib/nya_pr/repository/paths.rb
|
|
146
|
-
- lib/nya_pr/runner.rb
|
|
147
|
-
- lib/nya_pr/runner_factory.rb
|
|
148
|
-
- lib/nya_pr/version.rb
|
|
149
|
-
homepage: https://github.com/bodrovis/nya_pr
|
|
166
|
+
- LICENSE.md
|
|
167
|
+
- README.md
|
|
168
|
+
- exe/nya-pr
|
|
169
|
+
- lib/nya_pr.rb
|
|
170
|
+
- lib/nya_pr/cli/command.rb
|
|
171
|
+
- lib/nya_pr/config/builder.rb
|
|
172
|
+
- lib/nya_pr/config/defaults.rb
|
|
173
|
+
- lib/nya_pr/config/global.rb
|
|
174
|
+
- lib/nya_pr/config/loader.rb
|
|
175
|
+
- lib/nya_pr/config/schema.rb
|
|
176
|
+
- lib/nya_pr/error.rb
|
|
177
|
+
- lib/nya_pr/github/client.rb
|
|
178
|
+
- lib/nya_pr/github/connection.rb
|
|
179
|
+
- lib/nya_pr/github/request.rb
|
|
180
|
+
- lib/nya_pr/pull_request/config.rb
|
|
181
|
+
- lib/nya_pr/pull_request/csv_store.rb
|
|
182
|
+
- lib/nya_pr/pull_request/filter.rb
|
|
183
|
+
- lib/nya_pr/pull_request/finder.rb
|
|
184
|
+
- lib/nya_pr/pull_request/paths.rb
|
|
185
|
+
- lib/nya_pr/pull_request/printer.rb
|
|
186
|
+
- lib/nya_pr/repository/collector.rb
|
|
187
|
+
- lib/nya_pr/repository/config.rb
|
|
188
|
+
- lib/nya_pr/repository/csv_store.rb
|
|
189
|
+
- lib/nya_pr/repository/filter.rb
|
|
190
|
+
- lib/nya_pr/repository/finder.rb
|
|
191
|
+
- lib/nya_pr/repository/paths.rb
|
|
192
|
+
- lib/nya_pr/runner.rb
|
|
193
|
+
- lib/nya_pr/runner_factory.rb
|
|
194
|
+
- lib/nya_pr/version.rb
|
|
195
|
+
homepage: "https://github.com/bodrovis/nya_pr"
|
|
150
196
|
licenses:
|
|
151
|
-
- MIT
|
|
197
|
+
- MIT
|
|
152
198
|
metadata:
|
|
153
|
-
rubygems_mfa_required:
|
|
154
|
-
bug_tracker_uri: https://github.com/bodrovis/nya_pr/issues
|
|
155
|
-
documentation_uri: https://github.com/bodrovis/nya_pr/blob/master/README.md
|
|
156
|
-
homepage_uri: https://github.com/bodrovis/nya_pr
|
|
199
|
+
rubygems_mfa_required: "true"
|
|
200
|
+
bug_tracker_uri: "https://github.com/bodrovis/nya_pr/issues"
|
|
201
|
+
documentation_uri: "https://github.com/bodrovis/nya_pr/blob/master/README.md"
|
|
202
|
+
homepage_uri: "https://github.com/bodrovis/nya_pr"
|
|
157
203
|
rdoc_options: []
|
|
158
204
|
require_paths:
|
|
159
|
-
- lib
|
|
205
|
+
- lib
|
|
160
206
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
161
207
|
requirements:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
208
|
+
-
|
|
209
|
+
- ">="
|
|
210
|
+
- !ruby/object:Gem::Version
|
|
211
|
+
version: "4.0"
|
|
165
212
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
213
|
requirements:
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
214
|
+
-
|
|
215
|
+
- ">="
|
|
216
|
+
- !ruby/object:Gem::Version
|
|
217
|
+
version: "0"
|
|
170
218
|
requirements: []
|
|
171
|
-
rubygems_version: 4.
|
|
219
|
+
rubygems_version: 4.1.1
|
|
172
220
|
specification_version: 4
|
|
173
221
|
summary: A tiny kawaii CLI for hunting down GitHub pull requests
|
|
174
222
|
test_files: []
|
data/lib/nya_pr/progress.rb
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module NyaPr
|
|
4
|
-
class Progress
|
|
5
|
-
DEFAULT_WIDTH = 30
|
|
6
|
-
|
|
7
|
-
attr_reader :title, :total, :width, :output
|
|
8
|
-
|
|
9
|
-
def initialize(
|
|
10
|
-
title,
|
|
11
|
-
total:,
|
|
12
|
-
enabled: true,
|
|
13
|
-
width: DEFAULT_WIDTH,
|
|
14
|
-
output: $stderr
|
|
15
|
-
)
|
|
16
|
-
@title = title
|
|
17
|
-
@total = total
|
|
18
|
-
@width = width
|
|
19
|
-
@output = output
|
|
20
|
-
@enabled = enabled
|
|
21
|
-
@current = 0
|
|
22
|
-
|
|
23
|
-
# Use a monotonic clock so elapsed time is not affected by system
|
|
24
|
-
# clock changes while the progress bar is running.
|
|
25
|
-
@started_at = monotonic_time
|
|
26
|
-
|
|
27
|
-
# Progress may be updated by multiple worker threads. The mutex keeps
|
|
28
|
-
# the counter update and terminal rendering atomic relative to each
|
|
29
|
-
# other, preventing lost increments and interleaved output.
|
|
30
|
-
@mutex = Mutex.new
|
|
31
|
-
|
|
32
|
-
render if enabled?
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def advance(step = 1)
|
|
36
|
-
return unless enabled?
|
|
37
|
-
|
|
38
|
-
mutex.synchronize do
|
|
39
|
-
# Never allow the displayed counter to exceed the expected total.
|
|
40
|
-
@current = [@current + step, total].min
|
|
41
|
-
render
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def finish
|
|
46
|
-
return unless enabled?
|
|
47
|
-
|
|
48
|
-
mutex.synchronize do
|
|
49
|
-
# Render the final known state, then move subsequent output
|
|
50
|
-
# to a new terminal line.
|
|
51
|
-
render
|
|
52
|
-
output.puts
|
|
53
|
-
output.flush
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
private
|
|
58
|
-
|
|
59
|
-
attr_reader :current, :started_at, :mutex
|
|
60
|
-
|
|
61
|
-
def enabled?
|
|
62
|
-
# A zero-sized task does not need a progress bar.
|
|
63
|
-
@enabled && total.positive?
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def render
|
|
67
|
-
output.print(
|
|
68
|
-
# Return to the beginning of the line and clear the previous render.
|
|
69
|
-
"\r\e[2K",
|
|
70
|
-
title,
|
|
71
|
-
' [',
|
|
72
|
-
progress_bar,
|
|
73
|
-
'] ',
|
|
74
|
-
"#{current}/#{total} ",
|
|
75
|
-
"#{percentage}% ",
|
|
76
|
-
"ETA #{eta}"
|
|
77
|
-
)
|
|
78
|
-
output.flush
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def progress_bar
|
|
82
|
-
completed = (width * progress).round
|
|
83
|
-
remaining = width - completed
|
|
84
|
-
|
|
85
|
-
('█' * completed) + ('░' * remaining)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def progress
|
|
89
|
-
current.to_f / total
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def percentage
|
|
93
|
-
(progress * 100).round
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def eta
|
|
97
|
-
return '--' if current.zero?
|
|
98
|
-
|
|
99
|
-
elapsed = monotonic_time - started_at
|
|
100
|
-
rate = current / elapsed
|
|
101
|
-
|
|
102
|
-
return '--' unless rate.positive?
|
|
103
|
-
|
|
104
|
-
seconds = ((total - current) / rate).round
|
|
105
|
-
|
|
106
|
-
format_duration(seconds)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def format_duration(seconds)
|
|
110
|
-
return "#{seconds}s" if seconds < 60
|
|
111
|
-
|
|
112
|
-
minutes, seconds = seconds.divmod(60)
|
|
113
|
-
return "#{minutes}m #{seconds.to_s.rjust(2, '0')}s" if minutes < 60
|
|
114
|
-
|
|
115
|
-
hours, minutes = minutes.divmod(60)
|
|
116
|
-
|
|
117
|
-
"#{hours}h #{minutes.to_s.rjust(2, '0')}m"
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def monotonic_time
|
|
121
|
-
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
end
|