Functions in 'require' are not updated till restart..
-
Dear Forum,
I am developing a ruby script for shading calculations to integrate with my CFD analysis.
I have a few functions within an external file (not in a module) that I include in the main code with 'require'.
It has been working fine for the last few weeks, but a couple of days ago, I noticed that if I made a change in one of these external functions, these changes were not 'seen' until I restarted skethcup. The function worked once copied directly in the main script and I confirmed that the file was actually saved.
Is there any specific directive that I have to use at the beginning of the main ruby script? Is it a name space issue? I will keep testing, but it would be good to understand what it is actually happening.
This is what I have at the beginning of my code
require 'sketchup.rb'
require 'r/ReadMesh.rb'
#require 'r/ReadCSVMesh.rb'
require 'yaml'
require 'csv'
require 'r/readCSV'
include MathReadCSVMesh is the function incriminated...
Thanks a lot
-
requirewill ensure that a file is loaded only once. It will not update automatically. If you need to reload while developing you can reload the file using the Ruby console and theloadmethod. -
Thanks. Trying to make my head around modules. I am not planning to write plugins for distribution, I am just trying to keep my code cleaner.
Cheers
-
You should NOT be including ANY module like
Mathinto the global objectspace, which is actually classObject. Everyone else's classes and modules will then inherit any change YOU make to the global objectspace!It does not matter whether you will be distributing or not. There is a right way to code.
It is more about not corrupting other people's plugins.There is NO reason whatever for you to run code outside YOUR OWN module namespace.
So pick a unique toplevel module name, likeGuidaorRGor whatever, and then define ALL your plugins as sub-modules of YOUR toplevel modulespace. Within each plugin module, define nested modules and / or classes, as needed by each plugin.
Advertisement