diff options
author | Robert Speicher <rspeicher@gmail.com> | 2017-12-19 17:31:43 -0600 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-12-19 17:31:43 -0600 |
commit | 49adde6995dc780081860757aff2038821eb41ca (patch) | |
tree | 488a83d7637439467d12c07f8e0737dcd36f4a54 /app/models/blob_viewer/csv.rb | |
parent | 5b880f0d36b082a0b443c5fe95f51a84dee27475 (diff) | |
download | gitlab-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.rb | 21 |
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 |