bundler-alive 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bundler-alive.default.yml +30 -0
- data/.yardopts +1 -0
- data/README.md +39 -8
- data/gemspec.yml +0 -1
- data/lib/bundler/alive/cli.rb +3 -4
- data/lib/bundler/alive/client/gems_api_client.rb +39 -9
- data/lib/bundler/alive/client/git_hub_api.rb +10 -2
- data/lib/bundler/alive/doctor.rb +22 -45
- data/lib/bundler/alive/report.rb +0 -10
- data/lib/bundler/alive/reportable.rb +21 -9
- data/lib/bundler/alive/source_code_repository.rb +2 -0
- data/lib/bundler/alive/source_code_repository_url.rb +2 -0
- data/lib/bundler/alive/status.rb +1 -2
- data/lib/bundler/alive/status_collection.rb +5 -27
- data/lib/bundler/alive/status_result.rb +2 -0
- data/lib/bundler/alive/version.rb +1 -1
- data/lib/bundler/alive.rb +0 -1
- metadata +4 -17
- data/lib/bundler/alive/announcer.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd88b794101cf7f456811a805f287ec314d9ecf202294f5ec13e5e339db5834d
|
4
|
+
data.tar.gz: e0db2f2731c7dd50324900a5564365ff14abf82bc7169d30d9ad7444504dffec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89fec08047da08d6178bae7e2760f22139005dc33cd38201a6c7782a589ab173a7b5b72ee934bb301216fe4a5e1e5814dd69b773a9c937ab7ca2f7c7b61f0d3a
|
7
|
+
data.tar.gz: 0f1930be94cf0401d807ec1e63714dea3243c5bedbe226ff7cd4ff957e9d6d5f043d731f4903ca3dac35aa0403d1269cbc85e153a304894fad63848401ddec07
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
gems:
|
3
|
+
coffee-script-source:
|
4
|
+
url: https://github.com/jashkenas/coffeescript/
|
5
|
+
erubis:
|
6
|
+
url: https://github.com/kwatch/erubis
|
7
|
+
ffi-compiler:
|
8
|
+
url: https://github.com/ffi/ffi
|
9
|
+
foundation-rails:
|
10
|
+
url: https://github.com/foundation/foundation-rails
|
11
|
+
guard-compat:
|
12
|
+
url: https://github.com/guard/guard-compat
|
13
|
+
spoon:
|
14
|
+
url: https://github.com/headius/spoon
|
15
|
+
shellany:
|
16
|
+
url: https://github.com/guard/shellany
|
17
|
+
vegas:
|
18
|
+
url: https://github.com/quirkey/vegas
|
19
|
+
zipruby:
|
20
|
+
url: https://github.com/fjg/zipruby
|
21
|
+
gli:
|
22
|
+
url: https://github.com/davetron5000/gli
|
23
|
+
zen_to_i:
|
24
|
+
url: https://github.com/yoshitsugu/zen_to_i
|
25
|
+
trailblazer-option:
|
26
|
+
url: https://github.com/trailblazer/trailblazer-option
|
27
|
+
fog-sakuracloud:
|
28
|
+
url: https://github.com/fog/fog-sakuracloud
|
29
|
+
ovirt-engine-sdk:
|
30
|
+
url: https://github.com/oVirt/ovirt-engine-sdk-ruby
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--markup markdown --title "bundler-alive Documentation" --protected
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
`bunder-alive` checks if gems in a RubyGem's `Gemfile.lock` are active.
|
9
9
|
|
10
|
-
Currently only
|
10
|
+
Currently only GitHub is supported as a source code repository. If the source code repository is archived, then reports as not alive.
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
@@ -23,13 +23,15 @@ $ bundle-alive
|
|
23
23
|
..W....
|
24
24
|
Get all source code repository URLs of gems are done!
|
25
25
|
.....
|
26
|
-
Name: journey
|
27
|
-
URL: http://github.com/rails/journey
|
28
|
-
Status: false
|
29
26
|
|
30
|
-
|
27
|
+
Errors:
|
28
|
+
[bundle-alive] Not found in RubyGems.org.
|
31
29
|
|
32
|
-
|
30
|
+
Archived gems:
|
31
|
+
Name: journey
|
32
|
+
URL: http://github.com/rails/journey
|
33
|
+
|
34
|
+
Total: 6 (Archived: 1, Alive: 4, Unknown: 1)
|
33
35
|
Not alive gems are found!
|
34
36
|
```
|
35
37
|
|
@@ -39,7 +41,9 @@ Default `Gemfile.lock` location is in your current directory. You can specify it
|
|
39
41
|
$ bundle-alive -G /path/to/Gemfile.lock
|
40
42
|
```
|
41
43
|
|
42
|
-
|
44
|
+
## Exceeding rate limit
|
45
|
+
|
46
|
+
In some cases, the following error may be output.
|
43
47
|
|
44
48
|
```
|
45
49
|
Too many requested! Retry later.
|
@@ -47,7 +51,34 @@ Too many requested! Retry later.
|
|
47
51
|
|
48
52
|
In this case, setting [GitHub Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) as `BUNDLER_ALIVE_GITHUB_TOKEN` environment variable may alleviate the error.
|
49
53
|
|
50
|
-
|
54
|
+
## Ignore gems
|
55
|
+
|
56
|
+
You can ignore certain gems.
|
57
|
+
|
58
|
+
```
|
59
|
+
$ bundle-alive -i journey rubocop-junit-formatter
|
60
|
+
```
|
61
|
+
|
62
|
+
## Specifying repository URL
|
63
|
+
|
64
|
+
In some cases, some gems cannot find the URL of their source code repositories. For this case, you can specify a mapping between the gem and its URL.
|
65
|
+
|
66
|
+
Put `.bundler-alive.yml` in your current directory. The following code is the sample.
|
67
|
+
|
68
|
+
```yaml
|
69
|
+
---
|
70
|
+
gems:
|
71
|
+
coffee-script-source:
|
72
|
+
url: https://github.com/jashkenas/coffeescript/
|
73
|
+
```
|
74
|
+
|
75
|
+
You can also specify the file path.
|
76
|
+
|
77
|
+
```
|
78
|
+
$ bundle-alive -c /path/to/.bundler-alive.yml
|
79
|
+
```
|
80
|
+
|
81
|
+
[.bundler-alive.default.yml](https://github.com/kyoshidajp/bundler-alive/blob/main/.bundler-alive.default.yml) may also be helpful. Considering that having these mappings obtained automatically in the future.
|
51
82
|
|
52
83
|
## Contributing
|
53
84
|
|
data/gemspec.yml
CHANGED
data/lib/bundler/alive/cli.rb
CHANGED
@@ -16,15 +16,14 @@ module Bundler
|
|
16
16
|
map "--version" => :version
|
17
17
|
|
18
18
|
desc "check [DIR]", "Checks the Gemfile.lock"
|
19
|
+
method_option :ignore, type: :array, aliases: "-i", default: []
|
19
20
|
method_option :gemfile_lock, type: :string, aliases: "-G",
|
20
21
|
default: "Gemfile.lock"
|
21
|
-
method_option :
|
22
|
-
default: "result.toml"
|
22
|
+
method_option :config, type: :string, aliases: "-c", default: ".bundler-alive.yml"
|
23
23
|
|
24
24
|
def check(_dir = Dir.pwd)
|
25
25
|
extend Reportable
|
26
26
|
report = check_by_doctor
|
27
|
-
report.save_as_file(options[:result])
|
28
27
|
print_report(report)
|
29
28
|
|
30
29
|
exit_status = report.result.all_alive? ? 0 : 1
|
@@ -40,7 +39,7 @@ module Bundler
|
|
40
39
|
|
41
40
|
def check_by_doctor
|
42
41
|
doctor = begin
|
43
|
-
Doctor.new(options[:gemfile_lock], options[:
|
42
|
+
Doctor.new(options[:gemfile_lock], options[:config], options[:ignore])
|
44
43
|
rescue Bundler::GemfileLockNotFound
|
45
44
|
exit 1
|
46
45
|
end
|
@@ -18,8 +18,18 @@ module Bundler
|
|
18
18
|
class NotFound < StandardError
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
#
|
22
|
+
# A new instance of `GemApiClient`
|
23
|
+
#
|
24
|
+
# @param [String] config_path
|
25
|
+
#
|
26
|
+
# @return [GemApiClient]
|
27
|
+
#
|
28
|
+
def initialize(config_path = nil)
|
22
29
|
@error_messages = []
|
30
|
+
@config_gems = get_config_gems(config_path)
|
31
|
+
|
32
|
+
freeze
|
23
33
|
end
|
24
34
|
|
25
35
|
#
|
@@ -29,8 +39,8 @@ module Bundler
|
|
29
39
|
#
|
30
40
|
# @return [Client::GemsApiResponse]
|
31
41
|
#
|
32
|
-
def gems_api_response(gem_names
|
33
|
-
urls = service_with_urls(gem_names
|
42
|
+
def gems_api_response(gem_names)
|
43
|
+
urls = service_with_urls(gem_names)
|
34
44
|
$stdout.puts <<~MESSAGE
|
35
45
|
|
36
46
|
Get all source code repository URLs of gems are done!
|
@@ -43,7 +53,7 @@ module Bundler
|
|
43
53
|
|
44
54
|
private
|
45
55
|
|
46
|
-
attr_accessor :error_messages
|
56
|
+
attr_accessor :error_messages, :config_gems
|
47
57
|
|
48
58
|
def api_url(gem_name)
|
49
59
|
"https://rubygems.org/api/v1/gems/#{gem_name}.json"
|
@@ -55,8 +65,15 @@ module Bundler
|
|
55
65
|
end
|
56
66
|
end
|
57
67
|
|
58
|
-
def
|
59
|
-
|
68
|
+
def get_config_gems(path)
|
69
|
+
return {} if path.nil? || !File.exist?(path)
|
70
|
+
|
71
|
+
config = YAML.load_file(path)
|
72
|
+
config["gems"]
|
73
|
+
end
|
74
|
+
|
75
|
+
def service_with_urls(gem_names)
|
76
|
+
urls = get_repository_urls(gem_names)
|
60
77
|
urls.each_with_object({}) do |url, hash|
|
61
78
|
service_name = url.service_name
|
62
79
|
hash[service_name] = Array(hash[service_name]) << url
|
@@ -71,16 +88,27 @@ module Bundler
|
|
71
88
|
# @return [SourceCodeRepositoryUrl]
|
72
89
|
#
|
73
90
|
def get_repository_url(gem_name)
|
91
|
+
url_from_config = get_repository_url_from_config(gem_name)
|
92
|
+
return url_from_config unless url_from_config.nil?
|
93
|
+
|
74
94
|
url = api_url(gem_name)
|
75
95
|
response = connection.get(url)
|
76
96
|
|
77
|
-
raise NotFound, "
|
97
|
+
raise NotFound, "[#{gem_name}] Not found in RubyGems.org." unless response.success?
|
78
98
|
|
79
99
|
body = JSON.parse(response.body)
|
80
100
|
raw_url = source_code_url(body: body, gem_name: gem_name)
|
81
101
|
SourceCodeRepositoryUrl.new(raw_url, gem_name)
|
82
102
|
end
|
83
103
|
|
104
|
+
def get_repository_url_from_config(gem_name)
|
105
|
+
return nil if config_gems.nil?
|
106
|
+
return nil unless config_gems.key?(gem_name)
|
107
|
+
|
108
|
+
gem = config_gems[gem_name]
|
109
|
+
SourceCodeRepositoryUrl.new(gem["url"], gem_name)
|
110
|
+
end
|
111
|
+
|
84
112
|
def source_code_url(body:, gem_name:)
|
85
113
|
url = body["source_code_uri"]
|
86
114
|
return url if SourceCodeRepositoryUrl.support_url?(url)
|
@@ -88,12 +116,14 @@ module Bundler
|
|
88
116
|
url = body["homepage_uri"]
|
89
117
|
return url if SourceCodeRepositoryUrl.support_url?(url)
|
90
118
|
|
91
|
-
|
119
|
+
message = "[#{gem_name}] Source code repository is not found in RubyGems.org,"\
|
120
|
+
" or not supported. URL: https://rubygems.org/gems/#{gem_name}"
|
121
|
+
raise NotFound, message
|
92
122
|
end
|
93
123
|
|
94
124
|
def get_repository_urls(gem_names)
|
95
125
|
result = gem_names.map do |gem_name|
|
96
|
-
|
126
|
+
$stdout.write "."
|
97
127
|
get_repository_url(gem_name)
|
98
128
|
rescue StandardError => e
|
99
129
|
$stdout.write "W"
|
@@ -21,7 +21,15 @@ module Bundler
|
|
21
21
|
# Number of attempts to request after too many requests
|
22
22
|
RETRIES_ON_TOO_MANY_REQUESTS = 3
|
23
23
|
|
24
|
+
#
|
24
25
|
# Interval second when retrying request
|
26
|
+
#
|
27
|
+
# @note
|
28
|
+
# This is an empirical value and should
|
29
|
+
# refer to response of Rate Limit API
|
30
|
+
#
|
31
|
+
# @see
|
32
|
+
# https://docs.github.com/en/rest/overview/resources-in-the-rest-api#checking-your-rate-limit-status
|
25
33
|
RETRY_INTERVAL_SEC_ON_TOO_MANY_REQUESTS = 120
|
26
34
|
|
27
35
|
#
|
@@ -60,7 +68,7 @@ module Bundler
|
|
60
68
|
collection = StatusCollection.new
|
61
69
|
name_with_archived = get_name_with_statuses(urls)
|
62
70
|
urls.each do |url|
|
63
|
-
|
71
|
+
$stdout.write "."
|
64
72
|
|
65
73
|
gem_name = url.gem_name
|
66
74
|
alive = !name_with_archived[gem_name]
|
@@ -151,7 +159,7 @@ module Bundler
|
|
151
159
|
end
|
152
160
|
|
153
161
|
def sleep_with_message
|
154
|
-
puts "Too many requested. Sleep #{RETRY_INTERVAL_SEC_ON_TOO_MANY_REQUESTS} sec."
|
162
|
+
puts "Too many requested to GitHub. Sleep #{RETRY_INTERVAL_SEC_ON_TOO_MANY_REQUESTS} sec."
|
155
163
|
sleep RETRY_INTERVAL_SEC_ON_TOO_MANY_REQUESTS
|
156
164
|
puts "Retry request (#{@retries_on_too_many_requests}/#{RETRIES_ON_TOO_MANY_REQUESTS})"
|
157
165
|
end
|
data/lib/bundler/alive/doctor.rb
CHANGED
@@ -2,32 +2,31 @@
|
|
2
2
|
|
3
3
|
require "bundler"
|
4
4
|
require "octokit"
|
5
|
-
require "toml-rb"
|
6
5
|
|
7
6
|
module Bundler
|
8
7
|
module Alive
|
9
8
|
#
|
10
|
-
# Diagnoses a `Gemfile.lock`
|
9
|
+
# Diagnoses a `Gemfile.lock`
|
11
10
|
#
|
12
11
|
class Doctor
|
13
12
|
#
|
14
13
|
# A new instance of Doctor
|
15
14
|
#
|
16
15
|
# @param [String] lock_file lock file of gem
|
17
|
-
# @param [String]
|
16
|
+
# @param [String] config_file config file
|
17
|
+
# @param [Array<String>] ignore_gems ignore gems
|
18
18
|
#
|
19
|
-
def initialize(lock_file,
|
19
|
+
def initialize(lock_file, config_file, ignore_gems)
|
20
20
|
@lock_file = lock_file
|
21
|
-
@
|
22
|
-
@
|
21
|
+
@gem_client = Client::GemsApiClient.new(config_file)
|
22
|
+
@ignore_gems = ignore_gems
|
23
23
|
@result = nil
|
24
24
|
@rate_limit_exceeded = false
|
25
|
-
@announcer = Announcer.new
|
26
25
|
@error_messages = []
|
27
26
|
end
|
28
27
|
|
29
28
|
#
|
30
|
-
# Diagnoses gems in lock
|
29
|
+
# Diagnoses gems in Gemfile.lock
|
31
30
|
#
|
32
31
|
# @raise [Client::SourceCodeClient::RateLimitExceededError]
|
33
32
|
# When exceeded access rate limit
|
@@ -38,41 +37,27 @@ module Bundler
|
|
38
37
|
# @return [Report]
|
39
38
|
#
|
40
39
|
def diagnose
|
41
|
-
|
40
|
+
message = "#{collection_from_gemfile.total_size + ignore_gems.size} gems are in Gemfile.lock"
|
41
|
+
message = "#{message} (#{ignore_gems.size} gems are ignored)" if ignore_gems.size.positive?
|
42
|
+
$stdout.puts message
|
43
|
+
|
42
44
|
result = _diagnose
|
43
45
|
Report.new(result)
|
44
46
|
end
|
45
47
|
|
46
48
|
private
|
47
49
|
|
48
|
-
attr_reader :lock_file, :
|
50
|
+
attr_reader :lock_file, :gem_client, :ignore_gems,
|
49
51
|
:result, :error_messages, :rate_limit_exceeded
|
50
52
|
|
51
|
-
#
|
52
|
-
# @return [Array<String>]
|
53
|
-
#
|
54
|
-
def no_need_to_get_gems
|
55
|
-
return [] unless File.exist?(result_file)
|
56
|
-
|
57
|
-
toml_hash = TomlRB.load_file(result_file)
|
58
|
-
toml_hash.each_with_object([]) do |(gem_name, v), array|
|
59
|
-
alive = v["alive"]
|
60
|
-
array << gem_name unless alive
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
53
|
def diagnose_by_service(service, urls)
|
65
54
|
client = Client::SourceCodeClient.new(service_name: service)
|
66
|
-
client.query(urls: urls)
|
67
|
-
announcer.announce
|
68
|
-
end
|
55
|
+
client.query(urls: urls)
|
69
56
|
end
|
70
57
|
|
58
|
+
# @return [StatusResult]
|
71
59
|
def result_by_search(collection)
|
72
|
-
gems_api_response = gem_client.gems_api_response(collection.names)
|
73
|
-
announcer.announce
|
74
|
-
end
|
75
|
-
|
60
|
+
gems_api_response = gem_client.gems_api_response(collection.names)
|
76
61
|
service_with_urls = gems_api_response.service_with_urls
|
77
62
|
error_messages.concat(gems_api_response.error_messages)
|
78
63
|
|
@@ -83,19 +68,12 @@ module Bundler
|
|
83
68
|
result
|
84
69
|
end
|
85
70
|
|
86
|
-
|
87
|
-
collection = StatusCollection.new
|
88
|
-
base_collection.each do |name, status|
|
89
|
-
next if gem_names.include?(name)
|
90
|
-
|
91
|
-
collection = collection.add(name, status)
|
92
|
-
end
|
93
|
-
collection
|
94
|
-
end
|
95
|
-
|
71
|
+
# @return [StatusCollection]
|
96
72
|
def collection_from_gemfile
|
97
73
|
gems_from_lockfile.each_with_object(StatusCollection.new) do |gem, collection|
|
98
74
|
gem_name = gem.name
|
75
|
+
next if ignore_gems.include?(gem_name)
|
76
|
+
|
99
77
|
status = Status.new(name: gem_name,
|
100
78
|
repository_url: nil,
|
101
79
|
alive: nil,
|
@@ -104,14 +82,13 @@ module Bundler
|
|
104
82
|
end
|
105
83
|
end
|
106
84
|
|
85
|
+
# @return [StatusResult]
|
107
86
|
def _diagnose
|
108
|
-
collection =
|
87
|
+
collection = collection_from_gemfile
|
109
88
|
result = result_by_search(collection)
|
110
|
-
|
111
|
-
new_collection = collection_from_gemfile.merge(collection_from_toml_file)
|
112
|
-
.merge(result.collection)
|
113
|
-
|
89
|
+
new_collection = collection.merge(result.collection)
|
114
90
|
messages = error_messages.concat(result.error_messages)
|
91
|
+
|
115
92
|
StatusResult.new(collection: new_collection,
|
116
93
|
error_messages: messages,
|
117
94
|
rate_limit_exceeded: result.rate_limit_exceeded)
|
data/lib/bundler/alive/report.rb
CHANGED
@@ -21,11 +21,8 @@ module Bundler
|
|
21
21
|
error_messages = report.error_messages
|
22
22
|
print_error(error_messages)
|
23
23
|
|
24
|
-
gems = result.
|
25
|
-
|
26
|
-
gems.each do |_name, gem|
|
27
|
-
$stdout.puts gem.report
|
28
|
-
end
|
24
|
+
gems = result.archived_gems
|
25
|
+
print_archived_gems(gems) if gems.size.positive?
|
29
26
|
|
30
27
|
print_summary(result)
|
31
28
|
print_message(result, report.rate_limit_exceeded)
|
@@ -33,18 +30,33 @@ module Bundler
|
|
33
30
|
|
34
31
|
private
|
35
32
|
|
33
|
+
# soo messy
|
34
|
+
def print_archived_gems(gems)
|
35
|
+
$stdout.puts
|
36
|
+
$stdout.puts "Archived gems:"
|
37
|
+
archived_gems = gems.map do |_name, gem|
|
38
|
+
gem.report.split("\n").each_with_object([]) do |line, gem_str|
|
39
|
+
gem_str << " #{line}"
|
40
|
+
end.join("\n")
|
41
|
+
end
|
42
|
+
$stdout.puts archived_gems.join("\n\n")
|
43
|
+
end
|
44
|
+
|
36
45
|
def print_error(error_messages)
|
37
|
-
return if error_messages.
|
46
|
+
return if error_messages.empty?
|
38
47
|
|
39
48
|
$stdout.puts <<~ERROR
|
40
49
|
|
41
|
-
|
50
|
+
|
51
|
+
Errors:
|
52
|
+
#{error_messages.join("\n ")}
|
42
53
|
ERROR
|
43
54
|
end
|
44
55
|
|
45
56
|
def print_summary(result)
|
46
57
|
$stdout.puts <<~RESULT
|
47
|
-
|
58
|
+
|
59
|
+
Total: #{result.total_size} (Archived: #{result.archived_size}, Alive: #{result.alive_size}, Unknown: #{result.unknown_size})
|
48
60
|
RESULT
|
49
61
|
end
|
50
62
|
|
@@ -55,7 +67,7 @@ module Bundler
|
|
55
67
|
end
|
56
68
|
|
57
69
|
say "Too many requested! Retry later.", :yellow if rate_limit_exceeded
|
58
|
-
if result.
|
70
|
+
if result.archived_size.positive?
|
59
71
|
say "Not alive gems are found!", :red
|
60
72
|
return
|
61
73
|
end
|
data/lib/bundler/alive/status.rb
CHANGED
@@ -20,7 +20,7 @@ module Bundler
|
|
20
20
|
# @param [String] :name
|
21
21
|
# @param [SourceCodeRepositoryUrl] :repository_url
|
22
22
|
# @param [Boolean] :alive
|
23
|
-
# @param [] :checked_at
|
23
|
+
# @param [Time] :checked_at
|
24
24
|
#
|
25
25
|
# @return [Status]
|
26
26
|
#
|
@@ -67,7 +67,6 @@ module Bundler
|
|
67
67
|
<<~REPORT
|
68
68
|
Name: #{name}
|
69
69
|
URL: #{decorated_repository_url}
|
70
|
-
Status: #{decorated_alive}
|
71
70
|
|
72
71
|
REPORT
|
73
72
|
end
|
@@ -10,30 +10,7 @@ module Bundler
|
|
10
10
|
delegate each: :collection
|
11
11
|
delegate values: :collection
|
12
12
|
|
13
|
-
attr_reader :alive_size, :
|
14
|
-
|
15
|
-
#
|
16
|
-
# Creates `StatusCollection` from TOML file
|
17
|
-
#
|
18
|
-
# @param [String] path
|
19
|
-
#
|
20
|
-
# @return [StatusCollection]
|
21
|
-
#
|
22
|
-
def self.new_from_toml_file(path)
|
23
|
-
return new unless File.exist?(path)
|
24
|
-
|
25
|
-
collection = new
|
26
|
-
TomlRB.load_file(path).each do |name, v|
|
27
|
-
next if v["alive"] == Status::ALIVE_UNKNOWN
|
28
|
-
|
29
|
-
url = SourceCodeRepositoryUrl.new(v["repository_url"], name)
|
30
|
-
status = Status.new(name: name, repository_url: url,
|
31
|
-
alive: v["alive"], checked_at: v["checked_at"])
|
32
|
-
collection = collection.add(name, status)
|
33
|
-
end
|
34
|
-
|
35
|
-
collection
|
36
|
-
end
|
13
|
+
attr_reader :alive_size, :archived_size, :unknown_size
|
37
14
|
|
38
15
|
#
|
39
16
|
# Generates instance of `StatusCollection`
|
@@ -48,7 +25,8 @@ module Bundler
|
|
48
25
|
|
49
26
|
@alive_size = _alive_size
|
50
27
|
@unknown_size = _unknown_size
|
51
|
-
@
|
28
|
+
@archived_size = _archived_size
|
29
|
+
|
52
30
|
freeze
|
53
31
|
end
|
54
32
|
|
@@ -107,7 +85,7 @@ module Bundler
|
|
107
85
|
collection.transform_values(&:to_h)
|
108
86
|
end
|
109
87
|
|
110
|
-
def
|
88
|
+
def archived_gems
|
111
89
|
collection.find_all { |_name, gem| !!!gem.alive }
|
112
90
|
end
|
113
91
|
|
@@ -137,7 +115,7 @@ module Bundler
|
|
137
115
|
statuses_values.count { |gem| !!gem.alive && !gem.unknown? }
|
138
116
|
end
|
139
117
|
|
140
|
-
def
|
118
|
+
def _archived_size
|
141
119
|
statuses_values.count { |gem| !gem.alive && !gem.unknown? }
|
142
120
|
end
|
143
121
|
|
data/lib/bundler/alive.rb
CHANGED
@@ -7,7 +7,6 @@ require_relative "alive/source_code_repository_url"
|
|
7
7
|
require_relative "alive/status"
|
8
8
|
require_relative "alive/status_result"
|
9
9
|
require_relative "alive/status_collection"
|
10
|
-
require_relative "alive/announcer"
|
11
10
|
require_relative "alive/report"
|
12
11
|
require_relative "alive/client/gems_api_client"
|
13
12
|
require_relative "alive/client/gems_api_response"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bundler-alive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katsuhiko YOSHIDA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: toml-rb
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: rspec
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,8 +178,10 @@ executables:
|
|
192
178
|
extensions: []
|
193
179
|
extra_rdoc_files: []
|
194
180
|
files:
|
181
|
+
- ".bundler-alive.default.yml"
|
195
182
|
- ".rspec"
|
196
183
|
- ".rubocop.yml"
|
184
|
+
- ".yardopts"
|
197
185
|
- Gemfile
|
198
186
|
- LICENSE
|
199
187
|
- README.md
|
@@ -203,7 +191,6 @@ files:
|
|
203
191
|
- bundler-alive.gemspec
|
204
192
|
- gemspec.yml
|
205
193
|
- lib/bundler/alive.rb
|
206
|
-
- lib/bundler/alive/announcer.rb
|
207
194
|
- lib/bundler/alive/cli.rb
|
208
195
|
- lib/bundler/alive/client/gems_api_client.rb
|
209
196
|
- lib/bundler/alive/client/gems_api_response.rb
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "bundler"
|
4
|
-
|
5
|
-
module Bundler
|
6
|
-
module Alive
|
7
|
-
#
|
8
|
-
# Announces check progress
|
9
|
-
#
|
10
|
-
class Announcer
|
11
|
-
DOT = "."
|
12
|
-
|
13
|
-
private_constant :DOT
|
14
|
-
|
15
|
-
#
|
16
|
-
# A new instance of Reporter
|
17
|
-
#
|
18
|
-
def initialize
|
19
|
-
@output = $stdout
|
20
|
-
end
|
21
|
-
|
22
|
-
def announce
|
23
|
-
output.write DOT
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
attr_reader :output
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|