summaryrefslogtreecommitdiff
path: root/app/helpers/blob_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/blob_helper.rb')
-rw-r--r--app/helpers/blob_helper.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index 07ff6fb9488..3a9fd90d636 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -1,3 +1,5 @@
+require 'csv'
+
module BlobHelper
def highlight(blob_name, blob_content, repository: nil, plain: false)
highlighted = Gitlab::Highlight.highlight(blob_name, blob_content, plain: plain, repository: repository)
@@ -8,6 +10,14 @@ module BlobHelper
%w(credits changelog news copying copyright license authors)
end
+ def blob_to_csv(blob, options = {})
+ begin
+ CSV.parse(blob.data, options)
+ rescue CSV::MalformedCSVError
+ nil
+ end
+ end
+
def edit_blob_link(project = @project, ref = @ref, path = @path, options = {})
return unless current_user