end_of_life 0.2.0 → 0.3.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/CHANGELOG.md +112 -2
- data/Gemfile +4 -1
- data/Gemfile.lock +14 -3
- data/README.md +24 -6
- data/Rakefile +2 -1
- data/end_of_life.gemspec +2 -2
- data/lib/end_of_life/options.rb +55 -0
- data/lib/end_of_life/repository.rb +26 -16
- data/lib/end_of_life/ruby_version.rb +37 -12
- data/lib/end_of_life/version.rb +1 -1
- data/lib/end_of_life.rb +12 -37
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb7c4804e17e676497b2cf43afed14a21bec731ff6ea5e16bfd708ffbb265488
|
4
|
+
data.tar.gz: efaec85105f37185a05e10cd489e4c47403ac6a530615c1900ae978033573142
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73bb63d650d73851b37e0286fb7a6e771286bb49c35f329d91e805d087ca65cf0b160f43fdcb95f1613275f5872594745fe584494ae1314f6ea3ea8cb9048e4e
|
7
|
+
data.tar.gz: 30fed354f3c6a6a5d42c515157d531c2123a225aca3e996bd4193a8d718fd7a1860f0a2b0053cd8354cb4f2b5184751a978439509098977bab5b5d6f61111882
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,111 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.3.0]
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- Allow excluding repositories from search. Due to a [limitation] on GitHub's API,
|
8
|
+
it's only possible to exclude up to five words.
|
9
|
+
|
10
|
+
```sh
|
11
|
+
$ end_of_life --exclude=repo1,repo2
|
12
|
+
```
|
13
|
+
|
14
|
+
[limitation]: https://docs.github.com/en/search-github/getting-started-with-searching-on-github/troubleshooting-search-queries#limitations-on-query-length
|
15
|
+
|
16
|
+
- Allow specifying the repo visibility on search:
|
17
|
+
|
18
|
+
```sh
|
19
|
+
$ end_of_life --public-only
|
20
|
+
# or
|
21
|
+
$ end_of_life --private-only
|
22
|
+
```
|
23
|
+
|
24
|
+
- Allow searching repositories inside organizations
|
25
|
+
|
26
|
+
```sh
|
27
|
+
$ end_of_life --org org1
|
28
|
+
|
29
|
+
# It's also possible to search on multiple organizations
|
30
|
+
$ end_of_life --org org1,org2
|
31
|
+
```
|
32
|
+
|
33
|
+
- Fetch EOL Ruby versions from endoflife.date API. This ensures we always use up-to-date data but keep the embedded JSON as a fallback.
|
34
|
+
|
35
|
+
- Allow users to specify the maximum number of days away a version can be from EOL. It defaults to 0.
|
36
|
+
|
37
|
+
```sh
|
38
|
+
$ end_of_life --max-eol-days-away 90
|
39
|
+
```
|
40
|
+
|
41
|
+
- Add search methods to RubyVersion
|
42
|
+
|
43
|
+
It's possible to query all EOL versions, or the latest one at any given time.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
EndOfLife::RubyVersion.eol_versions_at(Date.today)
|
47
|
+
# =>
|
48
|
+
# [#<EndOfLife::RubyVersion:0x00007f9b1300d858
|
49
|
+
# @eol_date=#<Date: 2021-03-31 ((2459305j,0s,0n),+0s,2299161j)>,
|
50
|
+
# @version=Gem::Version.new("2.5.9")>,
|
51
|
+
# #<EndOfLife::RubyVersion:0x00007f9b1300cea8
|
52
|
+
# @eol_date=#<Date: 2020-03-31 ((2458940j,0s,0n),+0s,2299161j)>,
|
53
|
+
# @version=Gem::Version.new("2.4.10")>,
|
54
|
+
# #<EndOfLife::RubyVersion:0x00007f9b1300cb10
|
55
|
+
# @eol_date=#<Date: 2019-03-31 ((2458574j,0s,0n),+0s,2299161j)>,
|
56
|
+
# @version=Gem::Version.new("2.3.8")>,
|
57
|
+
# #<EndOfLife::RubyVersion:0x00007f9b1300c5e8
|
58
|
+
# @eol_date=#<Date: 2018-03-31 ((2458209j,0s,0n),+0s,2299161j)>,
|
59
|
+
# @version=Gem::Version.new("2.2.10")>,
|
60
|
+
# #<EndOfLife::RubyVersion:0x00007f9b1300c020
|
61
|
+
# @eol_date=#<Date: 2017-03-31 ((2457844j,0s,0n),+0s,2299161j)>,
|
62
|
+
# @version=Gem::Version.new("2.1.10")>,
|
63
|
+
# #<EndOfLife::RubyVersion:0x00007f9b112efbb8
|
64
|
+
# @eol_date=#<Date: 2016-02-24 ((2457443j,0s,0n),+0s,2299161j)>,
|
65
|
+
# @version=Gem::Version.new("2.0.0.pre.p648")>,
|
66
|
+
# #<EndOfLife::RubyVersion:0x00007f9b112ef028
|
67
|
+
# @eol_date=#<Date: 2015-02-23 ((2457077j,0s,0n),+0s,2299161j)>,
|
68
|
+
# @version=Gem::Version.new("1.9.3.pre.p551")>]
|
69
|
+
|
70
|
+
EndOfLife::RubyVersion.latest_eol # returns today's latest EOL version
|
71
|
+
# =>
|
72
|
+
# #<EndOfLife::RubyVersion:0x00007f9b1300d858
|
73
|
+
# @eol_date=#<Date: 2021-03-31 ((2459305j,0s,0n),+0s,2299161j)>,
|
74
|
+
# @version=Gem::Version.new("2.5.9")>
|
75
|
+
|
76
|
+
# returns the latest EOL version at a given date
|
77
|
+
EndOfLife::RubyVersion.latest_eol(at: Date.parse("2024-03-31"))
|
78
|
+
# =>
|
79
|
+
# #<EndOfLife::RubyVersion:0x00007f9b1300e7d0
|
80
|
+
# @eol_date=#<Date: 2024-03-31 ((2460401j,0s,0n),+0s,2299161j)>,
|
81
|
+
# @version=Gem::Version.new("3.0.3")>
|
82
|
+
|
83
|
+
EndOfLife::RubyVersion.new("3.0.0").eol?
|
84
|
+
# => false
|
85
|
+
|
86
|
+
EndOfLife::RubyVersion.new("3.0.0").eol?(at: Date.parse("2024-03-31"))
|
87
|
+
# => true
|
88
|
+
```
|
89
|
+
|
90
|
+
- Using the methods above, we can check whether a Repository is using EOL Ruby versions.
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
# repo with Ruby 3.0 (which is not EOL today)
|
94
|
+
repo.eol_ruby?
|
95
|
+
# => false
|
96
|
+
|
97
|
+
repo.eol_ruby?(at: Date.parse("2024.04.04"))
|
98
|
+
# => true
|
99
|
+
```
|
100
|
+
|
101
|
+
### Changed
|
102
|
+
|
103
|
+
- `EndOfLife::RubyVersion::EOL` constant was removed in favor of `EndOfLife::RubyVersion.latest_eol` method.
|
104
|
+
|
105
|
+
---
|
106
|
+
|
107
|
+
## [0.2.0]
|
108
|
+
|
3
109
|
### Added
|
4
110
|
|
5
111
|
- Allow searching a specific repository.
|
@@ -24,15 +130,19 @@ $ end_of_life --user=matz # searches on matz's repositories
|
|
24
130
|
|
25
131
|
### Changed
|
26
132
|
|
133
|
+
- Remove the 100 repo limit on GitHub API [#13](https://github.com/MatheusRich/end_of_life/pull/13)
|
134
|
+
|
27
135
|
- Exit with -1 if EOL repos are present.
|
28
136
|
|
29
137
|
- Upgrade `octokit` to v4.22, which fixes [a Faraday warning], so we can remove the dependency on the `warning` gem.
|
30
138
|
|
31
139
|
[a faraday warning]: https://github.com/octokit/octokit.rb/pull/1359
|
32
140
|
|
33
|
-
## [0.1.0]
|
141
|
+
## [0.1.0]
|
34
142
|
|
35
143
|
- Initial release
|
36
144
|
|
37
|
-
[unreleased]: https://github.com/MatheusRich/end_of_life/compare/v0.
|
145
|
+
[unreleased]: https://github.com/MatheusRich/end_of_life/compare/v0.3.0...HEAD
|
146
|
+
[0.3.0]: https://github.com/MatheusRich/end_of_life/releases/tag/v0.3.0
|
147
|
+
[0.2.0]: https://github.com/MatheusRich/end_of_life/releases/tag/v0.2.0
|
38
148
|
[0.1.0]: https://github.com/MatheusRich/end_of_life/releases/tag/v0.1.0
|
data/Gemfile
CHANGED
@@ -7,6 +7,9 @@ gemspec
|
|
7
7
|
|
8
8
|
gem "climate_control", "~> 1.0.1"
|
9
9
|
gem "rake", "~> 13.0"
|
10
|
-
gem "rspec", "~> 3.
|
10
|
+
gem "rspec", "~> 3.10"
|
11
|
+
gem "rspec-mocks", "~> 3.10"
|
11
12
|
gem "simplecov", "~> 0.21.2"
|
12
13
|
gem "standard", "~> 1.6"
|
14
|
+
gem "vcr", "~> 6.0.0"
|
15
|
+
gem "webmock", "~> 3.13"
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
end_of_life (0.
|
4
|
+
end_of_life (0.3.0)
|
5
5
|
dry-monads (~> 1.3)
|
6
|
-
octokit (~> 4.
|
6
|
+
octokit (~> 4.22)
|
7
7
|
pastel (~> 0.8.0)
|
8
8
|
tty-spinner (~> 0.9.0)
|
9
9
|
tty-table (~> 0.12.0)
|
@@ -16,6 +16,8 @@ GEM
|
|
16
16
|
ast (2.4.2)
|
17
17
|
climate_control (1.0.1)
|
18
18
|
concurrent-ruby (1.1.9)
|
19
|
+
crack (0.4.5)
|
20
|
+
rexml
|
19
21
|
diff-lcs (1.4.4)
|
20
22
|
docile (1.4.0)
|
21
23
|
dry-core (0.7.1)
|
@@ -46,6 +48,7 @@ GEM
|
|
46
48
|
faraday-patron (1.0.0)
|
47
49
|
faraday-rack (1.0.0)
|
48
50
|
faraday-retry (1.0.3)
|
51
|
+
hashdiff (1.0.1)
|
49
52
|
multipart-post (2.1.1)
|
50
53
|
octokit (4.22.0)
|
51
54
|
faraday (>= 0.9)
|
@@ -117,6 +120,11 @@ GEM
|
|
117
120
|
tty-screen (~> 0.8)
|
118
121
|
unicode-display_width (2.1.0)
|
119
122
|
unicode_utils (1.4.0)
|
123
|
+
vcr (6.0.0)
|
124
|
+
webmock (3.13.0)
|
125
|
+
addressable (>= 2.3.6)
|
126
|
+
crack (>= 0.3.2)
|
127
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
120
128
|
|
121
129
|
PLATFORMS
|
122
130
|
x86_64-darwin-20
|
@@ -126,9 +134,12 @@ DEPENDENCIES
|
|
126
134
|
climate_control (~> 1.0.1)
|
127
135
|
end_of_life!
|
128
136
|
rake (~> 13.0)
|
129
|
-
rspec (~> 3.
|
137
|
+
rspec (~> 3.10)
|
138
|
+
rspec-mocks (~> 3.10)
|
130
139
|
simplecov (~> 0.21.2)
|
131
140
|
standard (~> 1.6)
|
141
|
+
vcr (~> 6.0.0)
|
142
|
+
webmock (~> 3.13)
|
132
143
|
|
133
144
|
BUNDLED WITH
|
134
145
|
2.3.4
|
data/README.md
CHANGED
@@ -12,13 +12,14 @@ gem install end_of_life
|
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
15
|
-
1. Set up a [GitHub access token];
|
15
|
+
1. Set up a [GitHub access token][] (we recommend using a read-only token);
|
16
16
|
|
17
|
-
[
|
17
|
+
[github access token]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-token
|
18
18
|
|
19
19
|
2. Export the `GITHUB_TOKEN` environment variable or set it when calling `end_of_life`;
|
20
20
|
|
21
21
|
3. Use the `end_of_life` command to list the repositories:
|
22
|
+
|
22
23
|
```sh
|
23
24
|
$ GITHUB_TOKEN=something end_of_life # if your platform supports symlinks, you can use the `eol` command instead
|
24
25
|
[✔] Fetching repositories...
|
@@ -33,15 +34,32 @@ Found 2 repositories using EOL Ruby (<= 2.5.9):
|
|
33
34
|
└───┴──────────────────────────────────────────────┴──────────────┘
|
34
35
|
```
|
35
36
|
|
36
|
-
|
37
|
+
### Options
|
38
|
+
|
39
|
+
There are some options to help you filter down the results:
|
40
|
+
|
41
|
+
```
|
42
|
+
Usage: end_of_life [options]
|
43
|
+
--exclude=NAME,NAME2 Exclude repositories containing a certain word in its name. You can specify up to five words.
|
44
|
+
--public-only Searches only public repostories
|
45
|
+
--private-only Searches only private repostories
|
46
|
+
--repo, --repository=USER/REPO Searches a specific repostory
|
47
|
+
--org, --organization=ORG,ORG2 Searches within specific organizations
|
48
|
+
-u, --user=NAME Sets the user used on the repository search
|
49
|
+
--max-eol-days-away NUMBER Sets the maximum number of days away a version can be from EOL. It defaults to 0.
|
50
|
+
-v, --version Displays end_of_life version
|
51
|
+
-h, --help Displays this help
|
52
|
+
```
|
53
|
+
|
54
|
+
## How it works
|
37
55
|
|
38
56
|
This gem fetches all your GitHub repositories that contain Ruby code, then
|
39
57
|
searches for files that may have a Ruby version. Currently, those files are:
|
40
58
|
`.ruby-version`, `Gemfile`, `Gemfile.lock`, and `.tool-version`. We parse these
|
41
59
|
files and extract the minimum Ruby version used in the repository.
|
42
60
|
|
43
|
-
The EOL Ruby version is
|
44
|
-
|
61
|
+
The EOL Ruby version is provided by https://endoflife.date/, with a file
|
62
|
+
[fallback].
|
45
63
|
|
46
64
|
> **IMPORTANT:** To parse Gemfiles, we need to execute the code inside it. **Be
|
47
65
|
> careful** because this may be a security risk. We plan to add a secure parser
|
@@ -49,7 +67,7 @@ https://endoflife.date/. We plan to fetch their API endpoint in the future.
|
|
49
67
|
|
50
68
|
Some other limitations are listed on the [issues page].
|
51
69
|
|
52
|
-
[
|
70
|
+
[fallback]: ./lib/end_of_life.json
|
53
71
|
[issues page]: https://github.com/MatheusRich/end_of_life/issues
|
54
72
|
|
55
73
|
## Development
|
data/Rakefile
CHANGED
data/end_of_life.gemspec
CHANGED
@@ -32,9 +32,9 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
33
33
|
spec.require_paths = ["lib"]
|
34
34
|
|
35
|
-
spec.add_dependency "octokit", "~> 4.0"
|
36
|
-
spec.add_dependency "pastel", "~> 0.8.0"
|
37
35
|
spec.add_dependency "dry-monads", "~> 1.3"
|
36
|
+
spec.add_dependency "octokit", "~> 4.22"
|
37
|
+
spec.add_dependency "pastel", "~> 0.8.0"
|
38
38
|
spec.add_dependency "tty-spinner", "~> 0.9.0"
|
39
39
|
spec.add_dependency "tty-table", "~> 0.12.0"
|
40
40
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "optparse"
|
2
|
+
|
3
|
+
module EndOfLife
|
4
|
+
module Options
|
5
|
+
def self.from(argv)
|
6
|
+
options = {max_eol_date: Date.today}
|
7
|
+
|
8
|
+
OptionParser.new do |opts|
|
9
|
+
options[:parser] = opts
|
10
|
+
|
11
|
+
opts.banner = "Usage: end_of_life [options]"
|
12
|
+
|
13
|
+
opts.on("--exclude=NAME,NAME2", Array, "Exclude repositories containing a certain word in its name. You can specify up to five words.") do |excludes|
|
14
|
+
options[:excludes] = excludes.first(5)
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on("--public-only", "Searches only public repostories") do
|
18
|
+
options[:visibility] = :public
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("--private-only", "Searches only private repostories") do
|
22
|
+
options[:visibility] = :private
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on("--repo=USER/REPO", "--repository=USER/REPO", "Searches a specific repostory") do |repository|
|
26
|
+
options[:repository] = repository
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on("--org=ORG,ORG2...", "--organization=ORG,ORG2", Array, "Searches within specific organizations") do |organizations|
|
30
|
+
options[:organizations] = organizations
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on("-u NAME", "--user=NAME", "Sets the user used on the repository search") do |user|
|
34
|
+
options[:user] = user
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on("--max-eol-days-away NUMBER", "Sets the maximum number of days away a version can be from EOL. It defaults to 0.") do |days|
|
38
|
+
options[:max_eol_date] = Date.today + days.to_i.abs
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on("-v", "--version", "Displays end_of_life version") do
|
42
|
+
options[:command] = :version
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on("-h", "--help", "Displays this help") do
|
46
|
+
options[:command] = :help
|
47
|
+
end
|
48
|
+
end.parse!(argv)
|
49
|
+
|
50
|
+
options
|
51
|
+
rescue OptionParser::ParseError => e
|
52
|
+
{command: :print_error, error: e}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,20 +1,18 @@
|
|
1
|
-
require "dry-monads"
|
2
|
-
|
3
1
|
module EndOfLife
|
4
2
|
class Repository
|
5
3
|
class << self
|
6
4
|
include Dry::Monads[:result, :maybe]
|
7
5
|
|
8
|
-
def fetch(
|
6
|
+
def fetch(options)
|
9
7
|
github_client.bind do |github|
|
10
|
-
|
11
|
-
|
8
|
+
github.auto_paginate = true
|
9
|
+
options[:user] ||= github.user.login
|
12
10
|
|
13
|
-
|
14
|
-
|
11
|
+
query = search_query_for(options)
|
12
|
+
items = github.search_repositories(query).items
|
15
13
|
|
16
14
|
Success(
|
17
|
-
|
15
|
+
items.map do |repo|
|
18
16
|
Repository.new(
|
19
17
|
full_name: repo.full_name,
|
20
18
|
url: repo.html_url,
|
@@ -29,17 +27,29 @@ module EndOfLife
|
|
29
27
|
|
30
28
|
def github_client
|
31
29
|
Maybe(ENV["GITHUB_TOKEN"])
|
32
|
-
.to_result
|
33
30
|
.fmap { |token| Octokit::Client.new(access_token: token) }
|
34
31
|
.or { Failure("Please set GITHUB_TOKEN environment variable") }
|
35
32
|
end
|
36
33
|
|
37
|
-
def search_query_for(
|
38
|
-
query = "language
|
39
|
-
|
40
|
-
|
34
|
+
def search_query_for(options)
|
35
|
+
query = "language:ruby"
|
36
|
+
|
37
|
+
query += if options[:repository]
|
38
|
+
" repo:#{options[:repository]}"
|
39
|
+
elsif options[:organizations]
|
40
|
+
options[:organizations].map { |org| " org:#{org}" }.join
|
41
41
|
else
|
42
|
-
" user:#{user}"
|
42
|
+
" user:#{options[:user]}"
|
43
|
+
end
|
44
|
+
|
45
|
+
if options[:visibility]
|
46
|
+
query += " is:#{options[:visibility]}"
|
47
|
+
end
|
48
|
+
|
49
|
+
if options[:excludes]
|
50
|
+
words_to_exclude = options[:excludes].map { |word| "NOT #{word} " }.join
|
51
|
+
|
52
|
+
query += " #{words_to_exclude} in:name"
|
43
53
|
end
|
44
54
|
|
45
55
|
query
|
@@ -54,8 +64,8 @@ module EndOfLife
|
|
54
64
|
@github_client = github_client
|
55
65
|
end
|
56
66
|
|
57
|
-
def eol_ruby?
|
58
|
-
ruby_version&.eol?
|
67
|
+
def eol_ruby?(at: Date.today)
|
68
|
+
ruby_version&.eol?(at: at)
|
59
69
|
end
|
60
70
|
|
61
71
|
def ruby_version
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "net/http"
|
1
2
|
require "rubygems"
|
2
3
|
require_relative "ruby_version/parser"
|
3
4
|
|
@@ -5,28 +6,52 @@ module EndOfLife
|
|
5
6
|
class RubyVersion
|
6
7
|
include Comparable
|
7
8
|
|
8
|
-
|
9
|
+
class << self
|
10
|
+
include Dry::Monads[:try]
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
.map { |version| Gem::Version.new(version[:latest]) }
|
14
|
-
.max
|
12
|
+
def from_file(file_name:, content:, parser: Parser)
|
13
|
+
parser.parse_file(file_name: file_name, content: content)
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
def eol_versions_at(date)
|
17
|
+
all_versions.filter { |version| version.eol_date <= date }
|
18
|
+
end
|
19
|
+
|
20
|
+
def latest_eol(at: Date.today)
|
21
|
+
eol_versions_at(at).max
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
EOL_API_URL = "https://endoflife.date/api/ruby.json"
|
27
|
+
DB_PATH = File.join(__dir__, "../end_of_life.json")
|
28
|
+
|
29
|
+
def all_versions
|
30
|
+
@all_versions ||= (fetch_end_of_life_api || load_file_fallback)
|
31
|
+
.then { |json| JSON.parse(json, symbolize_names: true) }
|
32
|
+
.map { |version| new(version[:latest], eol_date: Date.parse(version[:eol])) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def fetch_end_of_life_api
|
36
|
+
Try { Net::HTTP.get URI(EOL_API_URL) }.value_or(nil)
|
37
|
+
end
|
38
|
+
|
39
|
+
def load_file_fallback
|
40
|
+
File.read(DB_PATH)
|
41
|
+
end
|
18
42
|
end
|
19
43
|
|
20
|
-
attr :version
|
44
|
+
attr :version, :eol_date
|
21
45
|
|
22
|
-
def initialize(version_string)
|
46
|
+
def initialize(version_string, eol_date: nil)
|
23
47
|
@version = Gem::Version.new(version_string)
|
48
|
+
@eol_date = eol_date
|
24
49
|
|
25
50
|
freeze
|
26
51
|
end
|
27
52
|
|
28
|
-
def eol?
|
29
|
-
|
53
|
+
def eol?(at: Date.today)
|
54
|
+
self <= RubyVersion.latest_eol(at: at)
|
30
55
|
end
|
31
56
|
|
32
57
|
def <=>(other)
|
data/lib/end_of_life/version.rb
CHANGED
data/lib/end_of_life.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "dry-monads"
|
3
4
|
require "json"
|
4
5
|
require "octokit"
|
5
|
-
|
6
|
+
require_relative "end_of_life/options"
|
6
7
|
require_relative "end_of_life/repository"
|
7
8
|
require_relative "end_of_life/ruby_version"
|
8
9
|
require_relative "end_of_life/terminal_helper"
|
@@ -36,45 +37,19 @@ module EndOfLife
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def check_eol_ruby_on_repositories(options)
|
39
|
-
fetch_repositories(
|
40
|
-
.fmap { |repositories| filter_repositories_with_end_of_life(repositories) }
|
41
|
-
.fmap { |repositories| print_diagnose_for(repositories) }
|
40
|
+
fetch_repositories(options)
|
41
|
+
.fmap { |repositories| filter_repositories_with_end_of_life(repositories, max_eol_date: options[:max_eol_date]) }
|
42
|
+
.fmap { |repositories| print_diagnose_for(repositories, max_eol_date: options[:max_eol_date]) }
|
42
43
|
.or { |error| puts "\n#{error_msg(error)}" }
|
43
44
|
end
|
44
45
|
|
45
46
|
def parse_options(argv)
|
46
|
-
|
47
|
-
|
48
|
-
OptionParser.new do |opts|
|
49
|
-
options[:parser] = opts
|
50
|
-
|
51
|
-
opts.banner = "Usage: end_of_life [options]"
|
52
|
-
|
53
|
-
opts.on("--repo=USER/REPO", "--repository=USER/REPO", "Searches a specific repostory") do |repository|
|
54
|
-
options[:repository] = repository
|
55
|
-
end
|
56
|
-
|
57
|
-
opts.on("-u NAME", "--user=NAME", "Sets the user used on the repository search") do |user|
|
58
|
-
options[:user] = user
|
59
|
-
end
|
60
|
-
|
61
|
-
opts.on("-v", "--version", "Displays end_of_life version") do
|
62
|
-
options[:command] = :version
|
63
|
-
end
|
64
|
-
|
65
|
-
opts.on("-h", "--help", "Displays this help") do
|
66
|
-
options[:command] = :help
|
67
|
-
end
|
68
|
-
end.parse!(argv)
|
69
|
-
|
70
|
-
options
|
71
|
-
rescue OptionParser::ParseError => e
|
72
|
-
{command: :print_error, error: e}
|
47
|
+
Options.from(argv)
|
73
48
|
end
|
74
49
|
|
75
|
-
def fetch_repositories(
|
50
|
+
def fetch_repositories(options)
|
76
51
|
with_loading_spinner("Fetching repositories...") do |spinner|
|
77
|
-
result = Repository.fetch(
|
52
|
+
result = Repository.fetch(options)
|
78
53
|
|
79
54
|
spinner.error if result.failure?
|
80
55
|
|
@@ -82,13 +57,13 @@ module EndOfLife
|
|
82
57
|
end
|
83
58
|
end
|
84
59
|
|
85
|
-
def filter_repositories_with_end_of_life(repositories)
|
60
|
+
def filter_repositories_with_end_of_life(repositories, max_eol_date:)
|
86
61
|
with_loading_spinner("Searching for EOL Ruby in repositories...") do
|
87
|
-
repositories.filter { |repo| repo.eol_ruby? }
|
62
|
+
repositories.filter { |repo| repo.eol_ruby?(at: max_eol_date) }
|
88
63
|
end
|
89
64
|
end
|
90
65
|
|
91
|
-
def print_diagnose_for(repositories)
|
66
|
+
def print_diagnose_for(repositories, max_eol_date:)
|
92
67
|
puts
|
93
68
|
|
94
69
|
if repositories.empty?
|
@@ -96,7 +71,7 @@ module EndOfLife
|
|
96
71
|
return
|
97
72
|
end
|
98
73
|
|
99
|
-
puts "Found #{repositories.size} repositories using EOL Ruby (<= #{RubyVersion
|
74
|
+
puts "Found #{repositories.size} repositories using EOL Ruby (<= #{RubyVersion.latest_eol(at: max_eol_date)}):"
|
100
75
|
puts end_of_life_table(repositories)
|
101
76
|
exit(-1)
|
102
77
|
end
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: end_of_life
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matheus Richard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: dry-monads
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: octokit
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '4.22'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '4.22'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: pastel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.8.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.8.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: tty-spinner
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- exe/eol
|
108
108
|
- lib/end_of_life.json
|
109
109
|
- lib/end_of_life.rb
|
110
|
+
- lib/end_of_life/options.rb
|
110
111
|
- lib/end_of_life/repository.rb
|
111
112
|
- lib/end_of_life/ruby_version.rb
|
112
113
|
- lib/end_of_life/ruby_version/parser.rb
|