Class: RemindMe::Reminder::GemVersionReminder

Inherits:
BaseReminder
  • Object
show all
Includes:
Utils::Versions
Defined in:
lib/remind_me/reminder/gem_version_reminder.rb

Constant Summary

Constants included from Utils::Versions

Utils::Versions::INSTALLED_GEMS

Instance Attribute Summary

Attributes inherited from BaseReminder

#reminder_comment_ast, #source_location

Instance Method Summary collapse

Methods included from Utils::Versions

#compare_version_numbers, #condition_comparators, #gem_installed?, #gem_version, #invalid_condition_message, #valid_condition?, #valid_version_string?

Methods inherited from BaseReminder

inherited, #inspect, #message

Methods included from Utils::HashASTManipulations

#apply_to_hash_with, #ast_hash_pair, #children_of_type, #create_hash_value_accessor_method, #create_reminder_from_ast, #hash_ast_pair_value, #hash_ast_pair_value_type, #key_present?, #singleton_method_defined?, #valid_hash_ast_key?, #valid_hash_ast_value?, #validate_hash_ast

Instance Method Details

#conditions_met?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/remind_me/reminder/gem_version_reminder.rb', line 19

def conditions_met?
  target_version = hash_version
  # if no version is specified, look for any version
  if target_version.nil? || target_version.empty?
    gem_installed?(hash_gem)
  else
    return false unless INSTALLED_GEMS[hash_gem]

    condition = hash_condition
    target_gem_version = Gem::Version.new(target_version)
    installed_gem_version = INSTALLED_GEMS[hash_gem]
    compare_version_numbers(target_gem_version, installed_gem_version, condition.to_sym)
  end
end

#validation_errorsObject



34
35
36
37
38
39
40
# File 'lib/remind_me/reminder/gem_version_reminder.rb', line 34

def validation_errors
  errors = super
  errors << gem_missing_message unless gem_installed?(hash_gem)
  errors << invalid_condition_message(source_location, hash_condition) unless valid_condition?(hash_condition)
  errors << malformed_version_string_message unless valid_version_string?(hash_version)
  errors
end