Sha256: 40673e1548c2bf7f5b5c228d3df6e77937329939197bb4f745e378b9f5958245

Contents?: true

Size: 848 Bytes

Versions: 62

Compression:

Stored size: 848 Bytes

Contents

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

module FeduxOrgStdlib
  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(%r{/}).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)

      raise 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

62 entries across 62 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.6.54 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.53 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.52 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.51 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.50 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.48 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.47 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.46 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.45 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.44 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.43 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.40 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.39 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.38 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.37 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.34 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.33 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.32 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.31 lib/fedux_org_stdlib/require_files.rb
fedux_org-stdlib-0.6.30 lib/fedux_org_stdlib/require_files.rb