Module: Toys::StandardMixins::Gems::ClassMethods

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

Overview

This module extends the tool class when you include the Gems mixin, so that the gems and gem directives defined in this module are available.

Instance Method Summary collapse

Instance Method Details

#gem(name, *requirements, **options) ⇒ :activated, ...

Activate the given gem. If it is not present, attempt to install it (or inform the user to update the bundle).

Parameters:

  • name (String)

    Name of the gem

  • requirements (String...)

    Version requirements

  • options (keywords)

    Additional options to pass to the Utils::Gems constructor

Returns:

  • (:activated)

    if the gem was activated

  • (:installed)

    if the gem was installed and activated

  • (false)

    if the gem had already been activated

Raises:

  • (ActivationFailedError)

    if activation or install failed



116
117
118
119
# File 'lib/toys/standard_mixins/gems.rb', line 116

def gem(name, *requirements, **options)
  gems_util = options.empty? ? gems : Utils::Gems.new(**options)
  gems_util.activate(name, *requirements)
end

#gemsToys::Utils::Gems

Returns a tool-wide instance of Utils::Gems.

Returns:



97
98
99
# File 'lib/toys/standard_mixins/gems.rb', line 97

def gems
  @__default_gems_util
end