Closed emad-elsaid closed 8 years ago
In Ruby, require
and require_relative
only work with files ending with .rb
(or compiled libraries ending with .so
, .o
, or .dll
). Thus for files ending with .rake
, we have no choice but to use load
.
As to why we use .rake
files to define Rake tasks, rather than putting the same code in a .rb
file: I'm not sure. This is a convention established a long time ago and is used by Capistrano itself and pretty much every Capistrano plugin I've ever come across. Perhaps this is a convention inherited from Rake (Capistrano is built on Rake).
I am trying to change that convention by introducing a more formal Capistrano plugin system that uses plain Ruby classes instead of .rake
stuff. I think it will help make plugins more predictable and Ruby-like. We'll see if it catches on.
https://github.com/capistrano/capistrano/blob/v3.5.0/lib/capistrano/plugin.rb
Thank you, that explained it, I was asking because i'm going to make a plugin for docker compose (originally part of a side project and wanted to release it as separate gem) and wanted to follow the same convention.
Hello,
this is not an issue, it's just a question, why are we using
load
instead ifrequire_relative
in this project?https://github.com/capistrano/rails/blob/master/lib/capistrano/tasks/migrations.rake#L1