Class: CreateGithubRelease::TaskBase Private

Inherits:
Object
  • Object
show all
Includes:
BacktickDebug
Defined in:
lib/create_github_release/task_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 tasks

All tasks 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) ⇒ TaskBase

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 tasks object and save the given project

Parameters:

Raises:

  • (ArgumentError)


15
16
17
18
19
20
# File 'lib/create_github_release/task_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 task object



38
39
40
# File 'lib/create_github_release/task_base.rb', line 38

def project
  @project
end

Instance Method Details

#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)


68
69
70
# File 'lib/create_github_release/task_base.rb', line 68

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



60
61
62
63
# File 'lib/create_github_release/task_base.rb', line 60

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 options

Parameters:

  • args (Array)

    the arguments to pass to Kernel.print



44
45
46
# File 'lib/create_github_release/task_base.rb', line 44

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



52
53
54
# File 'lib/create_github_release/task_base.rb', line 52

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

#run

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 task fails.

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/create_github_release/task_base.rb', line 29

def run
  raise NotImplementedError
end