Class: Aqueduct::Repositories::Mounted
- Inherits:
-
Object
- Object
- Aqueduct::Repositories::Mounted
- Includes:
- Aqueduct::Repository
- Defined in:
- lib/aqueduct/repositories/mounted.rb
Instance Method Summary collapse
- #count_files(file_locators, file_type) ⇒ Object
- #file_server_available? ⇒ Boolean
- #get_file(file_locator, file_type) ⇒ Object
- #has_repository? ⇒ Boolean
Instance Method Details
#count_files(file_locators, file_type) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/aqueduct/repositories/mounted.rb', line 8 def count_files(file_locators, file_type) error = '' result = 0 file_paths = [] url_paths = [] file_locators.each do |file_locator| file_locator = file_locator.to_s.gsub(/[\/*]/, '') # Don't allow wild cards or subfolders file_type = file_type.to_s.gsub(/[\/*]/, '') # Don't allow wild cards or subfolders matching_file_names = Dir.glob(File.join(Rails.root, 'tmp', 'symbolic', "source_#{@source.id}", @source.file_server_path, "#{file_locator}#{file_type}")) matching_file_names.each do |file_name| file_paths << file_name unless file_name.blank? url_paths << SITE_URL + "/sources/#{@source.id}/download_file?file_locator=#{file_locator}&file_type=#{file_type}&fn=#{file_name.split('/').last}" unless file_name.blank? end end { result: url_paths.size, error: error, file_paths: file_paths, urls: url_paths } end |
#file_server_available? ⇒ Boolean
34 35 36 |
# File 'lib/aqueduct/repositories/mounted.rb', line 34 def file_server_available? { result: true, error: "" } end |
#get_file(file_locator, file_type) ⇒ Object
25 26 27 28 |
# File 'lib/aqueduct/repositories/mounted.rb', line 25 def get_file(file_locator, file_type) result_hash = count_files([file_locator], file_type) { file_path: result_hash[:file_paths].first.to_s, error: result_hash[:error] } end |
#has_repository? ⇒ Boolean
30 31 32 |
# File 'lib/aqueduct/repositories/mounted.rb', line 30 def has_repository? { result: true, error: '' } end |