简体   繁体   English

从Ruby中执行文件

[英]Execute file from within ruby

I have a Pathname that points to a ruby file. 我有一个指向红宝石文件的Pathname

How do I execute that file from with in another ruby script. 如何在另一个ruby脚本中执行该文件。

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. 它需要共享内存,因此解决方案必须在MRI流程中运行文件。

 load pathname

The difference between load and require is with load , the file will always be executed. 之间的区别loadrequire是与load ,该文件就一定会执行。 With require , it will be executed only once. 使用require ,它将仅执行一次。

然后,您只需要Kernel#require方法:

require pathname

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM