thanks 2009/8/21 Tomas Matousek <[email protected]>
> If engine.Execute(Resource.test + rubyCode) works for you, > > > > engine.Execute(Resource.test) > > engine.Execute(rubyCode) > > > > should work too. > > > > Or you can monkey-patch Kernel#require and make it look into resources > first. Something like: > > engine.Execute(@” > > module Kernel > > alias __require require > > def require path > > return false if $”.include(path) > > if <path is in resources> > > eval(<resource string>) > > $” << path > > true > > else > > __require path > > end > > end > > end”); > > > > Tomas > > > > *From:* [email protected] [mailto: > [email protected]] *On Behalf Of *mlkjih mlkjih > *Sent:* Friday, August 21, 2009 10:07 AM > *To:* [email protected] > *Subject:* Re: [Ironruby-core] How add require from string? > > > > I need to execute some code that require test.rb. There is one solution, > engine.Execute(Resource.test + rubyCode) > but I believe that exist more elegant way. > > 2009/8/21 Tomas Matousek <[email protected]> > > Couldn’t you just execute the code in the resource (engine.Execute(resource > string))? > > Or do you need to do that from the Ruby script you execute? > > > > Tomas > > > > *From:* [email protected] [mailto: > [email protected]] *On Behalf Of *mlkjih mlkjih > *Sent:* Friday, August 21, 2009 7:29 AM > *To:* [email protected] > *Subject:* [Ironruby-core] How add require from string? > > > > var rubyCode = > "require 'test' > puts A.new" > > engine = Ruby.CreateRuntime().GetEngine("rb"); > engine.Execute(rubyCode); > > Engine search the test.rb file. What if i have test.rb code in resources? > Can I add it to engine from string instead of file? > > > _______________________________________________ > Ironruby-core mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/ironruby-core > > > > _______________________________________________ > Ironruby-core mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/ironruby-core > >
_______________________________________________ Ironruby-core mailing list [email protected] http://rubyforge.org/mailman/listinfo/ironruby-core
