Class: Anvil::Task

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods, Naming, Options
Defined in:
lib/anvil/task.rb,
lib/anvil/task/naming.rb,
lib/anvil/task/options.rb,
lib/anvil/task/callback.rb,
lib/anvil/task/projects.rb,
lib/anvil/task/repositories.rb,
lib/anvil/task/class_methods.rb

Overview

Common class for all tasks

Defined Under Namespace

Modules: ClassMethods, Naming, Options, Projects, Repositories Classes: Callback

Instance Attribute Summary collapse

Attributes included from Options

#parser_block

Instance Method Summary collapse

Methods included from ClassMethods

after, afters, assure, assures, before, befores, descendants

Methods included from Naming

description, from_name, get_namespace, task_name

Methods included from Options

build_parser, configure_parser, help, parse_options!, parser

Constructor Details

#initialize(options = {}) ⇒ Task

Returns a new instance of Task.



17
18
19
# File 'lib/anvil/task.rb', line 17

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



15
16
17
# File 'lib/anvil/task.rb', line 15

def options
  @options
end

Instance Method Details

#loggerObject



33
34
35
# File 'lib/anvil/task.rb', line 33

def logger
  Anvil.logger
end

#runObject?

Runs a task and its callbacks if the assures are OK

Returns:

  • (Object, nil)

    anything the task might return



24
25
26
27
28
29
30
31
# File 'lib/anvil/task.rb', line 24

def run
  return unless run_assures
  run_before_callbacks
  task_return_value = run_task
  run_after_callbacks

  task_return_value
end