Contents |
To give an overview of installing gems, updating them and, if necessary, removing them. We'll also look at some housekeeping and clean up and remove older versions of updated gems.
Installing a gem in fair enough but what if you don't know what it's called?
Well, one way of finding a gem is to look at the rubygems homepage at http://rubyforge.org/projects/rubygems/
However, this can be a bit overwhelming and may be a long way around if you know what you are looking for. In cases like these you can search a remote list of gems for the phrase you are after:
gem search mysql --remote gems.rubyforge.org
This will give a list of gems with the word 'mysql' in them.
Si queremos ver todas las versiones de una gema usamos al opción -a:
[~/local/src/ruby/sinatra/rack/hangout-framework(master)]$ gem list 'erubis$' -a -r
*** REMOTE GEMS ***
erubis (2.7.0, 2.6.6, 2.6.5, 2.6.4, 2.6.3, 2.6.2, 2.6.1, 2.6.0, 2.5.0, 2.4.1,
2.4.0, 2.3.1, 2.3.0, 2.2.0, 2.1.0, 2.0.1, 2.0.0, 1.1.0, 1.0.1, 1.0.0)
Installing a particular gem is very simple:
gem install mysql
That will, not unsurprisingly, install the gem 'mysql' (which is the ruby bindings for MySQL, not MySQL itself!).
The example above will give a choice of versions to install. On a Linux VPS simply choose the latest 'ruby' version. So at the time of writing I would select option (3) mysql 2.7 (ruby).
Often a gem will have several dependencies with it. To stop the install asking if you want the dependencies to be installed use this:
gem install mysql --include-dependencies
To get a list of gems that are now outdated (they have a newer version available), use this command:
gem outdated
To update all the installed rubygems is just as straightforward:
gem update
However, you may not want to update all at once, in which case specify the gem:
gem update mysql
This will remove outdated versions of gems that are installed, leaving the new updated version installed:
gem clean
This will leave a nice and shiny up to date rubygems install.
At some point you may want to get rid of a gem completely. No problem:
gem uninstall mysql
To get a list of locally installed gems, issue this command:
gem list
That will give an overview of the gems you have installed.
gem install --local path_to_gem/filename.gem
This will skip the usual gem repository scan that happens when you leave off --local.
[~/Dropbox/src/ruby/sinatra/bootstrap_example(master)]$ gem spec sinatra
--- !ruby/object:Gem::Specification
name: sinatra
version: !ruby/object:Gem::Version
version: 1.4.2
platform: ruby
authors:
- Blake Mizerany
- Ryan Tomayko
- Simon Rozet
- Konstantin Haase
autorequire:
bindir: bin
cert_chain: []
date: 2013-03-21 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: rack
requirement: !ruby/object:Gem::Requirement
requirements:
- - '>='
- !ruby/object:Gem::Version
version: 1.5.2
- - ~>
- !ruby/object:Gem::Version
version: '1.5'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - '>='
- !ruby/object:Gem::Version
version: 1.5.2
- - ~>
- !ruby/object:Gem::Version
version: '1.5'
- !ruby/object:Gem::Dependency
name: tilt
requirement: !ruby/object:Gem::Requirement
requirements:
- - '>='
- !ruby/object:Gem::Version
version: 1.3.4
- - ~>
- !ruby/object:Gem::Version
version: '1.3'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - '>='
- !ruby/object:Gem::Version
version: 1.3.4
- - ~>
- !ruby/object:Gem::Version
version: '1.3'
- !ruby/object:Gem::Dependency
name: rack-protection
requirement: !ruby/object:Gem::Requirement
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '1.4'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '1.4'
description: Sinatra is a DSL for quickly creating web applications in Ruby with minimal
effort.
email: sinatrarb@googlegroups.com
executables: []
extensions: []
extra_rdoc_files:
- README.de.md
- README.es.md
- README.fr.md
- README.hu.md
- README.jp.md
- README.ko.md
- README.md
- README.pt-br.md
- README.pt-pt.md
- README.ru.md
- README.zh.md
- LICENSE
files:
- README.de.md
- README.es.md
- README.fr.md
- README.hu.md
- README.jp.md
- README.ko.md
- README.md
- README.pt-br.md
- README.pt-pt.md
- README.ru.md
- README.zh.md
- LICENSE
homepage: http://www.sinatrarb.com/
licenses: []
metadata: {}
post_install_message:
rdoc_options:
- --line-numbers
- --inline-source
- --title
- Sinatra
- --main
- README.rdoc
- --encoding=UTF-8
require_paths:
- lib
required_ruby_version: !ruby/object:Gem::Requirement
requirements:
- - '>='
- !ruby/object:Gem::Version
version: '0'
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - '>='
- !ruby/object:Gem::Version
version: '0'
requirements: []
rubyforge_project:
rubygems_version: 2.0.3
signing_key:
specification_version: 3
summary: Classy web-development dressed in a DSL
test_files: []