开发者

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

开发者 https://www.devze.com 2023-04-01 11:05 出处:网络
How can I conditionally choose which开发者_StackOverflow中文版 gem to use based on the Ruby VM currently in use?

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

精彩评论

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