end_of_life 0.1.0 → 0.2.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
2
  SHA256:
3
- metadata.gz: 66851fa78b32b4451ef40ef58f02c25386f6badd5d216a8bd360ed0dba84feed
4
- data.tar.gz: 2f0c53b0a7d125b7ed0b408501a9a754c846b8d84e45821f70dd07ae1de13c1c
3
+ metadata.gz: 5e058c01c970e9fde4fdceeabde71c29a623374ef989987d5b5ab10e1e247ca4
4
+ data.tar.gz: 58adcd9c3aa9fbf64b1adb7a7f2f68d1d551ee41925ff9f06c03ce9e21298448
5
5
  SHA512:
6
- metadata.gz: 0cfee4bc90cae86ebb57baa7d48b1aa4cc4f9a521effffc4e0cbea29029fbcdfafd5a09b219639b30ae688792030102f91011b0960899d56a1e8e4aee4583f8d
7
- data.tar.gz: b2a3556b924c0fbfb8968ef8ff2c64359b9b66f2659acef55442a3579d35a3877a8805ae4f62192be5d9f3a3d1ea5a91fa0413a9ebf96386d86d4564ec2c7df4
6
+ metadata.gz: 87d59b8b0d1aa556bf0b2bc7295a617fe5890bb0056437c7728d497468a05df6b57150f13680ac0be0ae9a400d40d02dac05331a5999d59943bcce7821d767f9
7
+ data.tar.gz: 38acbd80942af304503ec510b666f2b18ce1de8a728d92254c5fd3acd1393d6eadeb3c8e24aa1de242bc6a7f5243226a446a11e529c03d5e6443adcd571408a6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2022-01-07
3
+ ### Added
4
+
5
+ - Allow searching a specific repository.
6
+
7
+ ```sh
8
+ $ end_of_life --repo=MatheusRich/ez_attributes
9
+ ```
10
+
11
+ - Allow specifying the user used on the repository search.
12
+
13
+ ```sh
14
+ $ end_of_life --user=matz # searches on matz's repositories
15
+ ```
16
+
17
+ ### Fixed
18
+
19
+ - Load end_of_life JSON database from dynamic path [#10](https://github.com/MatheusRich/end_of_life/pull/10).
20
+
21
+ When installed on a fresh Ruby installation without the source code cloned,
22
+ the JSON file couldn't be found because it was looking at the cwd of the
23
+ running process instead of the Gem's lib directory path.
24
+
25
+ ### Changed
26
+
27
+ - Exit with -1 if EOL repos are present.
28
+
29
+ - Upgrade `octokit` to v4.22, which fixes [a Faraday warning], so we can remove the dependency on the `warning` gem.
30
+
31
+ [a faraday warning]: https://github.com/octokit/octokit.rb/pull/1359
32
+
33
+ ## [0.1.0] - 2022-01-17
4
34
 
5
35
  - Initial release
36
+
37
+ [unreleased]: https://github.com/MatheusRich/end_of_life/compare/v0.1.0...HEAD
38
+ [0.1.0]: https://github.com/MatheusRich/end_of_life/releases/tag/v0.1.0
data/Gemfile.lock CHANGED
@@ -1,13 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- end_of_life (0.1.0)
4
+ end_of_life (0.2.0)
5
5
  dry-monads (~> 1.3)
6
6
  octokit (~> 4.0)
7
7
  pastel (~> 0.8.0)
8
8
  tty-spinner (~> 0.9.0)
9
9
  tty-table (~> 0.12.0)
10
- warning (~> 1.2.1)
11
10
 
12
11
  GEM
13
12
  remote: https://rubygems.org/
@@ -48,7 +47,7 @@ GEM
48
47
  faraday-rack (1.0.0)
49
48
  faraday-retry (1.0.3)
50
49
  multipart-post (2.1.1)
51
- octokit (4.21.0)
50
+ octokit (4.22.0)
52
51
  faraday (>= 0.9)
53
52
  sawyer (~> 0.8.0, >= 0.5.3)
54
53
  parallel (1.21.0)
@@ -118,7 +117,6 @@ GEM
118
117
  tty-screen (~> 0.8)
119
118
  unicode-display_width (2.1.0)
120
119
  unicode_utils (1.4.0)
121
- warning (1.2.1)
122
120
 
123
121
  PLATFORMS
124
122
  x86_64-darwin-20
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
- # End Of Life
1
+ # End of Life
2
2
 
3
3
  This gem lists GitHub repositories using end-of-life Ruby versions.
4
4
 
5
+ ![End of Life Demo](demo.gif)
6
+
5
7
  ## Installation
6
8
 
7
9
  ```sh
data/demo.gif ADDED
Binary file
data/end_of_life.gemspec CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Matheus Richard"]
9
9
  spec.email = ["matheusrichardt@gmail.com"]
10
10
 
11
- spec.summary = "Lists repositories using end-of-life Ruby versions"
11
+ spec.summary = "Lists repositories using end-of-life Ruby versions."
12
12
  spec.description = "Searches your GitHub repositores and lists the ones using end-of-life, i.e. " \
13
- "unmaintained, Ruby versions"
13
+ "unmaintained, Ruby versions."
14
14
  spec.homepage = "https://github.com/MatheusRich/end_of_life"
15
15
  spec.license = "MIT"
16
16
  spec.required_ruby_version = ">= 2.7.0"
@@ -37,7 +37,6 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency "dry-monads", "~> 1.3"
38
38
  spec.add_dependency "tty-spinner", "~> 0.9.0"
39
39
  spec.add_dependency "tty-table", "~> 0.12.0"
40
- spec.add_dependency "warning", "~> 1.2.1"
41
40
 
42
41
  # For more information and examples about making a new gem, check out our
43
42
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -5,19 +5,23 @@ module EndOfLife
5
5
  class << self
6
6
  include Dry::Monads[:result, :maybe]
7
7
 
8
- def fetch(language:, user: nil)
9
- github_client.fmap do |github|
8
+ def fetch(language:, user:, repository: nil)
9
+ github_client.bind do |github|
10
10
  user ||= github.user.login
11
- response = github.search_repositories("user:#{user} language:#{language}", per_page: 100)
11
+ query = search_query_for(language: language, user: user, repository: repository)
12
+
13
+ response = github.search_repositories(query, per_page: 100)
12
14
  warn "Incomplete results: we only search 100 repos at a time" if response.incomplete_results
13
15
 
14
- response.items.map do |repo|
15
- Repository.new(
16
- full_name: repo.full_name,
17
- url: repo.html_url,
18
- github_client: github
19
- )
20
- end
16
+ Success(
17
+ response.items.map do |repo|
18
+ Repository.new(
19
+ full_name: repo.full_name,
20
+ url: repo.html_url,
21
+ github_client: github
22
+ )
23
+ end
24
+ )
21
25
  rescue => e
22
26
  Failure("Unexpected error: #{e}")
23
27
  end
@@ -29,6 +33,17 @@ module EndOfLife
29
33
  .fmap { |token| Octokit::Client.new(access_token: token) }
30
34
  .or { Failure("Please set GITHUB_TOKEN environment variable") }
31
35
  end
36
+
37
+ def search_query_for(language:, user:, repository:)
38
+ query = "language:#{language}"
39
+ query += if repository
40
+ " repo:#{repository}"
41
+ else
42
+ " user:#{user}"
43
+ end
44
+
45
+ query
46
+ end
32
47
  end
33
48
 
34
49
  attr :full_name, :url
@@ -1,10 +1,13 @@
1
+ require "rubygems"
1
2
  require_relative "ruby_version/parser"
2
3
 
3
4
  module EndOfLife
4
5
  class RubyVersion
5
6
  include Comparable
6
7
 
7
- EOL = File.read("lib/end_of_life.json")
8
+ DB_PATH = File.join(__dir__, "../end_of_life.json")
9
+
10
+ EOL = File.read(DB_PATH)
8
11
  .then { |json| JSON.parse(json, symbolize_names: true) }
9
12
  .filter { |version| Date.parse(version[:eol]) <= Date.today }
10
13
  .map { |version| Gem::Version.new(version[:latest]) }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EndOfLife
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/end_of_life.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "json"
4
4
  require "octokit"
5
- require "warning"
5
+ require "optparse"
6
6
  require_relative "end_of_life/repository"
7
7
  require_relative "end_of_life/ruby_version"
8
8
  require_relative "end_of_life/terminal_helper"
@@ -11,23 +11,70 @@ require_relative "end_of_life/version"
11
11
  module EndOfLife
12
12
  extend TerminalHelper
13
13
 
14
- Warning.ignore(/Faraday::Connection#authorization/)
15
-
16
14
  class CLI
17
15
  include TerminalHelper
18
16
 
19
17
  def call(argv)
20
- fetch_repositories
18
+ parse_options(argv)
19
+ .then { |options| execute_command(options) }
20
+ end
21
+
22
+ private
23
+
24
+ def execute_command(options)
25
+ case options[:command]
26
+ when :help
27
+ puts options[:parser]
28
+ when :version
29
+ puts "end_of_life v#{EndOfLife::VERSION}"
30
+ when :print_error
31
+ puts error_msg(options[:error])
32
+ exit(-1)
33
+ else
34
+ check_eol_ruby_on_repositories(options)
35
+ end
36
+ end
37
+
38
+ def check_eol_ruby_on_repositories(options)
39
+ fetch_repositories(user: options[:user], repository: options[:repository])
21
40
  .fmap { |repositories| filter_repositories_with_end_of_life(repositories) }
22
41
  .fmap { |repositories| print_diagnose_for(repositories) }
23
42
  .or { |error| puts "\n#{error_msg(error)}" }
24
43
  end
25
44
 
26
- private
45
+ def parse_options(argv)
46
+ options = {}
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}
73
+ end
27
74
 
28
- def fetch_repositories
75
+ def fetch_repositories(user:, repository:)
29
76
  with_loading_spinner("Fetching repositories...") do |spinner|
30
- result = Repository.fetch(language: "ruby")
77
+ result = Repository.fetch(language: "ruby", user: user, repository: repository)
31
78
 
32
79
  spinner.error if result.failure?
33
80
 
@@ -51,6 +98,7 @@ module EndOfLife
51
98
 
52
99
  puts "Found #{repositories.size} repositories using EOL Ruby (<= #{RubyVersion::EOL}):"
53
100
  puts end_of_life_table(repositories)
101
+ exit(-1)
54
102
  end
55
103
 
56
104
  def end_of_life_table(repositories)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: end_of_life
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.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-01-17 00:00:00.000000000 Z
11
+ date: 2022-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -80,22 +80,8 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.12.0
83
- - !ruby/object:Gem::Dependency
84
- name: warning
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 1.2.1
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 1.2.1
97
83
  description: Searches your GitHub repositores and lists the ones using end-of-life,
98
- i.e. unmaintained, Ruby versions
84
+ i.e. unmaintained, Ruby versions.
99
85
  email:
100
86
  - matheusrichardt@gmail.com
101
87
  executables:
@@ -115,6 +101,7 @@ files:
115
101
  - Rakefile
116
102
  - bin/console
117
103
  - bin/setup
104
+ - demo.gif
118
105
  - end_of_life.gemspec
119
106
  - exe/end_of_life
120
107
  - exe/eol
@@ -150,5 +137,5 @@ requirements: []
150
137
  rubygems_version: 3.2.32
151
138
  signing_key:
152
139
  specification_version: 4
153
- summary: Lists repositories using end-of-life Ruby versions
140
+ summary: Lists repositories using end-of-life Ruby versions.
154
141
  test_files: []