Module: Binpkgbot::Tasks
- Defined in:
- lib/binpkgbot/tasks.rb,
lib/binpkgbot/tasks/run.rb,
lib/binpkgbot/tasks/base.rb,
lib/binpkgbot/tasks/include.rb,
lib/binpkgbot/tasks/install.rb,
lib/binpkgbot/tasks/upgrade.rb,
lib/binpkgbot/tasks/concern/emerge.rb
Defined Under Namespace
Modules: Concern
Classes: Base, Include, Install, Run, Upgrade
Class Method Summary
collapse
Class Method Details
.find(name) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/binpkgbot/tasks.rb', line 18
def self.find(name)
const = Binpkgbot::Tasks
prefix = 'binpkgbot/tasks'
retried = false
constant_name = name.to_s.gsub(/\A.|_./) { |s| s[-1].upcase }
begin
const.const_get constant_name, false
rescue NameError
unless retried
begin
require "#{prefix}/#{name}"
rescue LoadError
end
retried = true
retry
end
nil
end
end
|
.from_definition(defi, config: nil) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/binpkgbot/tasks.rb', line 5
def self.from_definition(defi, config: nil)
case defi
when String, Symbol
self.find(defi).new(config: config)
when Hash
raise ArgumentError, "task defiification should not have more than 2 keys when it's a Hash" if defi.size > 1
kind = defi.keys.first
options = defi.values.first
options = {name: options} unless options.kind_of?(Hash)
self.find(kind).new(config: config, **Utils.symbolize_keys(options))
end
end
|