开发者

How to choose particular gem in Gemfile based on current RVM?

How can I conditionally choose which开发者_StackOverflow中文版 gem to use based on the Ruby VM currently in use?

Ideally I would like something like:

if [using jruby]
    gem 'jruby-openssl'

This would only require the jruby-openssl if the RVM being used is JRuby.


Use the following in your Gemfile, as documented here: https://github.com/jruby/activerecord-jdbc-adapter

platforms :ruby do
  gem 'sqlite3'
end

platforms :jruby do
  gem 'jruby-openssl'
  gem 'activerecord-jdbcsqlite3-adapter'
end


Attempting to answer my own question here.

We can do this using the following Gemfile directive:

if defined?(JRUBY_VERSION)
  gem 'jdbc-sqlite3'
else
  gem 'sqlite3'
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜