module Toys::StandardMixins::Bundler
Ensures that a bundle is installed and set up when this tool is run.
The following parameters can be passed when including this mixin:
* `:static` (Boolean) If `true`, installs the bundle immediately, when defining the tool. If `false` (the default), installs the bundle just before the tool runs. * `:groups` (Array\<String\>) The groups to include in setup. * `:gemfile_path` (String) The path to the Gemfile to use. If `nil` or not given, the `:search_dirs` will be searched for a Gemfile. * `:search_dirs` (String,Symbol,Array\<String,Symbol\>) Directories to search for a Gemfile. You can pass full directory paths, and/or any of the following: * `:context` - the current context directory. * `:current` - the current working directory. * `:toys` - the Toys directory containing the tool definition, and any of its parents within the Toys directory hierarchy. The default is to search `[:toys, :context, :current]` in that order. See {DEFAULT_SEARCH_DIRS}. For most directories, the bundler mixin will look for the files ".gems.rb", "gems.rb", and "Gemfile", in that order. In `:toys` directories, it will look only for ".gems.rb" and "Gemfile", in that order. These can be overridden by setting the `:gemfile_names` and/or `:toys_gemfile_names` arguments. * `:gemfile_names` (Array\<String\>) File names that are recognized as Gemfiles when searching in directories other than Toys directories. Defaults to {Toys::Utils::Gems::DEFAULT_GEMFILE_NAMES}. * `:toys_gemfile_names` (Array\<String\>) File names that are recognized as Gemfiles when wearching in Toys directories. Defaults to {DEFAULT_TOYS_GEMFILE_NAMES}. * `:on_missing` (Symbol) What to do if a needed gem is not installed. Supported values: * `:confirm` - prompt the user on whether to install (default). * `:error` - raise an exception. * `:install` - just install the gem. * `:on_conflict` (Symbol) What to do if bundler has already been run with a different Gemfile. Supported values: * `:error` - raise an exception (default). * `:ignore` - just silently proceed without bundling again. * `:warn` - print a warning and proceed without bundling again. * `:retries` (Integer) Number of times to retry bundler operations (optional) * `:terminal` (Toys::Utils::Terminal) Terminal to use (optional) * `:input` (IO) Input IO (optional, defaults to STDIN) * `:output` (IO) Output IO (optional, defaults to STDOUT)
Constants
- DEFAULT_SEARCH_DIRS
Default search directories for Gemfiles. @return [Array<String,Symbol>]
- DEFAULT_TOYS_GEMFILE_NAMES
The gemfile names that are searched by default in
Toys
directories. @return [Array<String>]
Public Class Methods
setup_bundle(context_directory, source_info, gemfile_path: nil, search_dirs: nil, gemfile_names: nil, toys_gemfile_names: nil, groups: nil, on_missing: nil, on_conflict: nil, retries: nil, terminal: nil, input: nil, output: nil)
click to toggle source
@private
# File lib/toys/standard_mixins/bundler.rb, line 97 def self.setup_bundle(context_directory, source_info, gemfile_path: nil, search_dirs: nil, gemfile_names: nil, toys_gemfile_names: nil, groups: nil, on_missing: nil, on_conflict: nil, retries: nil, terminal: nil, input: nil, output: nil) require "toys/utils/gems" gemfile_path ||= begin gemfile_finder = GemfileFinder.new(context_directory, source_info, gemfile_names, toys_gemfile_names) gemfile_finder.search(search_dirs || DEFAULT_SEARCH_DIRS) end gems = ::Toys::Utils::Gems.new(on_missing: on_missing, on_conflict: on_conflict, terminal: terminal, input: input, output: output) gems.bundle(groups: groups, gemfile_path: gemfile_path, retries: retries) end