module Checky::Validators::Version

Public Class Methods

version_string() click to toggle source
# File lib/checky/validators/version.rb, line 11
def version_string
  command_path = storage.binary
  command_output = Checky.run("#{command_path} --version 2>&1").presence ||
                   Checky.run("#{command_path} -v 2>&1").presence
  command_output[/[0-9]+(?:\.[0-9]+)+/]
end

Public Instance Methods

check() click to toggle source
# File lib/checky/validators/version.rb, line 5
def check
  version = Gem::Version.new(version_string)
  requirement = Gem::Requirement.new(storage.version)
  requirement.satisfied_by?(version)
end
message() click to toggle source
# File lib/checky/validators/version.rb, line 18
def message
  "Checking #{storage.binary} version against #{storage.version}"
end

Private Instance Methods

version_string() click to toggle source
# File lib/checky/validators/version.rb, line 11
def version_string
  command_path = storage.binary
  command_output = Checky.run("#{command_path} --version 2>&1").presence ||
                   Checky.run("#{command_path} -v 2>&1").presence
  command_output[/[0-9]+(?:\.[0-9]+)+/]
end