`
fireDragonpzy
  • 浏览: 441568 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

Rails 3 | Bundler浅尝

阅读更多
Rails3里多了个Bundler工具。
它是一个Library管理工具,它提供了好的工具来管理你rails3项目依赖的gems。
$> bundle
这个命令会列出bundler提供给你的一些工具。
Tasks:
  bundle check        # Checks if the dependencies listed in Gemfile are satisfied by currently installed gems
  bundle exec         # Run the command in context of the bundle
  bundle help [TASK]  # Describe available tasks or one specific task
  bundle init         # Generates a Gemfile into the current working directory
  bundle install      # Install the current environment to the system
  bundle lock         # Locks the bundle to the current set of dependencies, including all child dependencies.
  bundle pack         # Packs all the gems to vendor/cache
  bundle show         # Shows all gems that are part of the bundle.
  bundle unlock       # Unlock the bundle. This allows gem versions to be changed

你只要在你的Gemfile文件里添加你项目所需的gems就可以了。

$> bundle pack
这个命令可以打包你的gems到vendor/cache目录下。然后你把项目给别的开发者,别人就可以使用:
$> bundle install
来安装项目依赖的gems了。

但是当你想把项目部署到生产环境的话,假如gems出现新版本,可能导致项目出现错误,这个时候,我们就需要锁定gem的版本。
$> bundle lock
这个命令会在rails的根目录下生成一个Gemfile.lock文件。类似于这样的:
---
dependencies:
- rails: = 3.0.0.beta
- sqlite3-ruby: ">= 0"
- pg: ">= 0"
specs:
- text-hyphen:
    version: 1.0.0
- builder:
    version: 2.1.2
- i18n:
    version: 0.3.3

当你在Gemfile文件里增加了一个新的gem,比如“hpricot”你运行:
$> bundle check
You changed your Gemfile after locking. Please relock using `bundle unlock`
想修改Gemfile必须先解锁Gemfile文件:
$> bundle unlock
然后才能修改,修改完再锁定。
$> bundle install
这条命令会自动安装Gemfile里的所有gem。
然后我们再检测:
$>bundle check
The Gemfile's dependencies are satisfied
这就安全了。
然后我们可以打包了:
$> bundle pack
Copying .gem files into vendor/cache
...
打包完以后,锁定我们的gems:
$> bundle lock
这下你就可以安全部署你的app了。

gem的写法可以具体参照:http://github.com/carlhuda/bundler
Bundler官网:http://gembundler.com

本文出自 “{ :Alex Space => &..” 博客,请务必保留此出处http://blackanger.blog.51cto.com/140924/355320
分享到:
评论

相关推荐

    npm-rails, 通过像DSL这样的Bundler支持 Rails的NPM.zip

    npm-rails, 通过像DSL这样的Bundler支持 Rails的NPM npm Rails 项目的NPM支持。 它允许你使用bundler像DSL和rake任务来包括npm包。 这个基于Browserify的gem,用于捆绑包和解析依赖关系。安装将此行添加到你的应用...

    sample-app:Web 5 Rails教程| 示例应用

    Ruby on Rails教程样本应用程序 这是的示例应用程序 进行 。 执照 中的所有源代码都可以根据MIT许可和Beerware许可共同获得。 有关详细信息,请参见 。 入门 要开始使用该应用程序,请克隆存储库,然后安装所需的gem...

    rails3教程

    Rails3教程系列 DRY(Dont Repeat Yourself) DRY(Dont Repeat Yourself) DRY(Dont Repeat Yourself) DRY(Dont Repeat Yourself) DRY(Dont Repeat Yourself) DRY(Dont Repeat Yourself) DRY(Dont Repeat Yourself) DRY...

    RVM_Ruby1.9.3_Rails3(2-Ruby on Rails3安装配置)

    Windows7_Cygwin_Git_RVM_Ruby1.9.3_Rails3_MongoD B_Nginx_Unicorn_Rspec_Guard_Spork(2-Ruby on Rails3 安装配置

    turbo-sprockets-rails3, 加速你的Rails 3资产.zip

    turbo-sprockets-rails3, 加速你的Rails 3资产 用于 Rails 3.2.x的涡轮链轮 通过只根据源文件的哈希来重新编译已经更改的资产,从而加快 Rails 3 rake assets:precompile的速度只编译一次以生成指纹和非打印的资产...

    The Rails 3 Way(2nd)

    The Rails™ 3 Way is a comprehensive resource that digs into the new features in Rails 3 and perhaps more importantly, the rationale behind them. —Yehuda Katz, Rails Core The Bible for Ruby on ...

    基于java的开发源码-Rails3消息队列系统 Sidekiq.zip

    基于java的开发源码-Rails3消息队列系统 Sidekiq.zip 基于java的开发源码-Rails3消息队列系统 Sidekiq.zip 基于java的开发源码-Rails3消息队列系统 Sidekiq.zip 基于java的开发源码-Rails3消息队列系统 Sidekiq.zip ...

    The Rails3 Way, 2nd Edition

    The Rails™ 3 Way is the only comprehensive, authoritative guide to delivering production-quality code with Rails 3. Pioneering Rails expert Obie Fernandez and a team of leading experts illuminate ...

    Rails 3 in Action

    Rails 3 in Action 2011年9月新鲜出炉,针对最新的Rails 3.1进行说明

    Rails3消息队列系统 Sidekiq

    Rails3消息队列系统 Sidekiq

    Rails3的ActiveRecord 查询API.doc

    Rails3的ActiveRecord 查询API.doc

    centOS Rails3环境搭建

    3 rails # gem install rails -v=2.3.11 4 passenger # gem install passenger passenger-install-apache2-module 安装完成后按照提示将下面的内容添加到etc/httpd/httpd.conf LoadModule pa

    rails金典教材3本

    Ruby+on+Rails+3+Tutorial.pdf 应用Rails进行敏捷Web开发第4版.pdf (Agile Web Development with Rails) Rails.Recipes.Rails.3.Edition.pdf

    rails-assets, 在 Rails 中,资产管理的解决.zip

    rails-assets, 在 Rails 中,资产管理的解决 Rails 资产 Bundler 到 Bower 代理本自述文件涉及项目的开发方面。 访问站点了解如何在你的应用程序中使用 Rails 资产。 插件开发设置git clone git@github.com:tenex/r

    [Rails] Crafting Rails Applications (英文版)

    This pioneering book is the first resource that deep dives into the new Rails 3 APIs and shows you how use them to write better web applications and make your day-to-day work with Rails more ...

    Rails3常用命令行命令

    rails常用命令,例如新建rails项目,新建controller、model 等等

    ruby on rails 3 tutorial.pdf

    ruby on rails开发的初学者很适合的工具书,易上手,很实用,

    rails3文档

    rails3的英文文档

    jquery-rails, 一个 gem,用于自动使用jQuery和 Rails 3.zip

    jquery-rails, 一个 gem,用于自动使用jQuery和 Rails 3 railsjQuery 面向 Rails 如此伟大。这里 gem 提供:jQuery 1.7.2jQuery UI 1.8.18 ( 仅适用于 javascript )jQuery UJS适配器assert_select_j

Global site tag (gtag.js) - Google Analytics