Class: Shanty::TaskSet

Inherits:
Object
  • Object
show all
Defined in:
lib/shanty/task_set.rb

Overview

Public: Discover shanty tasks

Direct Known Subclasses

BasicTasks

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.partial_taskObject (readonly)

Returns the value of attribute partial_task.



5
6
7
# File 'lib/shanty/task_set.rb', line 5

def partial_task
  @partial_task
end

.task_setsObject (readonly)

Returns the value of attribute task_sets.



5
6
7
# File 'lib/shanty/task_set.rb', line 5

def task_sets
  @task_sets
end

.tasksObject (readonly)

Returns the value of attribute tasks.



5
6
7
# File 'lib/shanty/task_set.rb', line 5

def tasks
  @tasks
end

Class Method Details

.desc(syntax, desc) ⇒ Object



16
17
18
19
# File 'lib/shanty/task_set.rb', line 16

def self.desc(syntax, desc)
  partial_task[:syntax] = syntax
  partial_task[:desc] = desc
end

.inherited(task_set) ⇒ Object

This method is auto-triggered by Ruby whenever a class inherits from Shanty::TaskSet. This means we can build up a list of all the tasks without requiring them to register with us - neat!



11
12
13
14
# File 'lib/shanty/task_set.rb', line 11

def self.inherited(task_set)
  @task_sets ||= []
  @task_sets << task_set
end

.method_added(name) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/shanty/task_set.rb', line 29

def self.method_added(name)
  @tasks ||= {}
  @tasks[name] = partial_task.merge(klass: self)

  # Now reset the task definition.
  @partial_task = {}
end

.option(name, options = {}) ⇒ Object



25
26
27
# File 'lib/shanty/task_set.rb', line 25

def self.option(name, options = {})
  partial_task[:options][name] = options
end

.param(name, options = {}) ⇒ Object



21
22
23
# File 'lib/shanty/task_set.rb', line 21

def self.param(name, options = {})
  partial_task[:params][name] = options
end