Module: TaskLoader

Extended by:
Capistrano::Ops::Helper
Defined in:
lib/capistrano/ops/task_loader.rb

Class Method Summary collapse

Methods included from Capistrano::Ops::Helper

gem_in_gemfile?

Class Method Details

.load_tasks_if_gem_present(gem_name, task_path, warning_message) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/capistrano/ops/task_loader.rb', line 8

def self.load_tasks_if_gem_present(gem_name, task_path, warning_message)
  unless gem_in_gemfile?(gem_name)
    warn warning_message
    return
  end

  base_path = File.expand_path(__dir__)
  task_files = Dir.glob("#{base_path}/#{task_path}/**/*.rake")

  task_files.each do |file|
    load file
  rescue StandardError => e
    puts "Failed to load #{file}: #{e.message}"
  end
end