class Sicily::TaskLoader
Public Instance Methods
load_all_tasks()
click to toggle source
# File lib/sicily/task_loader.rb, line 5 def load_all_tasks list_all_files.each do |file| require file include_module_if_exists(file) end end
Private Instance Methods
camelize(str)
click to toggle source
# File lib/sicily/task_loader.rb, line 36 def camelize(str) str.split('_').map(&:capitalize).join end
guess_module(file)
click to toggle source
# File lib/sicily/task_loader.rb, line 27 def guess_module(file) module_name = camelize(File.basename(file, '.*')) Task.const_get(module_name) end
include_module_if_exists(file)
click to toggle source
# File lib/sicily/task_loader.rb, line 14 def include_module_if_exists(file) maybe_module = guess_module(file) include_the_module(maybe_module) if really_module?(maybe_module) end
include_the_module(maybe_module)
click to toggle source
# File lib/sicily/task_loader.rb, line 19 def include_the_module(maybe_module) FileProcessor.send(:include, maybe_module) end
list_all_files()
click to toggle source
# File lib/sicily/task_loader.rb, line 32 def list_all_files Dir["#{Sicily.lib_path}/sicily/task/*.rb"] end
really_module?(maybe_module)
click to toggle source
# File lib/sicily/task_loader.rb, line 23 def really_module?(maybe_module) maybe_module.class.name == 'Module' end