Approach for installing system service implemented as Ruby gem

情到浓时终转凉″ 提交于 2019-12-06 02:56:41

You can do it. However it is probably not quite the recommended approach. But yes it is possible to run arbitary code during gem installation using the extensions option.

From the RubyGems Manual:

Usage
  spec.extensions << 'ext/rmagic/extconf.rb'

Notes
These files will be run when the gem is installed, causing the 
C (or whatever) code to be compiled on the user’s machine.

Just place whatever ruby code you need into the extconf.rb (or equivalent) file.

Examples for building C-extensions from the RubyGems Guides:
http://guides.rubygems.org/c-extensions/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!