I tested ActiveRuby automation with the new beta2, and now ruby runs fine, but there are 2 things that are bizarre:
1. The file that is executed is not the file itself, but a copy in the temp folder, typically named something like 'RSCC430.tmp.rb'. This prevents knowing the name of the executed file, which is a problem if for instance you want to use it to display messages to the user.
2. The ruby interpreter is kept running between calls to scripts. In my opinion, this is not viable: you must start "fresh" for each new script, otherwise the constants defined in one script will collide with the ones defined in another script. It also requires restarting salamander after each error, which makes debugging a nightmare.
To check point 1: run this script:
To check point 2, first run this script (say 'a.rb')require 'win32ole'
Salamander.MsgBox(__FILE__, 0, "Ruby")
It displays two non-standard constants, "ActiveRubyScript" and "Salamander", which is fine.require 'win32ole'
# standard Ruby constants:
base_constants = %w(
ARGF ARGV ArgumentError Array Bignum Binding CROSS_COMPILING Class Comparable ConditionVariable Config Continuation
Data Date DateTime Dir ENV EOFError Enumerable Errno Etc Exception FALSE FalseClass File FileTest Fixnum Float
FloatDomainError GC Gem Hash IO IOError IndexError Integer Interrupt Kernel LoadError LocalJumpError Marshal
MatchData MatchingData Math Method Module Mutex NIL NameError NilClass NoMemoryError NoMethodError
NotImplementedError Numeric Object ObjectSpace PLATFORM Precision Proc Process Queue RELEASE_DATE RUBY_COPYRIGHT
RUBY_DESCRIPTION RUBY_PATCHLEVEL RUBY_PLATFORM RUBY_RELEASE_DATE RUBY_VERSION Range RangeError Rational RbConfig
Regexp RegexpError RuntimeError STDERR STDIN STDOUT ScriptError SecurityError Signal SignalException SizedQueue
StandardError StopIteration String StringIO Struct Symbol SyntaxError SystemCallError SystemExit SystemStackError
TOPLEVEL_BINDING TRUE Thread ThreadError ThreadGroup Time TrueClass TypeError UnboundMethod VERSION Win32API YAML
ZeroDivisionError
)
# list all constants defined (not the win32ole ones):
diff = Module.constants.sort - base_constants
diff.reject! { |c| c =~ /^WIN32OLE/ }
Salamander.MsgBox(diff.inspect, 0, "Ruby")
Now run this script (say 'b.rb')
It now displays in addition the constant "Test", corresponding to the class defined.require 'win32ole'
# standard Ruby constants:
base_constants = %w(
ARGF ARGV ArgumentError Array Bignum Binding CROSS_COMPILING Class Comparable ConditionVariable Config Continuation
Data Date DateTime Dir ENV EOFError Enumerable Errno Etc Exception FALSE FalseClass File FileTest Fixnum Float
FloatDomainError GC Gem Hash IO IOError IndexError Integer Interrupt Kernel LoadError LocalJumpError Marshal
MatchData MatchingData Math Method Module Mutex NIL NameError NilClass NoMemoryError NoMethodError
NotImplementedError Numeric Object ObjectSpace PLATFORM Precision Proc Process Queue RELEASE_DATE RUBY_COPYRIGHT
RUBY_DESCRIPTION RUBY_PATCHLEVEL RUBY_PLATFORM RUBY_RELEASE_DATE RUBY_VERSION Range RangeError Rational RbConfig
Regexp RegexpError RuntimeError STDERR STDIN STDOUT ScriptError SecurityError Signal SignalException SizedQueue
StandardError StopIteration String StringIO Struct Symbol SyntaxError SystemCallError SystemExit SystemStackError
TOPLEVEL_BINDING TRUE Thread ThreadError ThreadGroup Time TrueClass TypeError UnboundMethod VERSION Win32API YAML
ZeroDivisionError
)
# define a new constant
class Test
end
# list all constants defined (not the win32ole ones):
diff = Module.constants.sort - base_constants
diff.reject! { |c| c =~ /^WIN32OLE/ }
Salamander.MsgBox(diff.inspect, 0, "Ruby")
Now re-run 'a.rb': "Test" is still there, which is abnormal.
If you want, I can participate into the tests before the release of the final Salamander, as I suspect there are not that many people that are scripting Salamander with Ruby, and other problems like this may surface...
Cheers
-- Thierry