summaryrefslogtreecommitdiff
path: root/app/models/blob_viewer/csv.rb
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2017-12-19 17:31:43 -0600
committerRobert Speicher <rspeicher@gmail.com>2017-12-19 17:31:43 -0600
commit49adde6995dc780081860757aff2038821eb41ca (patch)
tree488a83d7637439467d12c07f8e0737dcd36f4a54 /app/models/blob_viewer/csv.rb
parent5b880f0d36b082a0b443c5fe95f51a84dee27475 (diff)
downloadgitlab-ce-rs-csv-viewer.tar.gz
Add a CSV blob view handlerrs-csv-viewer
Diffstat (limited to 'app/models/blob_viewer/csv.rb')
-rw-r--r--app/models/blob_viewer/csv.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/models/blob_viewer/csv.rb b/app/models/blob_viewer/csv.rb
new file mode 100644
index 00000000000..c26900c4d35
--- /dev/null
+++ b/app/models/blob_viewer/csv.rb
@@ -0,0 +1,21 @@
+require 'csv'
+
+module BlobViewer
+ class CSV < Base
+ include ServerSide
+
+ self.binary = false
+ self.extensions = %w(csv)
+ self.partial_name = 'csv'
+ self.switcher_icon = 'file-excel-o'
+ self.type = :rich
+
+ def parse(&block)
+ begin
+ ::CSV.parse(blob.data).each_with_index(&block)
+ rescue ::CSV::MalformedCSVError => ex
+ # TODO (rspeicher): How do we want to handle this?
+ end
+ end
+ end
+end