浏览 7581 次
锁定老帖子 主题:简化gem安装
精华帖 (0) :: 良好帖 (7) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-04-19
我用的办法就是写一个自己的gem,让它依赖于项目里用到的其他gems。这样的话,安装这个gem的时候,就会顺带把其他gems安装了。 代码非常简单: >cat install-gems.gemspec # #Usage: #gem build install-gems.gemspec #gem install install-gems.0.0.1.gem #gem uninstall install-gems (optional, remove this useless gem) # spec = Gem::Specification.new do |s| s.name = "install-gems" s.version = "0.0.1" s.author = "yawl" s.email = "yawl@iteye.com" s.homepage = "http://xruby.iteye.com" s.platform = Gem::Platform::RUBY s.summary = "This gem has no content in itself, it helps to install all the gems we depend on" s.add_dependency('actionmailer', '>=2.0.2') s.add_dependency('actionpack', '>=2.0.2') s.add_dependency('activerecord', '>=2.0.2') s.add_dependency('activeresource', '>=2.0.2') s.add_dependency('activesupport', '>=2.0.2') s.add_dependency('acts_as_ferret', '>=0.4.3') s.add_dependency('capistrano', '>=2.1.0') s.add_dependency('mysql', '>=2.7') s.add_dependency('rails', '>=2.0.2') s.add_dependency('rake', '>=0.8.1') # add more here end 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-04-19
恩,这个办法不错
|
|
返回顶楼 | |
发表时间:2008-04-19
Hmm, 内部gemserver这个时候就很好用了
|
|
返回顶楼 | |
发表时间:2008-04-19
rails 2.1将内建支持该特性...
http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies |
|
返回顶楼 | |
发表时间:2008-04-20
lgn21st 写道 rails 2.1将内建支持该特性...
http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies # environment.rb实例 Rails::Initializer.run do |config| # config.gem "bj" # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" # Require a gem that needs to require a file different than the gem's name # config.gem "aws-s3", :lib => "aws/s3" config.gem "tzinfo", :version => '>= 0.3.8' config.gem "ambition", :version => '>= 0.5.2' config.gem "ambitious-activerecord", :version => '>= 0.1.1', :lib => 'ambition/adapters/active_record' # 或者如下写法 gem 'will_paginate', '~> 2.2.1' require 'will_paginate' # 用法 # rake gems # List the gems that this rails application depends on # rake gems:install # Installs all required gems for this application. # rake gems:unpack # Unpacks all gems into vendor/gems. # rake gems:unpack:dependencies # Unpack all dependencies # rake gems:unpack:dependencies GEM=foo #Unpack all dependencies for gem foo # rake gems:build # for build native extensions. end |
|
返回顶楼 | |
发表时间:2008-04-24
用了一下2.1的这个功能还不错。
一个小问题就是gem安装需要root权限,而我们自动deploy时是以普通用户进行的,所以没有把'rake gems:install'加到脚本里。 我知道可以把sudo设成不要密码,或者把gem安装目录的权限改了。但从安全的考虑都不愿意实施。 |
|
返回顶楼 | |
发表时间:2008-04-25
yawl 写道 用了一下2.1的这个功能还不错。
一个小问题就是gem安装需要root权限,而我们自动deploy时是以普通用户进行的,所以没有把'rake gems:install'加到脚本里。 我知道可以把sudo设成不要密码,或者把gem安装目录的权限改了。但从安全的考虑都不愿意实施。 rake gems:unpack # Unpacks all gems into vendor/gems. |
|
返回顶楼 | |
发表时间:2008-04-25
嗯,这个好。
leondu 写道 rake gems:unpack # Unpacks all gems into vendor/gems. |
|
返回顶楼 | |