Automation Plugin: ActiveRuby

Discussion of bugs and problems found in Altap Salamander. In your reports, please be as descriptive as possible, and report one incident per report. Do not post crash reports here, send us the generated bug report by email instead, please.
Thierry
Posts: 28
Joined: 28 Apr 2006, 10:35
Location: Paris, France
Contact:

Automation Plugin: ActiveRuby

Post by Thierry »

Hi,
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:
require 'win32ole'
Salamander.MsgBox(__FILE__, 0, "Ruby")
To check point 2, first run this script (say 'a.rb')
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")
It displays two non-standard constants, "ActiveRubyScript" and "Salamander", which is fine.
Now run this script (say 'b.rb')
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")
It now displays in addition the constant "Test", corresponding to the class defined.
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
manison
Plugin Developer
Plugin Developer
Posts: 216
Joined: 09 Dec 2005, 23:23
Location: Ceske Budejovice, Czech Republic
Contact:

Re: Automation Plugin: ActiveRuby

Post by manison »

Hello Thierry, thanks for the feedback. Unfortunately the ActiveRuby engine is quite buggy.
Thierry wrote: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.
This is bug (or maybe feature) in the ActiveRuby scripting engine and there is nothing I can do against it. You should maybe report this to the ActiveRuby developers. Try running the following script file.rb

Code: Select all

WScript.Echo(__FILE__)
under the Microsoft Script Host

Code: Select all

cscript.exe file.rb
You will see the same behavior.
Thierry wrote: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.
I am aware of this problem. This is because the ActiveRuby engine fails to exit. It also affects the Windows Script Host, however the WSH terminates when the script ends so this issue is not visible. This is not the case of Salamander that must stay running after the script ends. I will try to find some workaround (as I did for PHP), but please note that this is very time consuming and we must not break compatibility with 1st class citizens (JScript, VBScript) and therefore this is low priority.
manison
Plugin Developer
Plugin Developer
Posts: 216
Joined: 09 Dec 2005, 23:23
Location: Ceske Budejovice, Czech Republic
Contact:

Re: Automation Plugin: ActiveRuby

Post by manison »

Additional note to the script file names: You can use Salamander.Script.Path property to get the full script path regardless the scripting engine used. There is analogous property WScript.ScriptFullName for the WSH.
Thierry
Posts: 28
Joined: 28 Apr 2006, 10:35
Location: Paris, France
Contact:

Re: Automation Plugin: ActiveRuby

Post by Thierry »

Thank you for your feedback.
I have already been in contact for other matters with Arton, the developer of ActiveRuby. I will forward the problems to him, and keep you posted on any progress.
Thanks again.
manison
Plugin Developer
Plugin Developer
Posts: 216
Joined: 09 Dec 2005, 23:23
Location: Ceske Budejovice, Czech Republic
Contact:

Re: Automation Plugin: ActiveRuby

Post by manison »

Please keep us informed, for now we decided not to invest our time into solving this. However we may re-open the issue based on your feedback. Thanks.
Thierry
Posts: 28
Joined: 28 Apr 2006, 10:35
Location: Paris, France
Contact:

Re: Automation Plugin: ActiveRuby

Post by Thierry »

I understand. Here is what Arton told me:
Arton wrote:The first problem will be able to solved I believe (but not so soon).
Becuase COM layer supplies script fragments to the engine by strings, ASR
need to form it as a physical file to get the line number information.
But recent Ruby can handle line numbers virtually so I think it can
change the behaviour.
The second problem is bit serious. I think it depends on Ruby itself but
I'll look for the solution if it will be possible or not.
I'll report any progress.
Cheers
Post Reply