end_of_life 0.5.0 → 1.0.0.alpha

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.
@@ -1,63 +0,0 @@
1
- require "optparse"
2
-
3
- module EndOfLife
4
- module Options
5
- def self.from(argv)
6
- options = {product: Product.find("ruby"), max_eol_date: Date.today, skip_archived: true}
7
- OptionParser.new do |parser|
8
- options[:parser] = parser
9
-
10
- parser.banner = "Usage: end_of_life [options]"
11
-
12
- product_names = EndOfLife.products.map(&:name)
13
- parser.on("-p NAME", "--product NAME", /#{product_names.join("|")}/i, "Sets the product to scan for (default: ruby). Supported products are: #{product_names.join(", ")}.") do |name|
14
- options[:product] = Product.find(name)
15
- end
16
-
17
- parser.on("--exclude=NAME,NAME2", Array, "Exclude repositories containing a certain word in its name. You can specify up to five words.") do |excludes|
18
- options[:excludes] = excludes.first(5)
19
- end
20
-
21
- parser.on("--public-only", "Searches only public repositories") do
22
- options[:visibility] = :public
23
- end
24
-
25
- parser.on("--private-only", "Searches only private repositories") do
26
- options[:visibility] = :private
27
- end
28
-
29
- parser.on("--repo=USER/REPO", "--repository=USER/REPO", "Searches a specific repository") do |repository|
30
- options[:repository] = repository
31
- end
32
-
33
- parser.on("--org=ORG,ORG2...", "--organization=ORG,ORG2", Array, "Searches within specific organizations") do |organizations|
34
- options[:organizations] = organizations
35
- end
36
-
37
- parser.on("-u NAME", "--user=NAME", "Sets the user used on the repository search") do |user|
38
- options[:user] = user
39
- end
40
-
41
- parser.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|
42
- options[:max_eol_date] = Date.today + days.to_i.abs
43
- end
44
-
45
- parser.on("--include-archived", "Includes archived repositories on the search") do
46
- options[:skip_archived] = false
47
- end
48
-
49
- parser.on("-v", "--version", "Displays end_of_life version") do
50
- options[:command] = :version
51
- end
52
-
53
- parser.on("-h", "--help", "Displays this help") do
54
- options[:command] = :help
55
- end
56
- end.parse!(argv)
57
-
58
- options
59
- rescue OptionParser::ParseError => e
60
- {command: :print_error, error: e}
61
- end
62
- end
63
- end
@@ -1,35 +0,0 @@
1
- require "stringio"
2
-
3
- module EndOfLife
4
- class Report < Data.define(:product, :repositories, :max_eol_date)
5
- include Helpers::Terminal
6
-
7
- def to_s
8
- report = StringIO.new
9
- report.puts
10
-
11
- if repositories.empty?
12
- report.puts "No repositories using EOL #{product}."
13
- else
14
- word = (repositories.size == 1) ? "repository" : "repositories"
15
- report.puts "Found #{repositories.size} #{word} using EOL #{product} (<= #{product.latest_eol_release(at: max_eol_date)}):"
16
- report.puts end_of_life_table(repositories)
17
- end
18
-
19
- report.string
20
- end
21
-
22
- def failure? = repositories.any?
23
-
24
- private
25
-
26
- def end_of_life_table(repositories)
27
- headers = ["", "Repository", "#{product} version"]
28
- rows = repositories.map.with_index(1) do |repo, i|
29
- [i, repo.url, repo.min_release_of(product)]
30
- end
31
-
32
- table(headers, rows)
33
- end
34
- end
35
- end