Have a name, version, platform. Platform describes CPU architecture, OS or os versions.
lib/
contains code for the gemtest/
Rakefile
uses rake to automate tests, perform tasksbin/
collection of executable files.gemspec
file contains information about the gem, test info, platform, version number, author's name + emailPackage management framework for Ruby, gem
is the cli.
gem fetch gemname && gem unpack gemname
allows you to audit a gem's content without installation.gem build mygem.gemspec
builds a gem that you create or modify into a .gem
file, which can be installed locallygem install mygem
installs a gem from rubygems server or locallygem push mygem-1.0.0.gem
pushes to rubygems.orgMonkey Patching a gem:
git clone
, update gem version in gemspecgem build <gemfile>
gem install ./<gemname>.gem
gem '<mygem>', '=1.0.7'
require '<mygem>'
require
statement.adds lib's directory to Ruby $LOAD_PATH
RubyGems modifies your Ruby load path, controlling how code is found by the require
statement
require
a gem, places the gem's lib
directory onto your $LOAD_PATH
require
is preferred in almost all cases. load
will re-load code every time, inefficientautoload
is deprecated, some dependencies monkeypatch classes, meaning code behaviour can differ depending on what dependencies are loaded at the time (terrible to debug), however it makes sense for speed purposes with files in a gemrequire_relative
indicates a file path that is relative to the current file offering a good solution to loading project coderequire
is more for loading installed code, accessible by the whole system