ruby – 如何从Gemfile安装gem?

前端之家收集整理的这篇文章主要介绍了ruby – 如何从Gemfile安装gem?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想为我的项目添加代码覆盖率并注册coveralls.io并使用以下命令创建Gemfile:
gem 'coveralls',require: false

但是如何从Gemfile安装gem呢?

解决方法

一旦创建了Gemfile,就在shell中运行命令bundle install.

此命令将查看您的Gemfile并在指定的版本上安装相关的Gems.

安装Gemfiles是因为在你的Gemfile中你指出了可以从中下载gem的源.

您可以通过在shell中键入bundle init来创建Gemfile

添加了一个Gemfile示例供您参考:

source "https://rubygems.org"  # where gems will be downloaded from
ruby "2.2.3"  # ruby version,change for the one you use

gem "sinatra"
gem "sinatra-flash"
gem "sinatra-partial"
gem "bcrypt"
gem "dm-validations"
gem "dm-transactions"
gem "data_mapper"
gem "dm-postgres-adapter"
gem "pg"
gem "database_cleaner"

group :test do   # you can make groups for test,development,production..
  gem "rspec"
  gem "capybara"
  gem "rspec-sinatra"
  gem "cucumber"
  gem "coveralls",require: false
end
原文链接:https://www.f2er.com/ruby/271177.html

猜你在找的Ruby相关文章