Class: CreateGithubRelease::AssertionBase Private
- Inherits:
-
Object
- Object
- CreateGithubRelease::AssertionBase
- Includes:
- BacktickDebug
- Defined in:
- lib/create_github_release/assertion_base.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.
Base class for assertions
All assertions must inherit from this class.
It holds the options and knows how to print, puts and error while respecting the quiet
flag.
Direct Known Subclasses
CreateGithubRelease::Assertions::BundleIsUpToDate, CreateGithubRelease::Assertions::GhAuthenticated, CreateGithubRelease::Assertions::GhCommandExists, CreateGithubRelease::Assertions::GitCommandExists, CreateGithubRelease::Assertions::InGitRepo, CreateGithubRelease::Assertions::InRepoRootDirectory, CreateGithubRelease::Assertions::LastReleaseTagExists, CreateGithubRelease::Assertions::LocalAndRemoteOnSameCommit, CreateGithubRelease::Assertions::LocalReleaseBranchDoesNotExist, CreateGithubRelease::Assertions::LocalReleaseTagDoesNotExist, CreateGithubRelease::Assertions::NoStagedChanges, CreateGithubRelease::Assertions::NoUncommittedChanges, CreateGithubRelease::Assertions::OnDefaultBranch, CreateGithubRelease::Assertions::RemoteReleaseBranchDoesNotExist, CreateGithubRelease::Assertions::RemoteReleaseTagDoesNotExist
Instance Attribute Summary collapse
-
#project ⇒ CreateGithubRelease::Project
readonly
private
The project passed to the assertion object.
Instance Method Summary collapse
-
#assert
private
This method must be overriden by a subclass.
-
#backtick_debug? ⇒ Boolean
private
true
if theproject.verbose?
flag istrue
. -
#error(message)
private
Writes a message to stderr and exits with exitcode 1.
-
#initialize(project) ⇒ AssertionBase
constructor
private
Create a new assertion object and save the given
project
. -
#print(*args)
private
Calls
Kernel.print
if thequiet
flag is not set in theproject
. -
#puts(*args)
private
Calls
Kernel.puts
if thequiet
flag is not set in theproject
.
Methods included from BacktickDebug
Constructor Details
#initialize(project) ⇒ AssertionBase
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.
Create a new assertion object and save the given project
15 16 17 18 19 20 |
# File 'lib/create_github_release/assertion_base.rb', line 15 def initialize(project) raise ArgumentError, 'project must be a CreateGithubRelease::Project' unless project.is_a?(CreateGithubRelease::Project) @project = project end |
Instance Attribute Details
#project ⇒ CreateGithubRelease::Project (readonly)
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.
The project passed to the assertion object
36 37 38 |
# File 'lib/create_github_release/assertion_base.rb', line 36 def project @project end |
Instance Method Details
#assert
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.
This method must be overriden by a subclass
The subclass is expected to call error
if the assertion fails.
29 30 31 |
# File 'lib/create_github_release/assertion_base.rb', line 29 def assert raise NotImplementedError end |
#backtick_debug? ⇒ 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.
true
if the project.verbose?
flag is true
66 67 68 |
# File 'lib/create_github_release/assertion_base.rb', line 66 def backtick_debug? project.verbose? end |
#error(message)
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.
Writes a message to stderr and exits with exitcode 1
58 59 60 61 |
# File 'lib/create_github_release/assertion_base.rb', line 58 def error() warn "ERROR: #{}" exit 1 end |
#print(*args)
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.
Calls Kernel.print
if the quiet
flag is not set in the project
42 43 44 |
# File 'lib/create_github_release/assertion_base.rb', line 42 def print(*args) super unless project.quiet? end |
#puts(*args)
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.
Calls Kernel.puts
if the quiet
flag is not set in the project
50 51 52 |
# File 'lib/create_github_release/assertion_base.rb', line 50 def puts(*args) super unless project.quiet? end |