从Rails应用程序内部调用rubygem的二进制可执行文件?(Call a rubygem's binary executable from inside my rails applications?)

3 IT屋

I know that bundler makes a gems executables available using the bundle exec command. I want to understand how I can call these executables from inside a controller action or model class method? I don't see anything about this in the Bundler doco.

解决方案

Executables are ruby scripts sitting in the bin directory of the gems and their behavior depend on each gem. They are wrappers around the gems classes/APIs: simply dig into the source code of the gems you target and mimic the behavior of their CLIs.

我知道捆绑程序使用 bundle exec 命令使gems可执行文件可用。我想了解如何从控制器动作或模型类方法内部调用这些可执行文件?我在Bundler doco中什么都没有看到。


解决方案

可执行文件是 bin 目录及其行为取决于每个宝石。它们是gems类/ API的包装器:只需深入研究您所定位的gems的源代码并模仿其CLI的行为即可。


本文地址:IT屋 » 从Rails应用程序内部调用rubygem的二进制可执行文件?