How do I add conditional rubygem requirements to a gem specification?

后端 未结 7 685
伪装坚强ぢ
伪装坚强ぢ 2021-01-06 03:00

Is it possible to add a gem dependency only if the person is using a certain version of ruby?

Background: I\'m working on a fork of a project that u

7条回答
  •  北荒
    北荒 (楼主)
    2021-01-06 03:19

    Gemspecs are just ruby files anyway, so you can execute any ruby code inside them, so:

    spec.add_dependency = 'test-unit', '>= 2.0' if RUBY_VERSION =~ '1.9' 
    

    EDIT: Specs run only on the builders machine.

提交回复
热议问题