bin/check-all-gpg-keys-for-expiry.rb
def sort_keys
    success, output = fetch_collection_of_keys
    if success && output.count > 0
      note = ''
      output.sort! { |key1, key2| key1.num_of_days_left <=> key2.num_of_days_left }
      output.each do |key|
        note += key.to_s + "\n"
      end
      return note, output[0].level
    elsif success && output.count == 0
      return 'There are no keys.', 0
    elsif output.nil?
      return 'There are no keys.', 0
    else
      return output, 3
    end
  end
# Return a note and an appropriate alert level after sorting keys using
# their number of days left in ascending order
Return a note and an appropriate alert level after sorting keys using
their number of days left in ascending order
Return a note and an appropriate alert level after sorting keys using their number of days left in ascending order
def sort_keys
    success, output = fetch_collection_of_keys
    if success && output.count > 0
      note = ''
      output.sort! { |key1, key2| key1.num_of_days_left <=> key2.num_of_days_left }
      output.each do |key|
        note += key.to_s + "\n"
      end
      return note, output[0].level
    elsif success && output.count == 0
      return 'There are no keys.', 0
    elsif output.nil?
      return 'There are no keys.', 0
    else
      return output, 3
    end
  end
def sort_keys success , output = fetch_collection_of_keys if success && output . count > 0 note = '' output . sort! { | key1 , key2 | key1 . num_of_days_left <=> key2 . num_of_days_left } output . each do | key | note += key . to_s + "\n" end return note , output [ 0 ] . level elsif success && output . count == 0 return 'There are no keys.' , 0 elsif output . nil? return 'There are no keys.' , 0 else return output , 3 end end
Return a note and an appropriate alert level after sorting keys using
their number of days left in ascending order
Return a note and an appropriate alert level after sorting keys using their number of days left in ascending order