Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to refactor (?) a long deploy.rb #145

Closed
jrhorn424 opened this issue Sep 19, 2013 · 5 comments
Closed

How to refactor (?) a long deploy.rb #145

jrhorn424 opened this issue Sep 19, 2013 · 5 comments

Comments

@jrhorn424
Copy link

I'd like to split my deploy.rb up into multiple files for maintenance. I've tried the following:

Dir.glob('tasks/*.rb').each { |r| require r }
Dir.glob('tasks/*.rb').each { |r| load r }
Dir.glob('tasks/*.rb').each { |r| import r }

However, if I remove the :environment block into a different file, mina tasks fail silently. What should I do instead?

@mrbrdo
Copy link
Contributor

mrbrdo commented Sep 30, 2013

Did you make it load before the other tasks? Should work.

@jrhorn424
Copy link
Author

I've gone back to just using a long deploy.rb for now. I think the problem was that I had the environment block pulled out into a different file, and the files are loading alphabetically. Thanks for the tip!

@mrbrdo
Copy link
Contributor

mrbrdo commented Sep 30, 2013

Well you'd just have to require the file that contains the environment task explicitly first. When you do the wildcard require it will be skipped since it was already required (just don't do load since that will reload it, and that's not necessary).

@mrbrdo
Copy link
Contributor

mrbrdo commented Sep 30, 2013

PS: And as described in docs http://ruby-doc.org/core-1.9.3/Dir.html#method-c-glob the order is platform-dependent, so you are not guaranteed any specific order.

@jrhorn424
Copy link
Author

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants