Class: Renalware::UKRDC::Paths
- Inherits:
-
Object
- Object
- Renalware::UKRDC::Paths
- Defined in:
- app/models/renalware/ukrdc/paths.rb
Instance Attribute Summary collapse
-
#batch_number ⇒ Object
readonly
Returns the value of attribute batch_number.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#working_path ⇒ Object
readonly
Returns the value of attribute working_path.
Instance Method Summary collapse
- #archive_folder ⇒ Object
- #create_folders ⇒ Object
- #create_symlink_to_latest_timestamped_folder_so_it_is_easier_to_eyeball ⇒ Object
-
#initialize(timestamp: nil, batch_number:, working_path:) ⇒ Paths
constructor
A new instance of Paths.
-
#latest_archive_symlink_name ⇒ Object
Name for the symlink to the latest archive folder.
- #outgoing_folder ⇒ Object
- #timestamped_encrypted_folder ⇒ Object
- #timestamped_folder ⇒ Object
- #timestamped_xml_folder ⇒ Object
Constructor Details
#initialize(timestamp: nil, batch_number:, working_path:) ⇒ Paths
Returns a new instance of Paths.
10 11 12 13 14 15 16 17 18 |
# File 'app/models/renalware/ukrdc/paths.rb', line 10 def initialize(timestamp: nil, batch_number:, working_path:) raise(ArgumentError, "Invalid working_path") if working_path.blank? @timestamp = @batch_number = batch_number @timestamp ||= Time.zone.now.strftime("%Y%m%d%H%M%S%L") @working_path = Pathname(working_path) create_folders end |
Instance Attribute Details
#batch_number ⇒ Object (readonly)
Returns the value of attribute batch_number.
8 9 10 |
# File 'app/models/renalware/ukrdc/paths.rb', line 8 def batch_number @batch_number end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
8 9 10 |
# File 'app/models/renalware/ukrdc/paths.rb', line 8 def @timestamp end |
#working_path ⇒ Object (readonly)
Returns the value of attribute working_path.
8 9 10 |
# File 'app/models/renalware/ukrdc/paths.rb', line 8 def working_path @working_path end |
Instance Method Details
#archive_folder ⇒ Object
20 21 22 |
# File 'app/models/renalware/ukrdc/paths.rb', line 20 def archive_folder @archive_folder ||= working_path.join("archive") end |
#create_folders ⇒ Object
52 53 54 55 56 |
# File 'app/models/renalware/ukrdc/paths.rb', line 52 def create_folders FileUtils.mkdir_p FileUtils.mkdir_p FileUtils.mkdir_p outgoing_folder end |
#create_symlink_to_latest_timestamped_folder_so_it_is_easier_to_eyeball ⇒ Object
45 46 47 48 49 50 |
# File 'app/models/renalware/ukrdc/paths.rb', line 45 def if File.exist?(latest_archive_symlink_name) FileUtils.rm(latest_archive_symlink_name) end FileUtils.ln_sf(, latest_archive_symlink_name) end |
#latest_archive_symlink_name ⇒ Object
Name for the symlink to the latest archive folder
25 26 27 |
# File 'app/models/renalware/ukrdc/paths.rb', line 25 def latest_archive_symlink_name @latest_archive_symlink_name ||= archive_folder.join("latest") end |
#outgoing_folder ⇒ Object
29 30 31 |
# File 'app/models/renalware/ukrdc/paths.rb', line 29 def outgoing_folder @outgoing_folder ||= working_path.join("outgoing") end |
#timestamped_encrypted_folder ⇒ Object
41 42 43 |
# File 'app/models/renalware/ukrdc/paths.rb', line 41 def @timestamped_encrypted_folder ||= .join("encrypted") end |
#timestamped_folder ⇒ Object
33 34 35 |
# File 'app/models/renalware/ukrdc/paths.rb', line 33 def @timestamped_folder ||= archive_folder.join("#{batch_number}_#{}") end |
#timestamped_xml_folder ⇒ Object
37 38 39 |
# File 'app/models/renalware/ukrdc/paths.rb', line 37 def @timestamped_xml_folder ||= .join("xml") end |