== gem build -- Build a gem file from a specification The build command is used by developers to package their Ruby software into a single gem file that can be distributed. The build command requires a gemspec file to describe the metadata in the packge. You can see a good example of using build in CreateAGemInTenMinutes. A yaml file containing the Gem::Specification object built by a gemspec (instead of a gemspec file) may also be also be used with the build command. h3. Usage !usage build h3. Examples This example builds a the rake package from a gemspec file.
$ gem build rake.gemspec Attempting to build gem spec 'rake.gemspec' Successfully built RubyGem Name: rake Version: 0.4.0 File: rake-0.4.0.gemOf course, rake isn't normally built from a gemspec. It uses a special gem building task to build the gem directly from the rakefile. See CreateAGemUsingRake for more details.
$ rake gem (in /home/jim/working/rubyforge/rake) Successfully built RubyGem Name: rake Version: 0.4.0 File: rake-0.4.0.gem
$ gem cert --build gemmaster@example.comAdd a certificate to the list of trusted certificates. The trusted certificate list will be consulted when installing signed gems.
$ gem cert --add gem-public_cert.pemSign a certificate with the specified key and certificate (note that this modifies client_cert.pem!)
$ gem cert \ -K /mnt/floppy/issuer-priv_key.pem \ -C issuer-pub_cert.pem \ --sign client_cert.pem
$ gem check -v pkg/rake-0.4.0.gem Verifying gem: 'pkg/rake-0.4.0.gem'The following check shows that the rake gem file is invalid.
$ gem check -v pkg/rake-0.4.0.gem Verifying gem: 'pkg/rake-0.4.0.gem' ERROR: pkg/rake-0.4.0.gem is invalid.In this installation of
$ gem check --alien Performing the 'alien' operation madeleine-0.6 is error-free madeleine-0.6.1 is error-free rake-0.4.0 is error-free rake-0.3.2 is error-free copland-0.3.0 is error-free sources-0.0.1 has 2 problems iterator-0.5 is error-free activerecord-0.8.1 has 2 problems lib/active_record/connection_adapters/postgresql_adapter.rb: installed file doesn't match original from gem /usr/local/lib/ruby/gems/1.8/cache/activerecord-0.8.1.gem: Unmanaged files in gem: ["lib/active_record/connection_adapters/postgresql_adapter.rb~"] [... remaining output elided ...]
$ gem cleanup Rubygems Environment: - VERSION: 0.6 (0.6.1) - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8 - GEM PATH: - /usr/local/lib/ruby/gems/1.8 - REMOTE SOURCES: - http://gems.rubyforge.org
$ gem contents rake traken$ gem inspect rake /usr/local/lib/ruby/gems/1.8/gems/rake-0.5.4.3/install.rb /usr/local/lib/ruby/gems/1.8/gems/rake-0.5.4.3/CHANGES /usr/local/lib/ruby/gems/1.8/gems/rake-0.5.4.3/Rakefile /usr/local/lib/ruby/gems/1.8/gems/rake-0.5.4.3/README /usr/local/lib/ruby/gems/1.8/gems/rake-0.5.4.3/TODO [... truncated ...]h3. Limitations Currently there is no way to specify the version of the gem you wish to view.
$ gem dependency rails -v 0.10.1 Gem rails-0.10.1 Requires rake (>= 0.4.15) activesupport (= 1.0.1) activerecord (= 1.8.0) actionpack (= 1.5.1) actionmailer (= 0.7.1) actionwebservice (= 0.6.0)Adding a @--reverse-dependencies@ option adds the following bit of information:
$ gem dependency rails -v 0.10.1 --reverse-dependencies Gem rails-0.10.1 Requires rake (>= 0.4.15) activesupport (= 1.0.1) activerecord (= 1.8.0) actionpack (= 1.5.1) actionmailer (= 0.7.1) actionwebservice (= 0.6.0) Used by storycards-0.0.2 (rails (>= 0.7.0))Finally, the @--pipe@ option for the dependency command puts out the dependencies in a format that could be piped to another command.
$ gem dependency rails -v 0.10.1 --pipe rake --version '>= 0.4.15' activesupport --version '= 1.0.1' activerecord --version '= 1.8.0' actionpack --version '= 1.5.1' actionmailer --version '= 0.7.1' actionwebservice --version '= 0.6.0'
$ gem environment Rubygems Environment: - VERSION: 0.6 (0.6.1) - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8 - GEM PATH: - /usr/local/lib/ruby/gems/1.8 - REMOTE SOURCES: - http://gems.rubyforge.org
gem install --remote copland # shortcut: gem ins -R copland gem install copland --version '> 0.2' gem install copland --gen-rdoc --run-tests gem install copland --install-stubHere is an example session where a dependency is automatically downloaded and resolved.
$ gem install copland Attempting local installation of '' Local gem file not found: copland.gem Attempting remote installation of 'copland' Install required dependency log4r? [Yn] y Successfully installed copland, version 0.3.0
$ gem list -r a *** REMOTE GEMS *** activerecord (0.8.4, 0.8.3, 0.8.2, 0.8.1, 0.8.0, 0.7.6, 0.7.5) Implements the ActiveRecord pattern for ORM. arrayfields (3.3.0) Allow keyword access to arraysList all gems, local and remote.
$ gem list --both *** LOCAL GEMS *** ... *** REMOTE GEMS *** ...
$ gem query -n '[0-9]' --local *** LOCAL GEMS *** jabber4r (0.7.0) Jabber4r is a pure-Ruby Jabber client library log4r (1.0.5) Log4r is a comprehensive and flexible logging library for Ruby.To list all remote gems that begin with the letter 'm':
$ gem query -R -n ^m *** REMOTE GEMS *** madeleine (0.6.1, 0.6) Madeleine is a Ruby implementation of Object Prevalence midilib (0.8.0) MIDI file and event manipulation library
traken$ sudo gem rdoc rake --version 0.5.4 Installing RDoc documentation for rake-0.5.4...
$ gem search -r log *** REMOTE GEMS *** log4r (1.0.5) Log4r is a comprehensive and flexible logging library for Ruby. rublog (0.8.0) RubLog is a simple web log, based around the idea of displaying a set of regular files in a log-format.
$ gem spec rake -v 0.4.1 --- !ruby/object:Gem::Specification rubygems_version: "0.6" name: rake version: !ruby/object:Gem::Version version: 0.4.1 date: 2004-07-02 01:08:54.678603 -04:00 platform: summary: Ruby based make-like utility. require_paths: - lib files: - install.rb - CHANGES - Rakefile - README - TODO - MIT-LICENSE - bin/rake - lib/rake.rb - lib/rake/clean.rb ......
$ gem uninstall copland Attempting to uninstall gem 'copland' Successfully uninstalled copland version 0.3.0The following uninstalls all the installed versions of the rake gem. Since rake is an application, it has a ApplicationStub installed. The uninstall removes the stub as well.
$ sudo gem uninstall rake Attempting to uninstall gem 'rake' Select RubyGem to uninstall: 1. rake-0.3.2 2. rake-0.4.0 3. All versions > 3 Successfully uninstalled rake version 0.3.2 Successfully uninstalled rake version 0.4.0 WARNING: About to remove executables and scripts for: rake Proceed? [Y/n] y Removing rake
$ gem unpack rake Unpacked gem: 'rake-0.4.3' $ ls rake-0.4.3/ CHANGES MIT-LICENSE README Rakefile TODO bin doc install.rb lib test $ gem unpack wazoo ERROR: Gem 'wazoo' not installed.
$ gem update Upgrading installed gems... Attempting remote upgrade of activerecord Attempting remote installation of 'activerecord' Successfully installed activerecord, version 0.8.4 Attempting remote upgrade of csbattery Attempting remote installation of 'csbattery' Successfully installed csbattery, version 0.2.2 All gems up to date