在Gemfile中设置环境,以根据自定义文件捆绑安装/更新 [英] Setting the environment in Gemfile for bundling install/update based on a customize file
本文介绍了在Gemfile中设置环境,以根据自定义文件捆绑安装/更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我建立一个sinatra应用程序,捆绑的主要文件如下,
environment.rb
require'sinatra'
require'sequel'
ENV ['RACK_ENV'] ='development'
configure:production do
#do something
end
configure:development,:test do
#do something
end
Gemfile
gem'sinatra'
gem'sequel'
gem'pg',:group => :制作
gem'sqlite3',:group => [:development,:test]
所以,如何让这个bundle基于ENV [' RACK_ENV']在我的environment.rb文件中。
解决方案
在做捆绑器需求时,您可以指定需要哪些组。 / p>
例如:
require'rubygems'
require 'bundler'
如果ENV ['RACK_ENV'] =='development'
Bundler.require(:default,:development)
else
Bundler.require( :默认)
需要'sinatra'
更多关于bundler网站gemfile规格的信息< a href =http://bundler.io/v1.5/man/gemfile.5.html>这里。
hi, all I build a sinatra app, the main files for bundling as the following,
environment.rb
require 'sinatra'
require 'sequel'
ENV['RACK_ENV'] = 'development'
configure :production do
#do something
end
configure :development, :test do
#do something
end
Gemfile
gem 'sinatra'
gem 'sequel'
gem 'pg', :group => :production
gem 'sqlite3', :group => [:development, :test]
So, how to let the bundle install based on the ENV['RACK_ENV'] in my environment.rb file.
解决方案
When doing a bundler require you can specify which groups to be required.
For example:
require 'rubygems'
require 'bundler'
if ENV['RACK_ENV'] == 'development'
Bundler.require(:default, :development)
else
Bundler.require(:default)
require 'sinatra'
More info on the bundler site gemfile specifications found here.
这篇关于在Gemfile中设置环境,以根据自定义文件捆绑安装/更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文