Module: FeduxOrgStdlib::RequireFiles
- Defined in:
- lib/fedux_org_stdlib/require_files.rb
Overview
Helper
Instance Method Summary collapse
- #require_installed_gem(gems, _message_template = 'You need to install %s to make "%s" work.') ⇒ Object
- #require_library(libraries, message_template = 'You need to install %s to make "%s" work.') ⇒ Object
Instance Method Details
#require_installed_gem(gems, _message_template = 'You need to install %s to make "%s" work.') ⇒ Object
20 21 22 23 24 |
# File 'lib/fedux_org_stdlib/require_files.rb', line 20 def require_installed_gem(gems, = '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.') ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fedux_org_stdlib/require_files.rb', line 7 def require_library(libraries, = 'You need to install %s to make "%s" work.') libraries = Array(libraries) begin libraries.each { |l| require l } rescue LoadError => e $stderr.puts format(, libraries.map { |l| l.split(/\//).first }.uniq.to_list, caller[1].split(/:/)[0, 2].join(':')) $stderr.puts $stderr.puts e. exit 1 end end |