Trent Earl
Trent Earl

Reputation: 3607

Execute file from within ruby

I have a Pathname that points to a ruby file.

How do I execute that file from with in another ruby script.

I am looking for something like:

Kernel.execute(pathname)

It needs to share memory so the solution must run the file within the MRI process.

Upvotes: 0

Views: 88

Answers (2)

Damien
Damien

Reputation: 27463

 load pathname

The difference between load and require is with load, the file will always be executed. With require, it will be executed only once.

Upvotes: 3

Marek Lipka
Marek Lipka

Reputation: 51151

Then you simply need Kernel#require method:

require pathname

Upvotes: 1

Related Questions