Class: Semverify::CommandLine Private

Inherits:
Thor
  • Object
show all
Defined in:
lib/semverify/command_line.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The semverify cli

Examples:

require 'semverify'

Semverify::CommandLine.start(ARGV)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Tell Thor to exit with a non-zero status code if a command fails

Returns:

  • (Boolean)


19
# File 'lib/semverify/command_line.rb', line 19

def self.exit_on_failure? = true

Instance Method Details

#current

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Show the current gem version



35
36
37
38
39
40
41
42
43
44
# File 'lib/semverify/command_line.rb', line 35

def current
  version_file = Semverify::VersionFileFactory.find

  if version_file.nil?
    warn 'version file not found or is not valid' unless options[:quiet]
    exit 1
  end

  puts version_file.version unless options[:quiet]
end

#file

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Show the gem's version file



60
61
62
63
64
65
66
67
68
69
# File 'lib/semverify/command_line.rb', line 60

def file
  version_file = Semverify::VersionFileFactory.find

  if version_file.nil?
    warn 'version file not found or is not valid' unless options[:quiet]
    exit 1
  end

  puts version_file.path unless options[:quiet]
end

#next_major(version = nil)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Increment the gem version's major part

Parameters:

  • version (String, nil) (defaults to: nil)

    The version to increment or nil to use the version from the gem's version file



126
127
128
# File 'lib/semverify/command_line.rb', line 126

def next_major(version = nil)
  increment_core_version(:next_major, version)
end

#next_minor(version = nil)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Increment the gem version's minor part

Parameters:

  • version (String, nil) (defaults to: nil)

    The version to increment or nil to use the version from the gem's version file



185
186
187
# File 'lib/semverify/command_line.rb', line 185

def next_minor(version = nil)
  increment_core_version(:next_minor, version)
end

#next_patch(version = nil)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Increment the gem version's patch part

Parameters:

  • version (String, nil) (defaults to: nil)

    The version to increment or nil to use the version from the gem's version file



244
245
246
# File 'lib/semverify/command_line.rb', line 244

def next_patch(version = nil)
  increment_core_version(:next_patch, version)
end

#next_pre(version = nil)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Increment the gem version's pre-release part

Parameters:

  • version (String, nil) (defaults to: nil)

    The version to increment or nil to use the version from the gem's version file



309
310
311
312
313
314
315
316
317
# File 'lib/semverify/command_line.rb', line 309

def next_pre(version = nil)
  args = {}
  args[:pre_type] = options[:'pre-type'] if options[:'pre-type']
  args[:build_metadata] = options[:build] if options[:build]

  new_version = increment_version(:next_pre, args, version)

  puts new_version unless options[:quiet]
end

#next_release(version = nil)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Increment the gem's pre-release version to a release version

Parameters:

  • version (String, nil) (defaults to: nil)

    The version to increment or nil to use the version from the gem's version file



352
353
354
355
356
357
358
359
# File 'lib/semverify/command_line.rb', line 352

def next_release(version = nil)
  args = {}
  args[:build_metadata] = options[:build] if options[:build]

  new_version = increment_version(:next_release, args, version)

  puts new_version unless options[:quiet]
end

#validate(version)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Validate that the give version is a valid IncrementableSemver version

Parameters:

  • version (String)

    The version to validate



377
378
379
380
381
382
383
384
# File 'lib/semverify/command_line.rb', line 377

def validate(version)
  Semverify::IncrementableSemver.new(version)
rescue Semverify::Error => e
  warn e.message unless options[:quiet]
  exit 1
else
  puts version unless options[:quiet]
end