capistrano / rails

Official Ruby on Rails specific tasks for Capistrano
http://www.capistranorb.com/
MIT License
870 stars 269 forks source link

Question about code #173

Closed emad-elsaid closed 8 years ago

emad-elsaid commented 8 years ago

Hello,

this is not an issue, it's just a question, why are we using load instead if require_relative in this project?

https://github.com/capistrano/rails/blob/master/lib/capistrano/tasks/migrations.rake#L1

mattbrictson commented 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

emad-elsaid commented 8 years ago

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.