How to add Mac-specific gems to bundle on Mac but not on Linux?

后端 未结 5 1641
感动是毒
感动是毒 2020-12-15 04:04

I\'m developing a Rails app on a Mac, and I\'m new to testing, so I just added these gems to my Gemfile:

group :test, :development do
  gem          


        
5条回答
  •  感动是毒
    2020-12-15 04:40

    You can use :install_if method which accepts arbitrary lambda.

    Following example comes directly from Gemfile's man pages:

    install_if -> { RUBY_PLATFORM =~ /darwin/ } do
      gem "pasteboard"
    end
    

    It is much better than control flow constructs (e.g. if) as it maintains dependencies correctly and keeps Gemfile.lock uniform on all machines.

提交回复
热议问题