This a simple extension in dev source reloader, I used in my extension dev env.
It can automatic reload the extension source files after you change and saved.
I use UI.start_timer(2, true) to start a loop backend worker, and ::File.stat(file) to find all files in $LOADED_FEATURES、$LOAD_PATH whoes mtime changed.
(1) Extensions should not use global variables ($reloader_timer_id.)
Use a class or module variable instead. (Like: @@reloader_timer_id)
(2) It is rather heavy-handed to be checking every file in $LOADED_FEATURES every 2 seconds for a new mod time. I would suggest finding a way to only check the extension files under development.
Yes, it’s my mistake, I will change it to module variable later.
And,
It’s difficult to determine a extension is still under development or not.
In my development env, I place the extensions codes in my work directory such as ‘~/work/su_dev/**’ and
use thomthom 's Extension Sources to load them to SU.
And someone may directly place the extension files(under development) in the plugins directory.
And someone may create a ruby file(eg. 0.dev.rb) in the SU plugins directory, add extension entry file to $LOAD_PATH, such as
So, I find it difficult to determine which extension is still under development. I will continue to seek a better way to handle it, although the current mechanism can still operate normally.
Very impressed!
I have also created a tool similar to yours to aid me in my plugin development work. My approach is slightly different, as I have added a feature that allows me to add specific files or directories to the watch list. This makes it easier for me to manage and monitor only the necessary files or directories.
Don’t modify the ‘$LOAD_PATH’. Doing so may cause other extensions to load the wrong files. Instead include your extension support folder in the path whenever you load a file.