Module: Toys::StandardMixins::Gems

Includes:
Mixin
Defined in:
lib/toys/standard_mixins/gems.rb

Overview

Provides methods for installing and activating third-party gems. When this mixin is included, it provides a gem method that has the same effect as Utils::Gems#activate, so you can ensure a gem is present when running a tool. A gem directive is likewise added to the tool DSL itself, so you can also ensure a gem is present when defining a tool.

You may make these methods available to your tool by including the following directive in your tool configuration:

include :gems

If you pass additional options to the include directive, those are used to initialize settings for the gem install process. For example:

include :gems, on_missing: :error

See Utils::Gems#initialize for a list of supported options.

Instance Method Summary collapse

Methods included from Mixin

create

Instance Method Details

#gem(name, *requirements) ⇒ void

This method returns an undefined value.

Activate the given gem.

Parameters:

  • name (String)

    Name of the gem

  • requirements (String...)

    Version requirements



43
44
45
# File 'lib/toys/standard_mixins/gems.rb', line 43

def gem(name, *requirements)
  self.class.gems.activate(name, *requirements)
end

#gemsToys::Utils::Gems

A tool-wide instance of Utils::Gems.

Returns:



32
33
34
# File 'lib/toys/standard_mixins/gems.rb', line 32

def gems
  self.class.gems
end