class Cult::Task

Attributes

name[R]
path[R]
role[R]

Public Class Methods

all_for_role(project, role) click to toggle source
# File lib/cult/task.rb, line 44
def self.all_for_role(project, role)
  fail ArgumentError if block_given?

  Dir.glob(File.join(role.path, "tasks", "*")).sort.map do |path|
    spawn(role, path)
  end.compact.to_named_array
end
collection_name() click to toggle source
# File lib/cult/task.rb, line 17
def self.collection_name
  "tasks"
end
new(role, path) click to toggle source
# File lib/cult/task.rb, line 10
def initialize(role, path)
  @role = role
  @path = path
  @name = File.basename(path)
end
spawn(role, path) click to toggle source
# File lib/cult/task.rb, line 34
def self.spawn(role, path)
  [BuildTask, EventTask].each do |task_cls|
    if task_cls.valid_name?(File.basename(path))
      return task_cls.new(role, path)
    end
  end
  nil
end

Public Instance Methods

file_mode() click to toggle source

Task files are executable by anyone: this makes re-exec'ing tasks as another user trivial.

Calls superclass method Cult::Transferable#file_mode
# File lib/cult/task.rb, line 29
def file_mode
  super | 0111
end
relative_path() click to toggle source
# File lib/cult/task.rb, line 22
def relative_path
  File.basename(path)
end