Class: PortalModule::LoanEntry
- Inherits:
-
Object
- Object
- PortalModule::LoanEntry
- Includes:
- Assertable
- Defined in:
- lib/portal_module/loan_entry.rb
Constant Summary collapse
- DL_FILENAME =
'2-LatestPrequal.xml'
Instance Attribute Summary collapse
-
#page_factory ⇒ Object
readonly
Returns the value of attribute page_factory.
Instance Method Summary collapse
- #activate ⇒ Object
-
#download(org, file_path) ⇒ Object
Export loan entry data for an org unit to a file.
-
#initialize(page_factory) ⇒ LoanEntry
constructor
A new instance of LoanEntry.
- #set_org(org) ⇒ Object
-
#upload(org, file_path) ⇒ Object
Import loan entry data from a file.
Methods included from Assertable
#assert_dir_exists, #assert_dl_dir_is_configured, #assert_file_exists, #assert_org_is_configured
Constructor Details
#initialize(page_factory) ⇒ LoanEntry
Returns a new instance of LoanEntry.
20 21 22 |
# File 'lib/portal_module/loan_entry.rb', line 20 def initialize page_factory @page_factory = page_factory end |
Instance Attribute Details
#page_factory ⇒ Object (readonly)
Returns the value of attribute page_factory.
18 19 20 |
# File 'lib/portal_module/loan_entry.rb', line 18 def page_factory @page_factory end |
Instance Method Details
#activate ⇒ Object
24 25 26 27 |
# File 'lib/portal_module/loan_entry.rb', line 24 def activate loan_entry_page .activate end |
#download(org, file_path) ⇒ Object
Export loan entry data for an org unit to a file
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# 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..include? 'No such file or directory' raise IOError, "No such directory - #{file_path}" else raise e end end |
#set_org(org) ⇒ Object
29 30 31 32 33 |
# 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) ⇒ Object
Import loan entry data from a file
68 69 70 71 72 73 74 75 |
# 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).) end |