Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to require for the second time

Tags:

Is there a way to force require-ing of a file for the second time?

I am writing a library that is located in a path for Ruby. I am editing the file while doing a simple test of it in IRB.

Each time I make a change to the file, I want to reload it without ending the IRB session. Using load requires typing the whole path to the file each time, and restarting IRB each time requires me to type all the other variable settings required for the simple test.

I just want something like require but that allows loading for the second time. Is there a simple way to do it?

like image 255
sawa Avatar asked Apr 24 '12 20:04

sawa


Video Answer


2 Answers

load does not require (hmm) a full path. It expects a complete filename with an extension.

p load 'date.rb' #=> true p load 'date.rb' #=> true p load 'date'    #=> LoadError 
like image 179
steenslag Avatar answered Sep 22 '22 12:09

steenslag


:000> path = "extremely/long/path/to/my/file" :001> load path :002> load path 
like image 43
Francisco Soto Avatar answered Sep 18 '22 12:09

Francisco Soto