Module: Assertable
- Included in:
- PortalModule::Dts, PortalModule::LoanEntry
- Defined in:
- lib/portal_module/assertable.rb
Instance Method Summary collapse
-
#assert_dir_exists(path) ⇒ Object
File System Asserts.
- #assert_dl_dir_is_configured ⇒ Object
- #assert_file_exists(path) ⇒ Object
-
#assert_org_is_configured(org) ⇒ Object
ConfigurationError Asserts.
Instance Method Details
#assert_dir_exists(path) ⇒ Object
File System Asserts
27 28 29 30 31 |
# File 'lib/portal_module/assertable.rb', line 27 def assert_dir_exists path path = Pathname(path) dir = path.dirname raise IOError, "No such directory - #{path}" unless dir.exist? end |
#assert_dl_dir_is_configured ⇒ Object
19 20 21 22 23 24 |
# File 'lib/portal_module/assertable.rb', line 19 def assert_dl_dir_is_configured dd = PortalModule.configuration.download_dir if (dd.nil? || dd.to_s.empty?) raise ConfigurationError, "Download directory has not been configured" end end |
#assert_file_exists(path) ⇒ Object
33 34 35 36 |
# File 'lib/portal_module/assertable.rb', line 33 def assert_file_exists path path = Pathname(path) raise IOError, "File not found: #{path}" unless path.exist? && !path.directory? end |
#assert_org_is_configured(org) ⇒ Object
ConfigurationError Asserts
13 14 15 16 17 |
# File 'lib/portal_module/assertable.rb', line 13 def assert_org_is_configured org unless PortalModule.configuration.orgs.key?(org) raise ConfigurationError, "Org Unit has not been configured - #{org}" end end |