酿造配方中的宝石依赖性

时间:2016-02-16 16:28:35

标签: rubygems dependencies homebrew

是否可以为公式设置ruby gem依赖项?

文档中有一段关于它的内容,但没有进一步解释:https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Formula-Cookbook.md#specifying-gems-python-modules-go-projects-etc-as-dependencies

1 个答案:

答案 0 :(得分:0)

好的,通过this formulathis gem的组合找到了一个解决方案,第一个项目似乎是共同使用的。

它的长短不一,是每个gem的资源,安装到目录,更新脚本GEM_HOME以便它们可以找到它们:

class GemDependentProject < Formula

  #...cut

  resource 'aws-sdk' do
    url 'https://rubygems.org/gems/aws-sdk-2.6.29.gem'
    sha256 '686ecaf63713d7a123cdfb1d746cc660236b6c8c3ac0b4f12b56479fa0542f06'
  end

  def install
    prefix.install 'bin', 'lib'

    resources.each do |r|
      r.verify_download_integrity(r.fetch)
      system("gem", "install", r.cached_download, "--no-document",
             "--install-dir", "#{lib}/gem-dependent-project/vendor")
    end

    (bin/"gem-dependent-project-script").write(init_script)
  end

  def init_script
    <<-EOS.undent
    export GEM_HOME="#{HOMEBREW_PREFIX}/lib/gem-dependent-project/vendor"
    # Continue as normal...
    EOS
  end

    #... cut
end