Class: Moku::TaskFile

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/moku/task_file.rb

Overview

A list of tasks encoded in a file.

Defined Under Namespace

Classes: TaskSpec

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_tasks) ⇒ TaskFile

Returns a new instance of TaskFile.


23
24
25
# File 'lib/moku/task_file.rb', line 23

def initialize(raw_tasks)
  @raw_tasks = [raw_tasks].flatten.compact
end

Class Method Details

.from_path(path) ⇒ Object


14
15
16
17
18
19
20
21
# File 'lib/moku/task_file.rb', line 14

def self.from_path(path)
  raw_tasks = if path.exist?
    YAML.safe_load(File.read(path)) || []
  else
    []
  end
  new(raw_tasks)
end

Instance Method Details

#eachObject


27
28
29
# File 'lib/moku/task_file.rb', line 27

def each
  tasks.each {|task| yield(task) }
end