I wanted to test my prototype ADO.NET database wrappers for SQLite and
MySQL, so I thought I would see how far I could get in an attempt to run
activerecord. Running activerecord is of course a necessary step in the
path to running Rails. At this point I’m simply trying to get “require
‘active_record.rb’” to work, which in turn requires activesupport. Here
are some issues I’ve come across thus far:
(1) Missing method File.expand_path
- Adapted the implementation from Ruby.NET, along with some other
unimplemented methods from File. I will check on licensing issues
before posting a patch.
(2) rubygems is not yet running in IronRuby
- Commented out all “require ‘rubygems’” in the activerecord and
activesupport source, since they are not absolutely necessary (i.e.
rubygems is used to grab packages not present on the local
filesystem).
(3) Missing method Class.method_added
- This is just a ‘dummy’ method that gets overridden - see patch for
ModuleOps.cs
(4)
C:\brian\ironruby\trunk\src\IronRuby.Libraries\Builtins\Kernel.cs:611:in
`InstanceEval’: instance_eval on Module or Class needs singleton support
(NotImplementedError)
- It seems that instance_eval has different semantics when invoked
with a class or method as receiver. I haven’t yet worked out what is
involved with implementing this method, so for the time being I
commented out the NotImplementedError in Kernel.cs:
//if (self is RubyModule) {
// throw
RubyExceptions.CreateNotImplementedError(“instance_eval on
Module or Class needs singleton support”);
//}
(5) :0:in __init__': wrong number or type of arguments for define_method’ (ArgumentError)
-
Problem: current implementation of define_method does not accept
Proc objects as arguments, hence the following line in
activesupport-2.0.2\lib\active_support\core_ext\module\attr_accessor_with_default.rb
throws an exception:define_method(sym, block_given? ? block : Proc.new { default }) -
Solution: added an overload for DefineMethod that accepts a Proc
object as an argument; see patch for ModuleOps.cs
(6) Missing method Thread.critical
- Hacked a prototype implementation - see patch for ThreadOps.cs (it’s
ugly and purely for the purposes of trying to get activerecord
to import
(7) Missing method Dir.glob
- Adapted the implementation from Ruby.NET (see (1) above)
(8) Missing method File.basename
- Adapted the implementation from Ruby.NET (see (1) above)
(9) Problem with
activesupport-2.0.2\lib\active_support\core_ext\array\conversions.rb
-
unknown: Cannot cast from ‘Microsoft.Scripting.SymbolId’ to
‘Ruby.Builtins.Proc’
(ArgumentError) -
This is the offending piece of code in conversions.rb:
def to_param map(&:to_param).join '/' endI must say that I’m not familiar with the &:symbol syntax. Anyone
have any suggestions here? -
For the time being I have commented out this method in
conversions.rb.
(10) Libraries ‘enumerator.so’ and ‘bigdecimal.so’ not available
- Solution: commented out the requires in the activesupport source for
the time being
(11) Problem with the Ruby library ‘rational.rb’:
:0:in `main’: Can’t inherit from a class without a default or code
context constructor (System::NotSupportedException)
- The problem is that Rational is a subclass of Numeric, which is an
abstract class with no constructor:
class Rational < Numeric - Solution: hacked Ruby.Builtins.Numeric so that it is no longer
abstract, and has a zero-arg constructor - see patch for Numeric.cs
(12)
C:\brian\ironruby\trunk\src\IronRuby.Libraries\Builtins\Kernel.cs:804:in
`Require’: Expression transformation not implemented:
MemberAssignmentExpression (System::NotImplementedException)
- The problem is in the Ruby library date/format.rb, although I
haven’t narrowed it down further than that. - Solution: commented out all “require ‘date’” for the time being
(13) Problem with the Ruby library delegate.rb: Class.new not supported
(e.g. no zero-arg constructor for “Class”)
This is as far as I have got at this point - hopefully someone might
find all this useful.
- Brian