Class: Mona::Task::Manager
- Inherits:
-
Object
- Object
- Mona::Task::Manager
- Includes:
- Deps[ packages_repo: "package.repo" ], Mixins
- Defined in:
- lib/mona/task/manager.rb
Constant Summary collapse
Instance Method Summary collapse
Methods included from Mixins
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, **kwargs) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mona/task/manager.rb', line 18 def method_missing(method_name, *args, **kwargs) task = Mona.current_project.tasks.detect { _1.name == method_name } || (raise StandardError.new("task '#{method_name}' not found for project")) case task.on when :package statuses = kwargs[:packages].inject({}) do |result, package_name| package = packages_repo.find!(package_name.to_sym) result[package.name] = task.block.call(package, kwargs[:args]) result end failed_packages = statuses.reject {|package_name, exitstatus| exitstatus == 0} failed_packages.any? ? false : true else raise StandardError.new("unsupported task subject: #{task.on}") end end |