Class: CreateGithubRelease::AssertionBase Private

Inherits:
Object
  • Object
show all
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.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Parameters:

Raises:

  • (ArgumentError)


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

#projectCreateGithubRelease::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

Returns:



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.

Raises:

  • (NotImplementedError)


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

Returns:

  • (Boolean)


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

Parameters:

  • message (String)

    the message to write to stderr



58
59
60
61
# File 'lib/create_github_release/assertion_base.rb', line 58

def error(message)
  warn "ERROR: #{message}"
  exit 1
end

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

Parameters:

  • args (Array)

    the arguments to pass to Kernel.print



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

Parameters:

  • args (Array)

    the arguments to pass to Kernel.puts



50
51
52
# File 'lib/create_github_release/assertion_base.rb', line 50

def puts(*args)
  super unless project.quiet?
end