Class: EtdaUtilities::EtdaFilePaths

Inherits:
Object
  • Object
show all
Defined in:
lib/etda_utilities/etda_file_paths.rb

Constant Summary collapse

RESTRICTED_DIR =
'restricted'
RESTRICTED_INSTITUTION_DIR =
'restricted_institution'
RESTRICTED_LIBERAL_ARTS_DIR =
'restricted_liberal_arts'
OPEN_DIR =
'open_access'

Instance Method Summary collapse

Instance Method Details

#detailed_file_path(file_id, remediated: false) ⇒ Object

If remediated is true, the path will include the "remediated" subdirectory This will differentiate remediated files from original files while maintaining a similar directory structure to final_submission_files.



45
46
47
48
49
# File 'lib/etda_utilities/etda_file_paths.rb', line 45

def detailed_file_path(file_id, remediated: false)
  str1 = format("%02d", ((file_id.to_i || 0) % 100))
  str2 = file_id.to_s
  remediated ? "remediated/#{str1}/#{str2}/" : "#{str1}/#{str2}/"
end

#explore_base_pathObject



14
15
16
# File 'lib/etda_utilities/etda_file_paths.rb', line 14

def explore_base_path
  (defined? EXPLORE_BASE_PATH) ? EXPLORE_BASE_PATH : 'tmp/'
end

#explore_download_file_path(file_id, access_level, filename, remediated: false) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/etda_utilities/etda_file_paths.rb', line 51

def explore_download_file_path(file_id, access_level, filename, remediated: false)
  return nil if file_id.nil? || access_level.empty?

  return nil if access_level == 'restricted'

  return explore_open + detailed_file_path(file_id, remediated: remediated) + filename if access_level == 'open_access'

  return explore_psu_only + detailed_file_path(file_id, remediated: remediated) + filename if ['restricted_to_institution', 'restricted_liberal_arts'].include?(access_level)

  nil
end

#explore_liberal_arts_onlyObject



38
39
40
# File 'lib/etda_utilities/etda_file_paths.rb', line 38

def explore_liberal_arts_only
  "#{explore_base_path}#{RESTRICTED_LIBERAL_ARTS_DIR}/"
end

#explore_openObject



30
31
32
# File 'lib/etda_utilities/etda_file_paths.rb', line 30

def explore_open
  "#{explore_base_path}#{OPEN_DIR}/"
end

#explore_psu_onlyObject



34
35
36
# File 'lib/etda_utilities/etda_file_paths.rb', line 34

def explore_psu_only
  "#{explore_base_path}#{RESTRICTED_INSTITUTION_DIR}/"
end

#workflow_base_pathObject



10
11
12
# File 'lib/etda_utilities/etda_file_paths.rb', line 10

def workflow_base_path
  (defined? WORKFLOW_BASE_PATH) ? WORKFLOW_BASE_PATH : 'tmp/'
end

#workflow_restrictedObject



26
27
28
# File 'lib/etda_utilities/etda_file_paths.rb', line 26

def workflow_restricted
  "#{workflow_base_path}#{RESTRICTED_DIR}/"
end

#workflow_upload_final_files_pathObject



18
19
20
# File 'lib/etda_utilities/etda_file_paths.rb', line 18

def workflow_upload_final_files_path
  "#{workflow_base_path}final_submission_files/"
end

#workflow_upload_format_review_pathObject



22
23
24
# File 'lib/etda_utilities/etda_file_paths.rb', line 22

def workflow_upload_format_review_path
  "#{workflow_base_path}format_review_files/"
end