Sha256: 44d69af4426d626d565d135f04e99eedd5dc8150a6c942764d879f52c0026dd8

Contents?: true

Size: 858 Bytes

Versions: 56

Compression:

Stored size: 858 Bytes

Contents

# encoding: utf-8
require 'fedux_org_stdlib/core_ext/array'

module FeduxOrgStdlib
  # Helper
  module RequireFiles
    def require_library(libraries, message_template = 'You need to install %s to make "%s" work.')
      libraries = Array(libraries)

      begin
        libraries.each { |l| require l }
      rescue LoadError => e
        $stderr.puts format(message_template, libraries.map { |l| l.split(/\//).first }.uniq.to_list, caller[1].split(/:/)[0, 2].join(':'))
        $stderr.puts
        $stderr.puts e.message
        exit 1
      end
    end

    def require_installed_gem(gems, _message_template = 'You need to install %s to make "%s" work.')
      gems = Array(gems)

      fail LoadError, JSON.dump(gems: gems) if gems.any? { |name| Gem::Specification.find_all_by_name(name).blank? }
    end
  end
end

include FeduxOrgStdlib::RequireFiles

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.11.18 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.17 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.16 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.15 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.14 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.12 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.11 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.9 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.8 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.7 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.6 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.5 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.4 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.3 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.2 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.1 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.11.0 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.10.9 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.10.8 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.10.7 lib/fedux_org_stdlib/require_files.rb