Module: DbAgile::Robustness::Dependencies
- Included in:
- DbAgile::Robustness
- Defined in:
- lib/dbagile/robustness/dependencies.rb
Instance Method Summary collapse
-
#has_gem!(gem_name, gem_version = nil, msg = nil) ⇒ Object
Asserts that a gem exists and is loaded.
-
#has_stdlib!(util_name, msg = nil) ⇒ Object
Asserts that a standard library.
Instance Method Details
#has_gem!(gem_name, gem_version = nil, msg = nil) ⇒ Object
Asserts that a gem exists and is loaded
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dbagile/robustness/dependencies.rb', line 20 def has_gem!(gem_name, gem_version = nil, msg = nil) require 'rubygems' gem gem_name, gem_version require gem_name rescue StandardError => ex if msg.nil? msg = gem_version.nil? ? gem_name : "#{gem_name} (#{gem_version})" msg = "DbAgile requires #{msg} but failed to load it" end msg = "#{msg}\n#{ex.}" raise DbAgile::DependencyError, msg, ex.backtrace end |
#has_stdlib!(util_name, msg = nil) ⇒ Object
Asserts that a standard library
9 10 11 12 13 14 15 16 17 |
# File 'lib/dbagile/robustness/dependencies.rb', line 9 def has_stdlib!(util_name, msg = nil) require util_name rescue StandardError => ex if msg.nil? msg = "DbAgile requires #{util_name} but failed to load it" end msg = "#{msg}\n#{ex.}" raise DbAgile::DependencyError, msg, ex.backtrace end |