class PortalModule::LoanEntry
Constants
- DL_FILENAME
Attributes
page_factory[R]
Public Class Methods
new(page_factory)
click to toggle source
# File lib/portal_module/loan_entry.rb, line 20 def initialize page_factory @page_factory = page_factory end
Public Instance Methods
activate()
click to toggle source
# File lib/portal_module/loan_entry.rb, line 24 def activate loan_entry_page .activate end
download(org, file_path)
click to toggle source
Export loan entry data for an org unit to a file
# File lib/portal_module/loan_entry.rb, line 38 def download org, file_path assert_org_is_configured org assert_dl_dir_is_configured assert_dir_exists file_path loan_entry_page .load_org(org_string(org)) .download file_path = Pathname(file_path) file_path = file_path + DL_FILENAME if file_path.directory? dl_file = download_dir + DL_FILENAME wait_for_file(dl_file, PortalModule.configuration.download_timeout) assert_file_exists dl_file FileUtils.mv dl_file, file_path rescue Exception => e if e.message.include? 'No such file or directory' raise IOError, "No such directory - #{file_path}" else raise e end end
set_org(org)
click to toggle source
# File lib/portal_module/loan_entry.rb, line 29 def set_org org assert_org_is_configured org loan_entry_page.load_org(org_string(org)) end
upload(org, file_path)
click to toggle source
Import loan entry data from a file
# File lib/portal_module/loan_entry.rb, line 68 def upload org, file_path assert_org_is_configured org assert_file_exists file_path loan_entry_page .load_org(org_string(org)) .upload(Pathname(file_path).expand_path) end
Private Instance Methods
download_dir()
click to toggle source
# File lib/portal_module/loan_entry.rb, line 83 def download_dir Pathname(PortalModule.configuration.download_dir) end
loan_entry_page()
click to toggle source
# File lib/portal_module/loan_entry.rb, line 79 def loan_entry_page page_factory.loan_entry_page end
org_string(org)
click to toggle source
# File lib/portal_module/loan_entry.rb, line 87 def org_string org orgid = PortalModule.configuration.orgs[org] orgstr = "#{orgid}~#{org}" end
wait_for_file(file_path, timeout_secs)
click to toggle source
# File lib/portal_module/loan_entry.rb, line 92 def wait_for_file(file_path, timeout_secs) stop_time = Time.now + timeout_secs file_path = Pathname(file_path) while !file_path.exist? break if stop_time <= Time.now sleep 1 end end