Class: Tap::Tasks::Signal

Inherits:
Tap::Task show all
Defined in:
lib/tap/tasks/signal.rb

Overview

::task signal via a task

Instance Attribute Summary collapse

Attributes inherited from Tap::Task

#joins

Attributes inherited from App::Api

#app

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tap::Task

#associations, #call, #enq, #exe, #log, #on_complete, parser

Methods inherited from App::Api

#associations, help, inherited, #inspect, parse, parse!, parser

Methods included from Signals

#signal, #signal?, #signals

Methods included from Signals::ModuleMethods

included

Constructor Details

#initialize(sig, config = {}, app = Tap::App.current) ⇒ Signal

Returns a new instance of Signal.



26
27
28
29
# File 'lib/tap/tasks/signal.rb', line 26

def initialize(sig, config={}, app=Tap::App.current)
  super(config, app)
  @sig = sig
end

Instance Attribute Details

#sigObject

Returns the value of attribute sig.



24
25
26
# File 'lib/tap/tasks/signal.rb', line 24

def sig
  @sig
end

Class Method Details

.build(spec = {}, app = Tap::App.current) ⇒ Object



8
9
10
# File 'lib/tap/tasks/signal.rb', line 8

def build(spec={}, app=Tap::App.current)
  new(spec['sig'], spec['config'], app)
end

.convert_to_spec(parser, args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/tap/tasks/signal.rb', line 12

def convert_to_spec(parser, args)
  if args.empty?
    raise "no signal specified"
  end
  
  {
    'config' => parser.nested_config,
    'sig'  => args.shift
  }
end

Instance Method Details

#process(*args) ⇒ Object



31
32
33
# File 'lib/tap/tasks/signal.rb', line 31

def process(*args)
  app.signal(sig).call(args)
end

#to_specObject



35
36
37
38
39
# File 'lib/tap/tasks/signal.rb', line 35

def to_spec
  spec = super
  spec['sig'] = sig
  spec
end