I want to get the constants defined in my scripts, suppose I have two files like this:
TWO = 'this is 2'
ONE = 'this is 1'
# Check for constants
This is tricky because not having a class your are putting your constants onto the main:Object when you run your script. So you need to be able to know what constants are defined before the script executes. Something like this would work:
#script_one.rb obj_cons = Object.constants require_relative 'script_two' ONE = 'this is 1' puts self.class.constants - obj_cons
That generates the array: [TWO, ONE] -- which I believe is what you want.
$ ruby script_one.rb TWO ONE