Class: CreateGithubRelease::CommandLine::Validations::ValidatePreType Private

Inherits:
Base
  • Object
show all
Defined in:
lib/create_github_release/command_line/validations.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.

Validate if pre_type is nil or releast_type is 'pre' or the pre flag is set

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from CreateGithubRelease::CommandLine::Validations::Base

Instance Method Details

#errorString+

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.

Called when valid? is false to return the error messages

Returns:

  • (String, Array<String>)


106
107
108
109
110
111
112
# File 'lib/create_github_release/command_line/validations.rb', line 106

def error
  if %w[major minor patch pre].include?(options.release_type)
    '--pre must be given when --pre-type is given'
  else
    '--pre-type can only be given with a release type of major, minor, patch, or pre'
  end
end

#valid?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.

Returns true if valid

Returns:

  • (Boolean)


97
98
99
100
101
# File 'lib/create_github_release/command_line/validations.rb', line 97

def valid?
  options.pre_type.nil? ||
    options.release_type == 'pre' ||
    (%w[major minor patch].include?(options.release_type) && options.pre == true)
end