iruby icon indicating copy to clipboard operation
iruby copied to clipboard

Requiring configurations and helper methods

Open dansbits opened this issue 9 years ago • 3 comments

I've tried looking through the documentation so I apologize if I've missed this somewhere.

Is the any way to include some code which gets required for all iRuby notebooks? It would be useful to be able to add some data access methods and load some secrets (like database credentials) to be available globally and not have to require them in every notebook.

Thanks!

dansbits avatar Feb 23 '16 14:02 dansbits

Interesting use case. Don't think it's available as of now.

@domitry maybe we can some file called iruby_on_boot.rb which is run every time a new notebook is created? User can edit this file and keep it in some pre defined directory and iruby will run it before starting a notebook.

v0dro avatar Feb 24 '16 15:02 v0dro

@v0dro Thanks for the reply. That sounds perfect to me. I'm happy to help out but wasn't sure where to start. Any thoughts on where in the code base this would go?

dansbits avatar Mar 01 '16 18:03 dansbits

When IRB.setup is called, will it load any .irbrc file? That way we can satisfy the use case discussed above by putting ruby code in the config file.

Ref: https://docs.ruby-lang.org/en/master/IRB.html#module-IRB-label-Configuration+File

pool2win avatar Mar 08 '24 19:03 pool2win