Ruby gems: Difference between revisions

From wikinotes
No edit summary
 
(One intermediate revision by the same user not shown)
Line 26: Line 26:
</source>
</source>
</blockquote><!-- Environment -->
</blockquote><!-- Environment -->
= Notes =
<blockquote>
{| class="wikitable"
|-
| [[ruby gem projects]]
|-
| [[ruby gem package management]]
|-
|}
</blockquote><!-- Notes -->


= Usage =
= Usage =
Line 41: Line 52:


gem list --local                    # list installed gems/versions
gem list --local                    # list installed gems/versions
gem list -i ${GEM} -v ${VERSION}    # list installed gems
gem which \*${GEM}\*                # list install location of gem


gem unpack file.gem # extract gem
gem unpack file.gem # extract gem
Line 52: Line 65:
# when building a package. These are passed following '--'
# when building a package. These are passed following '--'
# ex:
# ex:
#  gem install -- [arguments passed to ruby interp]  
#  gem install -- [arguments passed to ruby interp]
gem install -- \
gem install -- \
   --with-opt-dir=/opt/lib/package  \ # add directory with subdirs 'include/' and 'lib/' for C headers/libs.
   --with-opt-dir=/opt/lib/package  \ # add directory with subdirs 'include/' and 'lib/' for C headers/libs.

Latest revision as of 19:52, 13 November 2022

A package manager for ruby libraries.
You may also be interested in the ruby gemfile, and ruby bundler.

Documentation

cli docs https://guides.rubygems.org/command-reference/
homepage/repo https://rubygems.org/
github https://github.com/rubygems/rubygems
gemspec file ref https://guides.rubygems.org/specification-reference/
wikipedia https://en.wikipedia.org/wiki/RubyGems

Environment

GEM_HOME=                # where gems are installed
GEM_PATH=/a/b:/c/d:/e/f  # where gems are found

Notes

ruby gem projects
ruby gem package management

Usage

gem -h
gem list -h                          # help for subcommand

gem search <pkg>                     # search for gem

gem install ${PKG} \
    -v 1.8          `# gem-version (also supports >=, ~>)` \
    --user-install  `# user install (rather than system install)` \
    --platform ruby `# specify platform for compiled gems, or ruby to build from src` \

gem list --local                     # list installed gems/versions
gem list -i ${GEM} -v ${VERSION}     # list installed gems
gem which \*${GEM}\*                 # list install location of gem

gem unpack file.gem # extract gem


If building packages with extensions, you can pass additional commandline arguments. See ruby extensions for more details.

# You may need to issue additional params to ruby
# when building a package. These are passed following '--'
# ex:
#   gem install -- [arguments passed to ruby interp]
gem install -- \
  --with-opt-dir=/opt/lib/package  \ # add directory with subdirs 'include/' and 'lib/' for C headers/libs.

File Structure

gem_name/
  bin/
    gem_name
  lib/
    gem_name.rb
  test/
    test_gem_name.rb
  README
  Rakefile
  gem_name.gemspec