技術メモ

主にRuby関連

Bundler

gem管理ツール

Bundler: The best way to manage Ruby applications

インストール

gem install bundler

アプリ用gem管理ファイル(Gemfile)作成

mkdir myapp
cd myapp
bundle init

Gemfileの雛形が作成される

[Gemfile]
# A sample Gemfile
source "http://rubygems.org"

# gem "rails"

Gemfileにアプリで使うgemを記述し、上書きする

[Gemfile]
source :rubygems

gem "nokogiri"

gemインストール(--path オプションでインストールディレクトリ指定できる)

bundle install --path vendor/bundle

gemインストール(--binstubs オプションで実行ファイルを指定フォルダ(デフォルト./bin)bundle exec が省略できるようになる )

bundle install --binstubs

gem一覧

bundle list
Gems included by the bundle:
  * bundler (1.0.21)
  * nokogiri (1.5.0)

requireする時

require "bundler/setup"
require "sinatra"