LoginSignup
6
7

More than 5 years have passed since last update.

MRI(CRuby)とJRuby用のgemをGemfileで管理したい

Posted at

Norikraを使い始めた所為でJRubyを使わなければならなくなってしまった、世間には良くある光景である。同じリポジトリで設定を管理したいので、次の様なディレクトリ構成にした。

.
├── Gemfile
├── Gemfile.lock
├── lib
│   ├── fluentd
│   │   ├── .ruby-version
│   │   └── fluent.conf
│   └── norikra
│       └── .ruby-version
└── scripts
    ├── fluentd
    └── norikra

fluentdとnorikraはそれぞれscriptsディレクトリに置いたスクリプトをたたくことで実行している。各Ruby処理系はrbenvで管理されていて、.ruby-versionでスイッチして運用している(別にスクリプトの中でスイッチしても良い)。最初はそれぞれのディレクトリにGemfileを置いていたけどplatformsを使えば1つにできることを知った。

source "https://rubygems.org"

platforms :ruby do
  gem "fluentd"
  gem "fluent-plugin-typecast"
  gem "fluent-plugin-forest"
  gem "fluent-plugin-mongo"
  gem "fluent-plugin-flatten-hash"
end

platforms :jruby do
  gem "norikra"
end

このように書くとbundle installを実行した処理系に応じてgemがインストールされる。1つにまとめられて便利だ。

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7