class EndOfLife::CLI

Public Instance Methods

call(argv) click to toggle source
# File lib/end_of_life.rb, line 18
def call(argv)
  parse_options(argv)
    .then { |options| execute_command(options) }
end

Private Instance Methods

check_eol_ruby_on_repositories(options) click to toggle source
# File lib/end_of_life.rb, line 39
def check_eol_ruby_on_repositories(options)
  fetch_repositories(options)
    .fmap { |repositories| filter_repositories_with_end_of_life(repositories, max_eol_date: options[:max_eol_date]) }
    .fmap { |repositories| print_diagnose_for(repositories, max_eol_date: options[:max_eol_date]) }
    .or { |error| puts "\n#{error_msg(error)}" }
end
end_of_life_table(repositories) click to toggle source
# File lib/end_of_life.rb, line 79
def end_of_life_table(repositories)
  headers = ["", "Repository", "Ruby version"]
  rows = repositories.map.with_index(1) do |repo, i|
    [i, repo.url, repo.ruby_version]
  end

  table(headers, rows)
end
execute_command(options) click to toggle source
# File lib/end_of_life.rb, line 25
def execute_command(options)
  case options[:command]
  when :help
    puts options[:parser]
  when :version
    puts "end_of_life v#{EndOfLife::VERSION}"
  when :print_error
    puts error_msg(options[:error])
    exit(-1)
  else
    check_eol_ruby_on_repositories(options)
  end
end
fetch_repositories(options) click to toggle source
# File lib/end_of_life.rb, line 50
def fetch_repositories(options)
  with_loading_spinner("Fetching repositories...") do |spinner|
    result = Repository.fetch(options)

    spinner.error if result.failure?

    result
  end
end
filter_repositories_with_end_of_life(repositories, max_eol_date:) click to toggle source
# File lib/end_of_life.rb, line 60
def filter_repositories_with_end_of_life(repositories, max_eol_date:)
  with_loading_spinner("Searching for EOL Ruby in repositories...") do
    repositories.filter { |repo| repo.eol_ruby?(at: max_eol_date) }
  end
end
parse_options(argv) click to toggle source
# File lib/end_of_life.rb, line 46
def parse_options(argv)
  Options.from(argv)
end
print_diagnose_for(repositories, max_eol_date:) click to toggle source