module FeduxOrgStdlib::RequireFiles
Helper
Public Instance Methods
require_installed_gem(gems, _message_template = 'You need to install %s to make "%s" work.')
click to toggle source
# File lib/fedux_org_stdlib/require_files.rb, line 20 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
require_library(libraries, message_template = 'You need to install %s to make "%s" work.')
click to toggle source
# File lib/fedux_org_stdlib/require_files.rb, line 7 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