Merge branch '3118-docker-fixes'
[arvados.git] / apps / workbench / app / helpers / collections_helper.rb
index 1f867a60b6725341ed274f9d862ca1d4f90c5f7a..23933cf599bd88e5a6d4a9b75d0dcd1a19f6e004 100644 (file)
@@ -5,14 +5,35 @@ module CollectionsHelper
     end
   end
 
+  ##
+  # Regex match for collection UUIDs, returns a regex match object with the
+  # hash in group 1, (optional) size in group 2, (optional) subsequent uuid
+  # fields in group 3, and (optional) file path within the collection as group
+  # 4; or nil for no match.
+  #
+  # +uuid+ the uuid string to match
+  #
   def self.match(uuid)
     /^([a-f0-9]{32})(\+[0-9]+)?(\+.*?)?(\/.*)?$/.match(uuid.to_s)
   end
 
+  ##
+  # Regex match for common image file extensions, returns a regex match object
+  # with the matched extension in group 1; or nil for no match.
+  #
+  # +file+ the file string to match
+  #
   def self.is_image file
     /\.(jpg|jpeg|gif|png|svg)$/i.match(file)
   end
 
+  ##
+  # Generates a relative file path than can be appended to the URL of a
+  # collection to get a file download link without adding a spurious ./ at the
+  # beginning for files in the default stream.
+  #
+  # +file+ an entry in the Collection.files list in the form [stream, name, size]
+  #
   def self.file_path file
     f0 = file[0]
     f0 = '' if f0 == '.'