Class: SemverDialects::Commands::CheckVersion
- Inherits:
-
SemverDialects::Command
- Object
- SemverDialects::Command
- SemverDialects::Commands::CheckVersion
- Defined in:
- lib/semver_dialects/commands/check_version.rb
Overview
The check version command implementation
Instance Method Summary collapse
- #execute(_input: $stdin, output: $stdout) ⇒ Object
-
#initialize(type, version, constraint, options) ⇒ CheckVersion
constructor
A new instance of CheckVersion.
Methods inherited from SemverDialects::Command
#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which
Constructor Details
#initialize(type, version, constraint, options) ⇒ CheckVersion
Returns a new instance of CheckVersion.
13 14 15 16 17 18 19 |
# File 'lib/semver_dialects/commands/check_version.rb', line 13 def initialize(type, version, constraint, ) @type = type @version = version @constraint = constraint = @avail_types = %w[gem npm ruby pypi php maven go] end |
Instance Method Details
#execute(_input: $stdin, output: $stdout) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 |