Class: Dev::EndOfLife

Inherits:
Object show all
Defined in:
lib/firespring_dev_commands/eol.rb,
lib/firespring_dev_commands/eol/aws.rb,
lib/firespring_dev_commands/eol/php.rb,
lib/firespring_dev_commands/eol/node.rb,
lib/firespring_dev_commands/eol/ruby.rb,
lib/firespring_dev_commands/eol/product_version.rb

Overview

Class that contains methods for checking product versions of all tracked projects

Defined Under Namespace

Classes: Aws, Config, Node, Php, ProductVersion, Ruby

Constant Summary collapse

END_OF_LIFE_API_URL =

The URL of the end of life project api

'https://endoflife.date/api'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(product_versions: self.class.config.product_versions) ⇒ EndOfLife

Returns a new instance of EndOfLife.



31
32
33
34
# File 'lib/firespring_dev_commands/eol.rb', line 31

def initialize(product_versions: self.class.config.product_versions)
  @product_versions = Array(product_versions)
  raise 'product version must be of type Dev::EndOfLife::ProductVersions' unless @product_versions.all?(Dev::EndOfLife::ProductVersion)
end

Instance Attribute Details

#product_versionsObject

Returns the value of attribute product_versions.



29
30
31
# File 'lib/firespring_dev_commands/eol.rb', line 29

def product_versions
  @product_versions
end

#productsObject

Returns all products supported by the EOL api



37
38
39
# File 'lib/firespring_dev_commands/eol.rb', line 37

def products
  @products
end

#urlObject

Returns the value of attribute url.



29
30
31
# File 'lib/firespring_dev_commands/eol.rb', line 29

def url
  @url
end

Class Method Details

.config {|@config| ... } ⇒ Object Also known as: configure

Instantiates a new top level config object if one hasn’t already been created Yields that config object to any given block Returns the resulting config object

Yields:



19
20
21
22
23
# File 'lib/firespring_dev_commands/eol.rb', line 19

def config
  @config ||= Config.new
  yield(@config) if block_given?
  @config
end

Instance Method Details

#checkObject

Prints all of the product version statuses Raises an error if any products are EOL



71
72
73
74
75
76
# File 'lib/firespring_dev_commands/eol.rb', line 71

def check
  puts
  status
  puts
  raise 'found EOL versions' if eol?
end

#eol?Boolean

Returns true if any of the products are EOL

Returns:

  • (Boolean)


65
66
67
# File 'lib/firespring_dev_commands/eol.rb', line 65

def eol?
  product_versions.any?(&:eol)
end

#product?(product) ⇒ Boolean

Returns true if the given product is supported either in the endoflife api products or a manual product

Returns:

  • (Boolean)


50
51
52
# File 'lib/firespring_dev_commands/eol.rb', line 50

def product?(product)
  products.include?(product) || self.class.config.manual_dates.any? { |key, _| key.to_s.start_with?("#{product}_") }
end

#statusObject

Prints all of the product version statuses



55
56
57
58
59
60
61
62
# File 'lib/firespring_dev_commands/eol.rb', line 55

def status
  if product_versions.empty?
    puts '  no tracked products'
    return
  end

  product_versions.sort_by(&:name).each(&:print_status)
end