class SemverDialects::Commands::CheckVersion

The check version command implementation

Public Class Methods

new(type, version, constraint, options) click to toggle source
# File lib/semver_dialects/commands/check_version.rb, line 13
def initialize(type, version, constraint, options)
  @type = type
  @version = version
  @constraint = constraint
  @options = options
  @avail_types = %w[gem npm ruby pypi php maven go]
end

Public Instance Methods

execute(_input: $stdin, output: $stdout) click to toggle source
# File lib/semver_dialects/commands/check_version.rb, line 21
def execute(_input: $stdin, output: $stdout)
  typ = @type.downcase
  raise SemverDialects::Error, 'wrong package type' unless @avail_types.include?(typ)

  if VersionChecker.version_sat?(typ, @version, @constraint)
    output.puts "#{@version} matches #{@constraint} for #{@type}"
    0
  else
    output.puts "#{@version} does not match #{@constraint}"
    1
  end
end