Help us understand the problem. What is going on with this article?


More than 5 years have passed since last update.


引数にgemの名前を渡すとgem gemname '~>version'を出力する。

$ gem install bundler-add
$ bundle add sinatra sinatra-contrib
gem 'sinatra', '~> 1.4.5'
gem 'sinatra-contrib', '~> 1.4.2'
$ bundle add minitest -g test,development
gem 'minitest', '~> 5.5.1', group: [:test, :development]


引数にgemの名前を渡すとGemfileにバージョン付きで追記してbundle installを実行する。

$ gemrat sinatra sinatra-contrib
gem 'sinatra', '1.4.5' added to your Gemfile.
gem 'sinatra-contrib', '1.4.2' added to your Gemfile.

オプションでpessimistic operator(~>)を使うこともできる。groupの指定はできない。



$ cat Gemfile
source ''

gem 'rake'
$ bundle install
# $ safedep
$ cat Gemfile
source ''

gem 'rake', '~> 10.4'

parserを使ってコードをパースして、メソッド名(gem, add_runtime_dependency, add_development_dependency, add_dependency)などを手がかりにgemを指定している箇所を検出してバージョン情報を書き込んでいる。

This document is licensed under CC0.

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away