Using a Gemfile and Bundler

suggest change

A Gemfile is the standard way to organize dependencies in your application. A basic Gemfile will look like this:

source 'https://rubygems.org'gem 'rack'gem 'sinatra'gem 'uglifier'

You can specify the versions of the gem you want as follows:

# Match except on point release. Use only 1.5.Xgem 'rack', '~>1.5.2'# Use a specific version.gem 'sinatra', '1.4.7'# Use at least a version or anything greater.gem 'uglifier', '>= 1.3.0'

You can also pull gems straight from a git repo:

# pull a gem from githubgem 'sinatra', git: 'https://github.com/sinatra/sinatra.git'# you can specify a shagem 'sinatra', git: 'https://github.com/sinatra/sinatra.git', sha: '30d4fb468fd1d6373f82127d845b153f17b54c51'# you can also specify a branch, though this is often unsafegem 'sinatra', git: 'https://github.com/sinatra/sinatra.git', branch: 'master'

You can also group gems depending on what they are used for. For example:

group :development, :test do# This gem is only available in dev and test, not production.gem 'byebug'end

You can specify which platform certain gems should run on if you application needs to be able to run on multiple platforms. For example:

platform :jruby dogem 'activerecord-jdbc-adapter'gem 'jdbc-postgres'endplatform :ruby dogem 'pg'end

To install all the gems from a Gemfile do:

gem install bundlerbundle install

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents