Class: Binpkgbot::Tasks::Include

Inherits:
Base
  • Object
show all
Defined in:
lib/binpkgbot/tasks/include.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #options

Instance Method Summary collapse

Methods inherited from Base

#execute, #initialize

Constructor Details

This class inherits a constructor from Binpkgbot::Tasks::Base

Instance Method Details

#runObject

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/binpkgbot/tasks/include.rb', line 7

def run
  name = @options[:name]
  raise ArgumentError, "include task is missing :name -- what to include?" unless name
  Dir.glob[name].sort.each do |path|
    yaml = YAML.load_file(path)
    if yaml.kind_of?(Array)
      raise ArgumentError, "#{path} should be an array of task definitions"
    end
    yaml.each do |task_def|
      Tasks.from_definition(task_def, config: @config).execute
    end
  end
end