1

I am looking for suggestions/resources/ways to manage external dependencies of a rails project apart from ruby games (which bundler does just perfect). For example, I want to add checks to see if things like

  1. Some external binaries (e.g. gdal, python etc etc..)
  2. Some environment variables are set or not (like aws access keys.. etc.. )
  3. Is it christmas today!?

And some more.

One things that comes to mind is would be good if these checks can be added to bundler and show error message if some other user defined project dependencies are missing or not. I not looking for version management or anything fancy. Just add some custom code checks to see all dependencies (apart from gems of course) are met.

Or is there a better way people are doing it? using unit tests may be? what if a beginner doesn't know to run unit tests?

Reason I ask this question is, for example me as a somewhat experienced rails developer wants to work with someone just starting out. I want to make project installation and setup easy and make errors verbose if any.

suggestions and links to good resources welcome.

UPDATE

Is there an "elegant" way to add some hooks to bundler? say make it run some unit tests from the tests or something ?

Also I am not necessarily looking for this check to also install those external dependencies. Just check them and if the check fails show a user friendly message and hint at how they can be installed.

simple example code would be awesome..

Shaunak
  • 17,377
  • 5
  • 53
  • 84
  • Cannot back it up with a whole answer, but I would definitely add a covering test that checked the environment. If you are working with someone inexperienced enough that they do not know how to run tests, then lesson 1 is "How to run the tests". – Neil Slater Jan 19 '14 at 08:33
  • why do you wsh to avoid *bundler*? – Малъ Скрылевъ Jan 19 '14 at 17:26
  • @NeilSlater I already have test cases covering the environment. But my thinking was "bundle install" is indeed the first thing you do. It would be awesome if we could run some more dependency checks along with it.. – Shaunak Jan 19 '14 at 18:06
  • @majioa never said I want to avoid bundler, just want to check some more dependencies besides gems – Shaunak Jan 19 '14 at 18:15
  • ok, just put the gem controlling dependencies to *bunlder*, and add a rake task for example *`install`*, which will control extended dependencies you wish, including `bundler install` function. – Малъ Скрылевъ Jan 19 '14 at 18:19
  • The dependencies are not really gems. They are some other external binaries, configurations etc. that application depends on to run background tasks. If you meant to add gems to check those dependencies can you please elaborate a little on that? Also please check the two points I just added to update, if that makes it clearer. thanks! – Shaunak Jan 19 '14 at 18:21
  • Under majioa's setup, you'd run a custom rake task instead of `bundle install`. The custom task would check for external dependencies and then invoke `bundle install` for you. Basically, your team would be running `rake custom:install` instead of `bundle install`. – Jimeux Jan 22 '14 at 05:53

1 Answers1

1

majioa's suggestion of using a rake task makes sense. You'll need to run shell commands somehow, and rake allows you to integrate them into your Rails app more naturally.

I'm not sure how you hook into bundle, but it's possible to hook into Rails' rake tasks (see this answer). db:create or db:migrate are common initial tasks that you could hook into. See this post as a starting point for learning rake.

Still, setting up machines seems like something that should be considered separately from the app itself. Have you looked into Chef before?

Community
  • 1
  • 1
Jimeux
  • 2,956
  • 1
  • 18
  • 14
  • thanks for the answer Jim, Yes I have looked into Chef, only I feel it will be an overkill to use it just for checking couple of these OS dependencies. Creating rake tasks now makes more sense with links in your answer. Just have to figure out how to execute them after bundler. because i still feel that's the easiest way to catch those errors if the dependencies are not met. – Shaunak Jan 22 '14 at 15:16